Package com.linecorp.armeria.common
Class AbstractRequestContextBuilder
java.lang.Object
com.linecorp.armeria.common.AbstractRequestContextBuilder
- Direct Known Subclasses:
ClientRequestContextBuilder,ServiceRequestContextBuilder
Provides the information required for building a
RequestContext.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRequestContextBuilder(boolean server, HttpRequest req) Creates a new builder with the specifiedHttpRequest.protectedAbstractRequestContextBuilder(boolean server, RpcRequest rpcReq, URI uri) Creates a new builder with the specifiedRpcRequestandURI. -
Method Summary
Modifier and TypeMethodDescriptionprotected final ByteBufAllocatoralloc()Returns theByteBufAllocator.alloc(ByteBufAllocator alloc) Sets theByteBufAllocator.protected final StringReturns the authority of the request.protected final EventLoopReturns theEventLoopthat handles the request.Sets theEventLoopthat handles the request.protected final ChannelReturns a fakeChannelwhich is required internally when creating a context.protected final RequestIdid()Returns theRequestId.Sets theRequestId.protected final booleanReturns whether the request start time has been specified.protected final SocketAddressReturns the local socket address of the connection.localAddress(SocketAddress localAddress) Sets the local socket address of the connection.protected final MeterRegistryReturns theMeterRegistry.meterRegistry(MeterRegistry meterRegistry) Sets theMeterRegistry.protected final HttpMethodmethod()Returns theHttpMethodof the request.protected AbstractRequestContextBuildermethod(HttpMethod method) Sets theHttpMethodof the request.protected final SocketAddressReturns the remote socket address of the connection.remoteAddress(SocketAddress remoteAddress) Sets the remote socket address of the connection.protected final @Nullable HttpRequestrequest()Returns theHttpRequestof the context.requestStartTime(long requestStartTimeNanos, long requestStartTimeMicros) Sets the request start time of the request.protected final longReturns the number of microseconds since the epoch when the request started.protected final longReturns theSystem.nanoTime()value when the request started.protected final RequestTargetReturns theRequestTarget.protected final @Nullable RpcRequestReturns theRpcRequestof the context.protected final SessionProtocolReturns theSessionProtocolof the request.sessionProtocol(SessionProtocol sessionProtocol) Sets theSessionProtocolof the request.protected final @Nullable SSLSessionReturns theSSLSessionof the connection.sslSession(SSLSession sslSession) Sets theSSLSessionof the connection.protected final booleantimedOut()Returns whether a timeout is set.timedOut(boolean timedOut) Sets the specifiedtimedOut.
-
Constructor Details
-
AbstractRequestContextBuilder
Creates a new builder with the specifiedHttpRequest.- Parameters:
server- whether this builder will build a server-side context.req- theHttpRequest.
-
AbstractRequestContextBuilder
Creates a new builder with the specifiedRpcRequestandURI.- Parameters:
server- whether this builder will build a server-side context.rpcReq- theRpcRequest.uri- theURIof the request endpoint.
-
-
Method Details
-
meterRegistry
Returns theMeterRegistry. -
meterRegistry
Sets theMeterRegistry. If not set,NoopMeterRegistryis used. -
eventLoop
Returns theEventLoopthat handles the request. -
eventLoop
Sets theEventLoopthat handles the request. If not set, one of theCommonPools.workerGroup()is used. -
alloc
Returns theByteBufAllocator. -
alloc
Sets theByteBufAllocator. If not set,ByteBufAllocator.DEFAULTis used. -
request
Returns theHttpRequestof the context. -
rpcRequest
Returns theRpcRequestof the context. -
sessionProtocol
Returns theSessionProtocolof the request. -
sessionProtocol
Sets theSessionProtocolof the request.- Throws:
IllegalArgumentException- if the specifiedSessionProtocolis not compatible with the scheme of theURIyou specified when creating this builder. For example, you cannot specifySessionProtocol.H2Cif you created this builder withh1c://example.com/.
-
remoteAddress
Returns the remote socket address of the connection. -
remoteAddress
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"). -
localAddress
Returns the local socket address of the connection. -
localAddress
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"). -
sslSession
Returns theSSLSessionof the connection.- Returns:
- the
SSLSession, ornullif theSessionProtocolis not TLS.
-
sslSession
Sets 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 insessionProtocol(SessionProtocol). -
isRequestStartTimeSet
protected final boolean isRequestStartTimeSet()Returns whether the request start time has been specified. If not specified, the builder will use the current time returned byrequestStartTimeNanos()andrequestStartTimeMicros()as the request start time. -
requestStartTimeNanos
protected final long requestStartTimeNanos()Returns theSystem.nanoTime()value when the request started.- Throws:
IllegalStateException- if the request start time is unspecified.
-
requestStartTimeMicros
protected final long requestStartTimeMicros()Returns the number of microseconds since the epoch when the request started.- Throws:
IllegalStateException- if the request start time is unspecified.
-
requestStartTime
public AbstractRequestContextBuilder requestStartTime(long requestStartTimeNanos, long requestStartTimeMicros) Sets the request start time of the request.- Parameters:
requestStartTimeNanos- theSystem.nanoTime()value when the request started.requestStartTimeMicros- the number of microseconds since the epoch when the request started.
-
method
Returns theHttpMethodof the request. -
method
Sets theHttpMethodof the request.- Throws:
IllegalArgumentException- if the specifiedHttpMethodis not same with theHttpMethodof theHttpRequestyou specified when creating this builder. This exception is not thrown if you created a builder with anRpcRequest.
-
authority
Returns the authority of the request. -
requestTarget
Returns theRequestTarget. -
id
-
id
Returns theRequestId. -
fakeChannel
Returns a fakeChannelwhich is required internally when creating a context. -
timedOut
protected final boolean timedOut()Returns whether a timeout is set. -
timedOut
Sets the specifiedtimedOut. If the specifiedtimedOutistrue,RequestContext.isTimedOut()will always returntrue. This is useful for checking the behavior of aServiceandClientwhen a request exceeds a deadline.
-