Package org.drasyl.node.behaviour
Class Behaviors
java.lang.Object
org.drasyl.node.behaviour.Behaviors
Factories for
Behavior.
Inspired by: https://doc.akka.io/docs/akka/current/typed/fsm.html
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.channel.EventLoopGroupReturns a default, sharedEventLoopGroupinstance intended forBehaviorscheduling.static Behaviorignore()A behavior that ignores every incoming message.static Behavior.BehaviorBuilderreceive()Creates a newBehavior.BehaviorBuilderto build a newBehaviorfor inbound message/event handling.static Behaviorsame()A behavior that advises the system to reuse the previous behavior.static Behaviorshutdown()A behavior that advises the system to shutdown theDrasylNode.static BehaviorA behavior that keeps the same behavior and signals that the event was not handled (event will be logged with DEBUG level).static BehaviorA behavior with support for scheduled self events in a node.static BehaviorwithScheduler(Function<Behaviors.EventScheduler, Behavior> factory, io.netty.channel.EventLoopGroup eventLoopGroup) A behavior with support for scheduled self events in a node.
-
Method Details
-
receive
Creates a newBehavior.BehaviorBuilderto build a newBehaviorfor inbound message/event handling.Typically used from
BehavioralDrasylNode.newBehaviorBuilder(). -
unhandled
A behavior that keeps the same behavior and signals that the event was not handled (event will be logged with DEBUG level). -
ignore
A behavior that ignores every incoming message. -
same
A behavior that advises the system to reuse the previous behavior. This is provided in order to avoid the allocation overhead of recreating the current behavior where that is not necessary. -
shutdown
A behavior that advises the system to shutdown theDrasylNode. Subsequent events will be ignored. -
withScheduler
public static Behavior withScheduler(Function<Behaviors.EventScheduler, Behavior> factory, io.netty.channel.EventLoopGroup eventLoopGroup) A behavior with support for scheduled self events in a node.- Parameters:
factory- function that returns the behavior that should react to scheduled self eventseventLoopGroup- theSchedulerto perform scheduled events on
-
withScheduler
A behavior with support for scheduled self events in a node.- Parameters:
factory- function that returns the behavior that should react to scheduled self events
-
eventLoopGroup
public static io.netty.channel.EventLoopGroup eventLoopGroup()Returns a default, sharedEventLoopGroupinstance intended forBehaviorscheduling.- Returns:
- a
EventLoopGroupmeant forBehavior-bound work
-