Package com.linecorp.armeria.server
Class ServiceRequestContextBuilder
java.lang.Object
com.linecorp.armeria.common.AbstractRequestContextBuilder
com.linecorp.armeria.server.ServiceRequestContextBuilder
Builds a new
ServiceRequestContext
. Note that it is not usually required to create a new context by
yourself, because Armeria will always provide a context object for you. However, it may be useful in some
cases such as unit testing.-
Method Summary
Modifier and TypeMethodDescriptionalloc
(ByteBufAllocator alloc) Sets theByteBufAllocator
.build()
Returns a newServiceRequestContext
created with the properties of this builder.defaultLogName
(String defaultLogName) Sets the default value of theRequestOnlyLog.name()
property which is used when no name was set viaRequestLogBuilder.name(String, String)
.defaultServiceName
(String defaultServiceName) Sets the default value of theRequestOnlyLog.serviceName()
property which is used when no service name was set viaRequestLogBuilder.name(String, String)
.defaultServiceNaming
(ServiceNaming defaultServiceNaming) Sets the default naming rule for theRequestOnlyLog.serviceName()
.Sets theEventLoop
that handles the request.Sets theRequestId
.localAddress
(InetSocketAddress localAddress) Sets the local socket address of the connection.meterRegistry
(MeterRegistry meterRegistry) Sets theMeterRegistry
.proxiedAddresses
(ProxiedAddresses proxiedAddresses) Sets theProxiedAddresses
of the request.remoteAddress
(InetSocketAddress remoteAddress) Sets the remote socket address of the connection.requestStartTime
(long requestStartTimeNanos, long requestStartTimeMicros) Sets the request start time of the request.Sets theRoute
of the request.routingResult
(RoutingResult routingResult) Sets theRoutingResult
of the request.serverConfigurator
(Consumer<? super ServerBuilder> serverConfigurator) Adds theConsumer
that configures the givenServerBuilder
.service
(HttpService service) Sets theService
that handles the request.sessionProtocol
(SessionProtocol sessionProtocol) Sets theSessionProtocol
of the request.sslSession
(SSLSession sslSession) Sets theSSLSession
of the connection.timedOut
(boolean timedOut) Sets the specifiedtimedOut
.Methods inherited from class com.linecorp.armeria.common.AbstractRequestContextBuilder
alloc, authority, eventLoop, fakeChannel, id, isRequestStartTimeSet, localAddress, meterRegistry, method, method, remoteAddress, request, requestStartTimeMicros, requestStartTimeNanos, requestTarget, rpcRequest, sessionProtocol, sslSession, timedOut
-
Method Details
-
service
-
defaultServiceName
Sets the default value of theRequestOnlyLog.serviceName()
property which is used when no service name was set viaRequestLogBuilder.name(String, String)
.- Parameters:
defaultServiceName
- the default log name.
-
defaultServiceNaming
Sets the default naming rule for theRequestOnlyLog.serviceName()
. If set, the service name will be converted according to given naming rule.- Parameters:
defaultServiceNaming
- the default service naming.
-
defaultLogName
Sets the default value of theRequestOnlyLog.name()
property which is used when no name was set viaRequestLogBuilder.name(String, String)
.- Parameters:
defaultLogName
- the default log name.
-
route
Sets theRoute
of the request. If not set, it is auto-generated from the request. -
routingResult
Sets theRoutingResult
of the request. If not set, it is auto-generated from the request. -
proxiedAddresses
Sets theProxiedAddresses
of the request. If not set,ServiceRequestContext.proxiedAddresses()
will returnnull
. -
serverConfigurator
public ServiceRequestContextBuilder serverConfigurator(Consumer<? super ServerBuilder> serverConfigurator) Adds theConsumer
that configures the givenServerBuilder
. TheConsumer
s added by this method will be invoked when this builder builds a dummyServer
. This may be useful when you need to update the default settings of the dummyServer
, such asServerBuilder.maxRequestLength(long)
. -
build
Returns a newServiceRequestContext
created with the properties of this builder. -
meterRegistry
Description copied from class:AbstractRequestContextBuilder
Sets theMeterRegistry
. If not set,NoopMeterRegistry
is used.- Overrides:
meterRegistry
in classAbstractRequestContextBuilder
-
eventLoop
Description copied from class:AbstractRequestContextBuilder
Sets theEventLoop
that handles the request. If not set, one of theCommonPools.workerGroup()
is used.- Overrides:
eventLoop
in classAbstractRequestContextBuilder
-
alloc
Description copied from class:AbstractRequestContextBuilder
Sets theByteBufAllocator
. If not set,ByteBufAllocator.DEFAULT
is used.- Overrides:
alloc
in classAbstractRequestContextBuilder
-
sessionProtocol
Description copied from class:AbstractRequestContextBuilder
Sets theSessionProtocol
of the request.- Overrides:
sessionProtocol
in classAbstractRequestContextBuilder
-
id
Description copied from class:AbstractRequestContextBuilder
- Overrides:
id
in classAbstractRequestContextBuilder
-
remoteAddress
Description copied from class:AbstractRequestContextBuilder
Sets the remote socket address of the connection. If not set, it is auto-generated with the localhost IP address (e.g."127.0.0.1"
or"::1"
).- Overrides:
remoteAddress
in classAbstractRequestContextBuilder
-
localAddress
Description copied from class:AbstractRequestContextBuilder
Sets the local socket address of the connection. If not set, it is auto-generated with the localhost IP address (e.g."127.0.0.1"
or"::1"
).- Overrides:
localAddress
in classAbstractRequestContextBuilder
-
sslSession
Description copied from class:AbstractRequestContextBuilder
Sets theSSLSession
of the connection. If the currentSessionProtocol
is not TLS, the TLS version of the currentSessionProtocol
will be set automatically. For example,SessionProtocol.H2C
will be automatically upgraded toSessionProtocol.H2
. Note that upgrading the currentSessionProtocol
may trigger anIllegalArgumentException
, as described inAbstractRequestContextBuilder.sessionProtocol(SessionProtocol)
.- Overrides:
sslSession
in classAbstractRequestContextBuilder
-
requestStartTime
public ServiceRequestContextBuilder requestStartTime(long requestStartTimeNanos, long requestStartTimeMicros) Description copied from class:AbstractRequestContextBuilder
Sets the request start time of the request.- Overrides:
requestStartTime
in classAbstractRequestContextBuilder
- Parameters:
requestStartTimeNanos
- theSystem.nanoTime()
value when the request started.requestStartTimeMicros
- the number of microseconds since the epoch when the request started.
-
timedOut
Description copied from class:AbstractRequestContextBuilder
Sets the specifiedtimedOut
. If the specifiedtimedOut
istrue
,RequestContext.isTimedOut()
will always returntrue
. This is useful for checking the behavior of aService
andClient
when a request exceeds a deadline.- Overrides:
timedOut
in classAbstractRequestContextBuilder
-