rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
rotor Namespace Reference

Basic namespace for all rotor functionalities. More...

Namespaces

namespace  asio
 namespace for boost::asio adapters for rotor
 
namespace  ev
 namespace for ev adapters for rotor
 
namespace  fltk
 namespace for fltk adapters for rotor
 
namespace  message
 namespace for rotor core messages (which just transform payloads)
 
namespace  payload
 namespace for rotor core payloads
 
namespace  thread
 namespace for pure thread backend (supervisor) for rotor
 
namespace  wx
 namespace for wxWidgets adapters for rotor
 

Classes

struct  actor_base_t
 universal primitive of concurrent computation More...
 
struct  actor_config_builder_t
 CRTP actor config builder. More...
 
struct  actor_config_t
 basic actor configuration: init and shutdown timeouts, etc. More...
 
struct  address_mapping_t
 NAT mechanism for rotor More...
 
struct  address_t
 Message subscription and delivery point. More...
 
struct  cancellation_t
 Request cancellation payload. More...
 
struct  continuation_t
 continue handler invocation (used for intercepting) More...
 
struct  extended_error_t
 Holds string context, error_code and the pointer to the following error. More...
 
struct  handler_base_t
 Base class for rotor handler, i.e concrete message type processing point on concrete actor. More...
 
struct  handler_intercepted_t
 proxies call to the original hanlder, applying tag-specific actions More...
 
struct  handler_t
 
struct  handler_t< Handler, std::enable_if_t< details::is_actor_handler_v< Handler > > >
 the actor handler meant to hold user-specific pointer-to-member function More...
 
struct  handler_t< Handler, std::enable_if_t< details::is_plugin_handler_v< Handler > > >
 handler specialization for plugin More...
 
struct  handler_t< lambda_holder_t< Handler, M >, std::enable_if_t< details::is_lambda_handler_v< lambda_holder_t< Handler, M > > > >
 handler specialization for lambda handler More...
 
struct  handler_traits
 Helper class to extract final actor class and message type from pointer-to-member function. More...
 
struct  handler_traits< lambda_holder_t< M, H > >
 handler decomposer for lambda-based handler More...
 
struct  handler_traits< void(A::*)(M &) noexcept >
 Helper class to extract final actor class and message type from pointer-to-member function. More...
 
struct  handler_traits< void(A::*)(M &)>
 
struct  lambda_holder_t
 Helper struct which holds lambda function for processing particular message types. More...
 
struct  message_base_t
 Base class for rotor message. More...
 
struct  message_stringifier_t
 Abstract interface for making textual/string representation of a message. More...
 
struct  message_t
 the generic message meant to hold user-specific payload More...
 
struct  message_visitor_t
 Abstract message visitor interface. More...
 
struct  plugin_storage_base_t
 abstract item to store plugins inside actor More...
 
struct  plugin_storage_t
 templated plugin storage implementation More...
 
struct  registry_t
 keeps name-to-service_address mapping at runtime More...
 
struct  request_base_t
 base class for request payload More...
 
struct  request_builder_t
 builder pattern implementation for the original request More...
 
struct  request_curry_t
 the recorded context, which is needed to produce error response to the original request More...
 
struct  request_traits_t
 type helper to deduce request/response messages from original (user-supplied) request type More...
 
struct  request_unwrapper_t
 optionally unwraps request type from intrusive pointer More...
 
struct  request_unwrapper_t< intrusive_ptr_t< T > >
 request_unwrapper_t specialization for intrusive pointer of T More...
 
struct  request_wrapper_t
 optionally wraps request type into intrusive pointer More...
 
struct  request_wrapper_t< T, std::enable_if_t< std::is_base_of_v< arc_base_t< T >, T > > >
 request_wrapper_t specialization for refcounted item More...
 
struct  response_helper_t
 generic helper, which helps to construct user-defined response payload More...
 
struct  response_helper_t< intrusive_ptr_t< Response > >
 specific helper, which helps to construct intrusive pointer to user-defined response payload More...
 
struct  spawner_t
 allows automatically restart actors More...
 
struct  subscription_container_t
 list of subscription_info_ptr_t with possibility to find via subscription_point_t More...
 
struct  subscription_info_t
 subscription_point_t with extended information (e.g. state) More...
 
struct  subscription_point_t
 pair of handler_base_t linked to particular address_t More...
 
struct  subscription_t
 Holds and classifies message handlers on behalf of supervisor. More...
 
struct  supervisor_config_builder_t
 CRTP supervisor config builder. More...
 
struct  supervisor_config_t
 base supervisor config, which holds shutdown timeout value More...
 
struct  supervisor_t
 supervisor is responsible for managing actors (workers) lifetime More...
 
struct  system_context_t
 The system context holds root supervisor_t (intrusive pointer) and may be loop-related details in derived classes. More...
 
struct  timer_handler_base_t
 Base class for timer handler. More...
 
struct  timer_handler_t
 templated implementation of timer handler More...
 
struct  wrapped_request_t
 templated request, which is able to hold user-supplied payload More...
 
struct  wrapped_request_t< T, std::enable_if_t< std::is_base_of_v< arc_base_t< T >, T > > >
 wrapped request specialization, when the request should be wrapped into intrusive pointer More...
 
struct  wrapped_response_t
 trackable templated response which holds user-supplied response payload. More...
 

Typedefs

using plugins_t = std::deque< plugin::plugin_base_t * >
 list of raw plugin pointers
 
using plugin_storage_ptr_t = std::unique_ptr< plugin_storage_base_t >
 smart pointer for plugin_storage_base_t
 
using address_ptr_t = intrusive_ptr_t< address_t >
 intrusive pointer for address
 
using counter_policy_t = boost::thread_safe_counter
 thread-safe intrusive pointer policy
 
template<typename T >
using arc_base_t = boost::intrusive_ref_counter< T, counter_policy_t >
 base class to inject ref-counter with the specified policy
 
template<typename T >
using intrusive_ptr_t = boost::intrusive_ptr< T >
 alias for intrusive pointer
 
using extended_error_ptr_t = intrusive_ptr_t< extended_error_t >
 intrusive pointer to extended error type
 
using actor_ptr_t = intrusive_ptr_t< actor_base_t >
 intrusive pointer for actor
 
using handler_ptr_t = intrusive_ptr_t< handler_base_t >
 intrusive pointer for handler
 
using supervisor_ptr_t = intrusive_ptr_t< supervisor_t >
 intrusive pointer for supervisor
 
using request_id_t = std::size_t
 timer identifier type in the scope of the actor
 
using factory_t = std::function< actor_ptr_t(supervisor_t &, const address_ptr_t &)>
 factory which allows to create actors lazily or on demand
 
using message_ptr_t = intrusive_ptr_t< message_base_t >
 intrusive pointer for message
 
using messages_queue_t = std::deque< message_ptr_t >
 structure to hold messages (intrusive pointers)
 
using message_stringifier_ptr_t = std::unique_ptr< message_stringifier_t >
 smart pointer for message stringifier
 
typedef message_ptr_t() error_producer_t(const address_ptr_t &reply_to, message_base_t &msg, const extended_error_ptr_t &ec) noexcept
 free function type, which produces error response to the original request
 
using subscription_info_ptr_t = intrusive_ptr_t< subscription_info_t >
 intrusive pointer for subscription_info_t
 
using system_context_ptr_t = intrusive_ptr_t< system_context_t >
 intrusive pointer for system context
 
using timer_handler_ptr_t = std::unique_ptr< timer_handler_base_t >
 alias for timer smart pointer
 

Enumerations

enum class  error_code_t {
  success = 0 , cancelled , request_timeout , supervisor_defined ,
  already_registered , actor_misconfigured , actor_not_linkable , already_linked ,
  failure_escalation , registration_failed , discovery_failed , unknown_service
}
 fatal error codes in rotor
 
enum class  shutdown_code_t {
  normal = 0 , supervisor_shutdown , child_down , child_init_failed ,
  init_failed , unlink_requested
}
 actor shutdown reasons as error code
 
enum class  supervisor_policy_t { shutdown_self = 1 , shutdown_failed }
 how to behave on child actor initialization failures More...
 
enum class  restart_policy_t {
  always , never , ask_actor , normal_only ,
  fail_only
}
 spawner's actor restart policy More...
 
enum class  state_t {
  UNKNOWN , NEW , INITIALIZING , INITIALIZED ,
  OPERATIONAL , SHUTTING_DOWN , SHUT_DOWN
}
 state of actor in rotor
 
enum class  owner_tag_t { ANONYMOUS , PLUGIN , SUPERVISOR , FOREIGN }
 who owns the subscription point More...
 

Functions

template<>
auto & actor_base_t::access< asio::to::supervisor > () noexcept
 access to supervisor
 
ROTOR_API const details::error_code_categoryerror_code_category ()
 returns error code category for rotor error codes
 
ROTOR_API const details::shutdown_code_categoryshutdown_code_category ()
 returns error code category for rotor shutdown codes
 
ROTOR_API std::error_code make_error_code (const error_code_t e)
 makes std::error_code from rotor error code enumerations
 
ROTOR_API std::error_code make_error_code (const shutdown_code_t e)
 makes std::error_code from rotor shutdown code enumerations
 
ROTOR_API extended_error_ptr_t make_error (const std::string &context_, const std::error_code &ec_, const extended_error_ptr_t &next_={}, const message_ptr_t &request_={}) noexcept
 constructs smart pointer to the extened error
 
template<typename M , typename F >
constexpr lambda_holder_t< M, F > lambda (F &&fn)
 helper function for lambda holder constructing
 
template<>
auto & plugin::plugin_base_t::access< details::to::actor > () noexcept
 access to actor via plugin
 
template<typename M , typename... Args>
auto make_message (const address_ptr_t &addr, Args &&...args) -> message_ptr_t
 constructs message by constructing it's payload; intrusive pointer for the message is returned
 
template<typename M , typename... Args>
auto make_routed_message (const address_ptr_t &addr, const address_ptr_t &route_addr, Args &&...args) -> message_ptr_t
 constructs message by constructing it's payload; after delivery to destination address (to all subscribers), the message is routed the specified route_addr; intrusive pointer for the message is returned
 
template<typename Handler >
handler_ptr_t wrap_handler (actor_base_t &actor, Handler &&handler)
 wraps handler (pointer to member function) and actor address into intrusive pointer
 

Detailed Description

Basic namespace for all rotor functionalities.

Typedef Documentation

◆ factory_t

using rotor::factory_t = typedef std::function<actor_ptr_t(supervisor_t &, const address_ptr_t &)>

factory which allows to create actors lazily or on demand

The spawner address MUST be set to the newly created actor to allow further spawning.

This function might throw an exception, which is however ignored, but spawner might attempt to create new actor instance.

Enumeration Type Documentation

◆ owner_tag_t

enum class rotor::owner_tag_t
strong

who owns the subscription point

  • plugin (i.e. subscription was invoked from plugin)
  • supervisor (temporally instantiated subscription for request/response handling)
  • foreign (when it is subscribed for foreign address)
  • anonymous (subscription point was created from actor)

◆ restart_policy_t

enum class rotor::restart_policy_t
strong

spawner's actor restart policy

Enumerator
always 

always restart actor

never 

never restart actor

ask_actor 

ask terminated actor whether a new instance should be spawned should_restart() method is used

normal_only 

restart actor only when it terminated normally (without error)

fail_only 

restart actor only when it terminated abnormally (with error)

◆ supervisor_policy_t

enum class rotor::supervisor_policy_t
strong

how to behave on child actor initialization failures

Enumerator
shutdown_self 

shutdown supervisor (and all its actors) if a child-actor fails during supervisor initialization phase

shutdown_failed 

shutdown a failed child and continue initialization

Function Documentation

◆ make_routed_message()

template<typename M , typename... Args>
auto rotor::make_routed_message ( const address_ptr_t addr,
const address_ptr_t route_addr,
Args &&...  args 
) -> message_ptr_t

constructs message by constructing it's payload; after delivery to destination address (to all subscribers), the message is routed the specified route_addr; intrusive pointer for the message is returned

The function is used for "synchronized" message post-processing, i.e. once a message has been delivered and processed by all recipients (can be zero), then it is routed to the specifed address to do cleanup.

Example:

  1. an db-actor and opens transaction and reads data (i.e. as std::string_views, owned by db)
  2. actors sends broadcast message to all interesting parties to deserialized data
  3. after the step 2 is finished the db-actor closes transaction and releases acquired resources.

The make_routed_message is needed to perform recipient-agnostic 3rd step.

The alternative is to create a copy (snapshot) of data (i.e. std::string instead of std::string_view), but that seems redundant.