rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
rotor::plugin::child_manager_plugin_t Struct Reference

supervisor's plugin for child-actors housekeeping More...

#include <child_manager.h>

Inheritance diagram for rotor::plugin::child_manager_plugin_t:
rotor::plugin::plugin_base_t

Public Member Functions

const std::type_index & identity () const noexcept override
 returns pointer, which uniquely identifiess plugin type
 
void activate (actor_base_t *actor) noexcept override
 invoked by actor upon initialization.
 
void deactivate () noexcept override
 deactivates plugin from an actor
 
virtual void create_child (const actor_ptr_t &actor) noexcept
 pre-initializes child and sends create_child message to the supervisor
 
virtual void spawn (factory_t factory, const pt::time_duration &period, restart_policy_t policy, size_t max_attempts, bool escalate) noexcept
 records spawner (via generating a new address) and sends spawn_actor_t message to the supervisor
 
virtual void remove_child (const actor_base_t &actor) noexcept
 removes the child from the supervisor
 
virtual void on_shutdown_fail (actor_base_t &actor, const extended_error_ptr_t &ec) noexcept
 reaction on child shutdown failure
 
virtual void on_create (message::create_actor_t &message) noexcept
 sends initialization request upon actor creation message
 
virtual void on_init (message::init_response_t &message) noexcept
 reaction on (maybe unsuccessful) init confirmation
 
virtual void on_shutdown_trigger (message::shutdown_trigger_t &message) noexcept
 reaction on shutdown trigger
 
virtual void on_shutdown_confirm (message::shutdown_response_t &message) noexcept
 reaction on shutdown confirmation (i.e. perform some cleanings)
 
virtual void on_spawn (message::spawn_actor_t &message) noexcept
 actually attempts to spawn a new actor via spawner
 
bool handle_init (message::init_request_t *) noexcept override
 polls plugin, whether it is done with initialization
 
bool handle_shutdown (message::shutdown_request_t *) noexcept override
 polls plugin, whether it is done with shutdown
 
void handle_start (message::start_trigger_t *message) noexcept override
 polls plugin, whether it is done with start
 
bool handle_unsubscription (const subscription_point_t &point, bool external) noexcept override
 polls plugin, whether it is done with unsubscription
 
template<typename T >
auto & access () noexcept
 generic non-public fields accessor
 
 plugin_base_t ()=default
 default plugin ctor
 
 plugin_base_t (const plugin_base_t &)=delete
 copy ctor is not allowed
 
- Public Member Functions inherited from rotor::plugin::plugin_base_t
 plugin_base_t ()=default
 default plugin ctor
 
 plugin_base_t (const plugin_base_t &)=delete
 copy ctor is not allowed
 
virtual bool handle_subscription (message::subscription_t &message) noexcept
 polls plugin, whether it is done with subscription
 
virtual bool forget_subscription (const subscription_point_t &point) noexcept
 remove subscription point from internal storage
 
virtual void forget_subscription (const subscription_info_ptr_t &info) noexcept
 commits unsubscription via supervisor
 
template<typename Plugin , typename Fn >
void with_casted (Fn &&fn, config_phase_t desired_phase=config_phase_t::INITIALIZING) noexcept
 invokes the callback if plugin type and phase mach
 
reaction_underlying_t get_reaction () const noexcept
 returns the current set of plugin reactions
 
void reaction_on (reaction_t value) noexcept
 turns on the specified reaction of the plugin
 
void reaction_off (reaction_t value) noexcept
 turns off the specified reaction of the plugin
 
template<typename T >
auto & access () noexcept
 generic non-public fields accessor
 

Static Public Attributes

static const std::type_index class_identity
 
- Static Public Attributes inherited from rotor::plugin::plugin_base_t
static constexpr reaction_underlying_t REACTION_MASK = 0b00001111
 the bit mask for all reactions enabled
 

Additional Inherited Members

- Public Types inherited from rotor::plugin::plugin_base_t
enum  reaction_t : unsigned { INIT = 0b00000001 , SHUTDOWN = 0b00000010 , SUBSCRIPTION = 0b00000100 , START = 0b00001000 }
 possible plugin's reactions on actor lifetime events
 
using reaction_underlying_t = std::underlying_type_t< reaction_t >
 the underlying type of reaction_t
 
- Protected Member Functions inherited from rotor::plugin::plugin_base_t
template<typename Handler >
subscription_info_ptr_t subscribe (Handler &&handler, const address_ptr_t &address) noexcept
 subscribes plugin to the custom plugin handler on the specified address
 
template<typename Handler >
subscription_info_ptr_t subscribe (Handler &&handler) noexcept
 subscribes plugin to the custom plugin handler on the main actor address
 
extended_error_ptr_t make_error (const std::error_code &ec, const extended_error_ptr_t &next={}, const message_ptr_t &request={}) noexcept
 makes an error within the context of actor
 
- Protected Attributes inherited from rotor::plugin::plugin_base_t
actor_base_tactor
 non-owning actor pointer
 

Detailed Description

supervisor's plugin for child-actors housekeeping

The plugin is responsible for child actors creation, initialization and shutdown. The supervisor policy is also handled here, e.g. if an child-actor fails to initialize self, the supervisor might shutdown self.

Member Function Documentation

◆ activate()

void rotor::plugin::child_manager_plugin_t::activate ( actor_base_t actor)
overridevirtualnoexcept

invoked by actor upon initialization.

It it responsible for setting up reactions and further installation, e.g. messages subscriptions and may calling back actor's configuration (which can be postponed).

Before the activate is invoked, the plugin is in PREINIT phase, after the activate is called, the plugin is in INITIALIZING phase. This might be useful for early/late (double) plugin configuration in actor.

Reimplemented from rotor::plugin::plugin_base_t.

◆ deactivate()

void rotor::plugin::child_manager_plugin_t::deactivate ( )
overridevirtualnoexcept

deactivates plugin from an actor

The method can be intercepted by descendants to do not deactivate too early, and called when needed.

The plugin_base_t implementation unsubscribes from all plugin subscriptions and when no subscription left commits deactivation to an actor.

Reimplemented from rotor::plugin::plugin_base_t.

◆ handle_init()

bool rotor::plugin::child_manager_plugin_t::handle_init ( message::init_request_t message)
overridevirtualnoexcept

polls plugin, whether it is done with initialization

The method is invoked only when init reaction was set on.

The true is returned, that means plugin is done with init and will not be longer polled in future.

Reimplemented from rotor::plugin::plugin_base_t.

◆ handle_shutdown()

bool rotor::plugin::child_manager_plugin_t::handle_shutdown ( message::shutdown_request_t message)
overridevirtualnoexcept

polls plugin, whether it is done with shutdown

The method is invoked only when shutdown reaction was set on.

The true is returned, that means plugin is done with shutdown and will not be longer polled in future.

Reimplemented from rotor::plugin::plugin_base_t.

◆ handle_start()

void rotor::plugin::child_manager_plugin_t::handle_start ( message::start_trigger_t message)
overridevirtualnoexcept

polls plugin, whether it is done with start

The method is invoked only when start reaction was set on.

The true is returned, that means plugin is done with start and will not be longer polled in future.

Reimplemented from rotor::plugin::plugin_base_t.

◆ handle_unsubscription()

bool rotor::plugin::child_manager_plugin_t::handle_unsubscription ( const subscription_point_t point,
bool  external 
)
overridevirtualnoexcept

polls plugin, whether it is done with unsubscription

All plugins are polled for unsubscription, no special handling is needed unless you know what your are doing.

The true is returned, that means plugin is done with unsubscription and will not be longer polled in future. The default is false.

Reimplemented from rotor::plugin::plugin_base_t.

◆ identity()

const std::type_index & rotor::plugin::child_manager_plugin_t::identity ( ) const
overridevirtualnoexcept

returns pointer, which uniquely identifiess plugin type

Implements rotor::plugin::plugin_base_t.

◆ on_init()

virtual void rotor::plugin::child_manager_plugin_t::on_init ( message::init_response_t message)
virtualnoexcept

reaction on (maybe unsuccessful) init confirmation

Possibilities:

  • shutdown child
  • shutdown self (supervisor)
  • continue init

◆ on_shutdown_fail()

virtual void rotor::plugin::child_manager_plugin_t::on_shutdown_fail ( actor_base_t actor,
const extended_error_ptr_t ec 
)
virtualnoexcept

reaction on child shutdown failure

By default it is forwarded to system context, which terminates program by default

◆ on_shutdown_trigger()

virtual void rotor::plugin::child_manager_plugin_t::on_shutdown_trigger ( message::shutdown_trigger_t message)
virtualnoexcept

reaction on shutdown trigger

Possibilities:

  • shutdown self (supervisor), via shutdown request
  • shutdown self (supervisor) directly, if there is no root supervisor
  • shutdown via request for a child

◆ remove_child()

virtual void rotor::plugin::child_manager_plugin_t::remove_child ( const actor_base_t actor)
virtualnoexcept

removes the child from the supervisor

If there was an error, the supervisor might trigger shutdown self (in accordance with policy)

Otherwise, if all is ok, it continues the supervisor initialization

Member Data Documentation

◆ class_identity

const std::type_index rotor::plugin::child_manager_plugin_t::class_identity
static

The plugin unique identity to allow further static_cast'ing


The documentation for this struct was generated from the following file: