Package org.drasyl.pipeline.handler
Class MessagesThroughputHandler
- java.lang.Object
-
- org.drasyl.pipeline.skeleton.HandlerAdapter
-
- org.drasyl.pipeline.skeleton.AddressHandlerAdapter<A>
-
- org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler<I,E,A>
-
- org.drasyl.pipeline.skeleton.SimpleDuplexEventAwareHandler<I,Event,O,A>
-
- org.drasyl.pipeline.skeleton.SimpleDuplexHandler<Object,Object,Address>
-
- org.drasyl.pipeline.handler.MessagesThroughputHandler
-
-
Field Summary
Fields Modifier and Type Field Description static Duration
INTERVAL
static String
MESSAGES_THROUGHPUT_HANDLER
-
Constructor Summary
Constructors Constructor Description MessagesThroughputHandler()
Creates a new handler which visualizes the number of inbound and outbound messages per second.MessagesThroughputHandler(BiPredicate<Address,Object> consumeOutbound, BiPredicate<Address,Object> consumeInbound)
Creates a new handler which visualizes the number of inbound and outbound messages per second, consumes outbound message matchingconsumeOutbound
, and inbound messages matchingconsumeInbound
.MessagesThroughputHandler(BiPredicate<Address,Object> consumeOutbound, BiPredicate<Address,Object> consumeInbound, io.reactivex.rxjava3.core.Scheduler scheduler)
Creates a new handler which visualizes the number of inbound and outbound messages per second, consumes outbound message matchingconsumeOutbound
, and inbound messages matchingconsumeInbound
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.protected void
matchedRead(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleInboundEventAwareHandler
.protected void
matchedWrite(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleDuplexEventAwareHandler
.-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleDuplexHandler
matchedEventTriggered
-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleDuplexEventAwareHandler
acceptOutbound, write
-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler
acceptEvent, acceptInbound, read
-
Methods inherited from class org.drasyl.pipeline.skeleton.AddressHandlerAdapter
acceptAddress
-
Methods inherited from class org.drasyl.pipeline.skeleton.HandlerAdapter
exceptionCaught, handlerAdded, handlerRemoved
-
-
-
-
Field Detail
-
MESSAGES_THROUGHPUT_HANDLER
public static final String MESSAGES_THROUGHPUT_HANDLER
- See Also:
- Constant Field Values
-
INTERVAL
public static final Duration INTERVAL
-
-
Constructor Detail
-
MessagesThroughputHandler
public MessagesThroughputHandler(BiPredicate<Address,Object> consumeOutbound, BiPredicate<Address,Object> consumeInbound, io.reactivex.rxjava3.core.Scheduler scheduler)
Creates a new handler which visualizes the number of inbound and outbound messages per second, consumes outbound message matchingconsumeOutbound
, and inbound messages matchingconsumeInbound
.- Parameters:
consumeOutbound
- predicate that consumes outbound messages on matchconsumeInbound
- predicate that consumes inbound messages on matchscheduler
- scheduler on which this handler is executed
-
MessagesThroughputHandler
public MessagesThroughputHandler(BiPredicate<Address,Object> consumeOutbound, BiPredicate<Address,Object> consumeInbound)
Creates a new handler which visualizes the number of inbound and outbound messages per second, consumes outbound message matchingconsumeOutbound
, and inbound messages matchingconsumeInbound
.- Parameters:
consumeOutbound
- predicate that consumes outbound messages on matchconsumeInbound
- predicate that consumes inbound messages on match
-
MessagesThroughputHandler
public MessagesThroughputHandler()
Creates a new handler which visualizes the number of inbound and outbound messages per second.
-
-
Method Detail
-
eventTriggered
public void eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Description copied from interface:Handler
Gets called if aEvent
was emitted.- Specified by:
eventTriggered
in interfaceHandler
- Overrides:
eventTriggered
in classSimpleDuplexHandler<Object,Object,Address>
- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
matchedWrite
protected void matchedWrite(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future)
Description copied from class:SimpleDuplexEventAwareHandler
Is called for each message of typeSimpleDuplexEventAwareHandler
.- Specified by:
matchedWrite
in classSimpleDuplexEventAwareHandler<Object,Event,Object,Address>
- Parameters:
ctx
- handler contextrecipient
- the recipient of the messagemsg
- the messagefuture
- a future for the message
-
matchedRead
protected void matchedRead(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future)
Description copied from class:SimpleInboundEventAwareHandler
Is called for each message of typeSimpleInboundEventAwareHandler
.- Specified by:
matchedRead
in classSimpleInboundEventAwareHandler<Object,Event,Address>
- Parameters:
ctx
- handler contextsender
- the sender of the messagemsg
- the messagefuture
- the future of the message
-
-