Package com.linecorp.armeria.server
Class ServiceRequestContextBuilder
java.lang.Object
com.linecorp.armeria.common.AbstractRequestContextBuilder
com.linecorp.armeria.server.ServiceRequestContextBuilder
public final class ServiceRequestContextBuilder extends AbstractRequestContextBuilder
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
Methods inherited from class com.linecorp.armeria.common.AbstractRequestContextBuilder
alloc, authority, eventLoop, fakeChannel, id, isRequestStartTimeSet, localAddress, meterRegistry, method, method, path, query, remoteAddress, request, requestStartTimeMicros, requestStartTimeNanos, 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.
-
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
-