Interface ConsumerService<Context>
- Type Parameters:
Context- Context
- All Superinterfaces:
Consumer<Context>,Function<Context,,State> Service<Context,,State> SideEffectService<Context>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface ConsumerService<Context>
extends SideEffectService<Context>, Consumer<Context>
Service type where each implementation gets a chance to consume the context. This service type
effectively turns the pipeline into an event bus.
A service can forcefully terminate execution by calling interrupt()
-
Nested Class Summary
Nested Classes -
Method Summary
-
Method Details
-
interrupt
Immediately terminate the execution and returnState.ACCEPTED- Throws:
ConsumerService.PipeBurst- Pipe burst
-
handle
Description copied from interface:SideEffectServiceConsumes the context, if possible. ReturnsState.ACCEPTEDif the input was consumed, elseState.REJECTED- Specified by:
handlein interfaceService<Context,State> - Specified by:
handlein interfaceSideEffectService<Context>- Parameters:
context- context used in the generation of the response- Returns:
- Response. If the response isn't
State.ACCEPTED, the next service in the service chain will get to act on the context. Otherwise the execution halts, and the provided response is the final response.
-
accept
Accept the context. Callinterrupt()to interrupt the entire pipeline and immediately returnState.ACCEPTEDto the sink
-