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(io.netty.buffer.ByteBufAllocator alloc) Sets theByteBufAllocator.build()Returns a newServiceRequestContextcreated 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().eventLoop(io.netty.channel.EventLoop eventLoop) Sets theEventLoopthat handles the request.Sets theRequestId.localAddress(InetSocketAddress localAddress) Sets the local socket address of the connection.meterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry) Sets theMeterRegistry.proxiedAddresses(ProxiedAddresses proxiedAddresses) Sets theProxiedAddressesof 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 theRouteof the request.routingResult(RoutingResult routingResult) Sets theRoutingResultof the request.serverConfigurator(Consumer<? super ServerBuilder> serverConfigurator) Adds theConsumerthat configures the givenServerBuilder.service(HttpService service) Sets theServicethat handles the request.sessionProtocol(SessionProtocol sessionProtocol) Sets theSessionProtocolof the request.sslSession(SSLSession sslSession) Sets theSSLSessionof 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 theRouteof the request. If not set, it is auto-generated from the request. -
routingResult
Sets theRoutingResultof the request. If not set, it is auto-generated from the request. -
proxiedAddresses
Sets theProxiedAddressesof the request. If not set,ServiceRequestContext.proxiedAddresses()will returnnull. -
serverConfigurator
public ServiceRequestContextBuilder serverConfigurator(Consumer<? super ServerBuilder> serverConfigurator) Adds theConsumerthat configures the givenServerBuilder. TheConsumers 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 newServiceRequestContextcreated with the properties of this builder. -
meterRegistry
public ServiceRequestContextBuilder meterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry) Description copied from class:AbstractRequestContextBuilderSets theMeterRegistry. If not set,NoopMeterRegistryis used.- Overrides:
meterRegistryin classAbstractRequestContextBuilder
-
eventLoop
Description copied from class:AbstractRequestContextBuilderSets theEventLoopthat handles the request. If not set, one of theCommonPools.workerGroup()is used.- Overrides:
eventLoopin classAbstractRequestContextBuilder
-
alloc
Description copied from class:AbstractRequestContextBuilderSets theByteBufAllocator. If not set,ByteBufAllocator.DEFAULTis used.- Overrides:
allocin classAbstractRequestContextBuilder
-
sessionProtocol
Description copied from class:AbstractRequestContextBuilderSets theSessionProtocolof the request.- Overrides:
sessionProtocolin classAbstractRequestContextBuilder
-
id
Description copied from class:AbstractRequestContextBuilder- Overrides:
idin classAbstractRequestContextBuilder
-
remoteAddress
Description copied from class:AbstractRequestContextBuilderSets 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:
remoteAddressin classAbstractRequestContextBuilder
-
localAddress
Description copied from class:AbstractRequestContextBuilderSets 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:
localAddressin classAbstractRequestContextBuilder
-
sslSession
Description copied from class:AbstractRequestContextBuilderSets theSSLSessionof the connection. If the currentSessionProtocolis not TLS, the TLS version of the currentSessionProtocolwill be set automatically. For example,SessionProtocol.H2Cwill be automatically upgraded toSessionProtocol.H2. Note that upgrading the currentSessionProtocolmay trigger anIllegalArgumentException, as described inAbstractRequestContextBuilder.sessionProtocol(SessionProtocol).- Overrides:
sslSessionin classAbstractRequestContextBuilder
-
requestStartTime
public ServiceRequestContextBuilder requestStartTime(long requestStartTimeNanos, long requestStartTimeMicros) Description copied from class:AbstractRequestContextBuilderSets the request start time of the request.- Overrides:
requestStartTimein 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:AbstractRequestContextBuilderSets the specifiedtimedOut. If the specifiedtimedOutistrue,RequestContext.isTimedOut()will always returntrue. This is useful for checking the behavior of aServiceandClientwhen a request exceeds a deadline.- Overrides:
timedOutin classAbstractRequestContextBuilder
-