Class DefaultWebRequestGateway
java.lang.Object
io.fluxzero.sdk.common.AbstractNamespaced<WebRequestGateway>
io.fluxzero.sdk.web.DefaultWebRequestGateway
- All Implemented Interfaces:
Namespaced<WebRequestGateway>, WebRequestGateway, HasLocalHandlers
public class DefaultWebRequestGateway
extends AbstractNamespaced<WebRequestGateway>
implements WebRequestGateway
Default implementation of the
WebRequestGateway interface that delegates requests to a configured
GenericGateway, or executes them through a lifecycle-managed native HTTP client when explicitly requested.
It supports sending web requests in both asynchronous (fire-and-forget, future-based) and synchronous (blocking) manners. Proxy execution remains the default and preserves Fluxzero message handling and traceability.
- See Also:
-
Field Summary
Fields inherited from interface WebRequestGateway
defaultSettings -
Constructor Summary
ConstructorsConstructorDescriptionDefaultWebRequestGateway(GenericGateway delegate) Creates a gateway using a default Jackson serializer for opt-in native HTTP request bodies.DefaultWebRequestGateway(GenericGateway delegate, Serializer serializer) Creates a gateway using the configured application serializer for opt-in native HTTP request bodies. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Gracefully shuts down the gateway and releases any associated resources.protected WebRequestGatewaycreateForNamespace(String namespace) forNamespace(String namespace) Returns the resource scoped to the specified namespace.send(WebRequest request, WebRequestSettings settings) Sends the given web request using given request settings and returns a future that completes with the response.sendAndForget(io.fluxzero.common.Guarantee guarantee, WebRequest... requests) Sends one or more web requests without waiting for a response.sendAndWait(WebRequest request, WebRequestSettings settings) Sends the given web request using the specified request settings and waits for the response synchronously.withDelegate(GenericGateway delegate) Returns a gateway backed by the given proxy delegate and an independently owned native HTTP client.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilterMethods inherited from interface Namespaced
forApplicationNamespace, forDefaultNamespaceMethods inherited from interface WebRequestGateway
send, sendAndWait
-
Constructor Details
-
DefaultWebRequestGateway
Creates a gateway using a default Jackson serializer for opt-in native HTTP request bodies.- Parameters:
delegate- gateway used for proxy-routed requests
-
DefaultWebRequestGateway
Creates a gateway using the configured application serializer for opt-in native HTTP request bodies.- Parameters:
delegate- gateway used for proxy-routed requestsserializer- serializer used to encode native HTTP request bodies
-
-
Method Details
-
sendAndForget
public CompletableFuture<Void> sendAndForget(io.fluxzero.common.Guarantee guarantee, WebRequest... requests) Description copied from interface:WebRequestGatewaySends one or more web requests without waiting for a response.Use this for fire-and-forget scenarios (e.g., async webhook posts).
- Specified by:
sendAndForgetin interfaceWebRequestGateway- Parameters:
guarantee- indicates whether to wait until the request is sent or storedrequests- the web requests to send- Returns:
- a future that completes once the requests have been sent or stored
-
send
Description copied from interface:WebRequestGatewaySends the given web request using given request settings and returns a future that completes with the response.Proxy and native HTTP execution require an absolute URL; relative URLs may be handled by a local web handler. Cancelling the returned future for a native request also cancels its active HTTP call or pending retry delay on a best-effort basis.
- Specified by:
sendin interfaceWebRequestGateway- Parameters:
request- the web request to send- Returns:
- a future completed with the
WebResponse
-
sendAndWait
Description copied from interface:WebRequestGatewaySends the given web request using the specified request settings and waits for the response synchronously.This method blocks the calling thread until the request is completed or times out.
Proxy and native HTTP execution require an absolute URL; relative URLs may be handled by a local web handler.
- Specified by:
sendAndWaitin interfaceWebRequestGateway- Parameters:
request- the web request to sendsettings- configuration settings for this request (e.g., timeouts, accepted encodings)- Returns:
- the received
WebResponse
-
createForNamespace
- Specified by:
createForNamespacein classAbstractNamespaced<WebRequestGateway>
-
forNamespace
Description copied from interface:NamespacedReturns the resource scoped to the specified namespace. Passingnullselects the namespace configured for this application.- Specified by:
forNamespacein interfaceNamespaced<WebRequestGateway>- Overrides:
forNamespacein classAbstractNamespaced<WebRequestGateway>- Parameters:
namespace- the namespace to which the returned resource is scoped, ornullfor the application namespace- Returns:
- the resource associated with the specified namespace
-
withDelegate
Returns a gateway backed by the given proxy delegate and an independently owned native HTTP client.- Parameters:
delegate- gateway used for proxy-routed requests- Returns:
- this gateway if the delegate is unchanged, otherwise a gateway with an independent lifecycle
-
close
public void close()Description copied from interface:WebRequestGatewayGracefully shuts down the gateway and releases any associated resources.- Specified by:
closein interfaceWebRequestGateway- Overrides:
closein classAbstractNamespaced<WebRequestGateway>
-