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
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.channel.EventLoopGroup
Returns a default, sharedEventLoopGroup
instance intended forBehavior
scheduling.static Behavior
ignore()
A behavior that ignores every incoming message.static Behavior.BehaviorBuilder
receive()
Creates a newBehavior.BehaviorBuilder
to build a newBehavior
for inbound message/event handling.static Behavior
same()
A behavior that advises the system to reuse the previous behavior.static Behavior
shutdown()
A behavior that advises the system to shutdown theDrasylNode
.static Behavior
A behavior that keeps the same behavior and signals that the event was not handled (event will be logged with DEBUG level).static Behavior
A behavior with support for scheduled self events in a node.static Behavior
withScheduler
(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.BehaviorBuilder
to build a newBehavior
for 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
- theScheduler
to 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, sharedEventLoopGroup
instance intended forBehavior
scheduling.- Returns:
- a
EventLoopGroup
meant forBehavior
-bound work
-