Package org.incendo.cloud.services
Class ServiceSpigot<Context,Result>
java.lang.Object
org.incendo.cloud.services.ServiceSpigot<Context,Result>
- Type Parameters:
Context- Context typeResult- Result type
Class that outputs results from the given context, using the specified service type
-
Method Summary
Modifier and TypeMethodDescriptioncomplete()Returns the first result that is generated for the given context.voidcomplete(@NonNull BiConsumer<Result, Throwable> consumer) Returns the first result that is generated for the given context.Returns the first result that is generated for the given context.forward()Forward the request through the original pipeline.Forward the request through the original pipeline.
-
Method Details
-
complete
Returns the first result that is generated for the given context. This cannot returnnull.If nothing manages to produce a result, an exception will be thrown. If the pipeline has been constructed properly, this will never happen.
- Returns:
- generated result
- Throws:
IllegalStateException- If no result was found. This only happens if the pipeline has not been constructed properly. The most likely cause is a faulty default implementationIllegalStateException- If aSideEffectServicereturnsnullPipelineException- Any exceptions thrown during result retrieval from the implementations will be wrapped byPipelineException. UseThrowable.getCause()to get the exception that was thrown.PipelineException- Any exceptions thrown during filtering will be wrapped byPipelineException. UseThrowable.getCause()to get the exception that was thrown.- See Also:
-
complete
Returns the first result that is generated for the given context.If nothing manages to produce a result, an exception will be thrown. If the pipeline has been constructed properly, this will never happen. The exception passed to the consumer will be unwrapped, in the case that it's a
PipelineException. Thus, the actual exception will be given instead of the wrapper.- Parameters:
consumer- result consumer. If an exception was wrong, the result will benull, otherwise the exception will be non-null and the exception will benull.- Throws:
IllegalStateException- If no result was found. This only happens if the pipeline has not been constructed properly. The most likely cause is a faulty default implementationIllegalStateException- If aSideEffectServicereturnsnull
-
completeAsynchronously
Returns the first result that is generated for the given context. This cannot returnnull.If nothing manages to produce a result, an exception will be thrown. If the pipeline has been constructed properly, this will never happen.
- Returns:
- generated result
-
forward
Forward the request through the original pipeline.- Returns:
- New pump, for the result of this request
-
forwardAsynchronously
Forward the request through the original pipeline.- Returns:
- New pump, for the result of this request
-