Ravn::Actor::Statefulness::

InstanceMethods module

Methods that are added to extended objects.

Attributes

state_proxy R

The hashlike proxy to the state for this actor in the State Manager. Only set after start is called.

Public Class Methods

new( state_future, ... )

Add some instance data to including classes. The state_future should be a Concurrent::Promise that fulfills to a Hashlike object which is used to store persistent state. It is resolved into the state_proxy by the start Actor lifecycle method.

# File lib/ravn/actor/statefulness.rb, line 108
def initialize( state_future, ... )
        @state_proxy = nil
        @state_future = state_future

        super( ... ) if defined?( super )
end

Public Instance Methods

start()

Fetch a state proxy when the actor is started.

# File lib/ravn/actor/statefulness.rb, line 123
def start
        @state_proxy = @state_future.wait.value

        super if defined?( super )
end