Class Behaviors

java.lang.Object
org.drasyl.node.behaviour.Behaviors

public final class Behaviors extends Object
  • Method Details

    • receive

      public static Behavior.BehaviorBuilder receive()
      Creates a new Behavior.BehaviorBuilder to build a new Behavior for inbound message/event handling.

      Typically used from BehavioralDrasylNode.newBehaviorBuilder().

    • unhandled

      public static Behavior unhandled()
      A behavior that keeps the same behavior and signals that the event was not handled (event will be logged with DEBUG level).
    • ignore

      public static Behavior ignore()
      A behavior that ignores every incoming message.
    • same

      public static Behavior 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

      public static Behavior shutdown()
      A behavior that advises the system to shutdown the DrasylNode. 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 events
      eventLoopGroup - the Scheduler to perform scheduled events on
    • withScheduler

      public static Behavior withScheduler(Function<Behaviors.EventScheduler,Behavior> factory)
      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, shared EventLoopGroup instance intended for Behavior scheduling.
      Returns:
      a EventLoopGroup meant for Behavior-bound work