A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
a11::actions::ActionRegistry Class Reference

A thread-safe catalogue mapping action names to schema and handler. More...

#include <cpp/a11/actions/registry.h>

Inheritance diagram for a11::actions::ActionRegistry:
[legend]

Public Member Functions

absl::Status Register (std::string action_name, ActionSchema schema, ActionHandler handler={})
 Registers an action under action_name.
 
absl::Status RegisterSync (std::string action_name, ActionSchema schema, SyncActionHandler handler)
 Registers an action with a synchronous handler.
 
absl::Status Unregister (std::string_view action_name)
 Removes the registration for action_name.
 
bool IsRegistered (std::string_view action_name) const
 Whether action_name is registered.
 
absl::StatusOr< ActionSchemaGetSchema (std::string_view action_name) const
 Returns the schema for action_name, or NotFound.
 
absl::StatusOr< ActionHandlerGetHandler (std::string_view action_name) const
 Returns the handler for action_name, or NotFound.
 
absl::StatusOr< std::shared_ptr< Action > > MakeAction (std::string_view action_name, std::string action_id={}, std::shared_ptr< nodes::NodeMap > node_map=nullptr, std::shared_ptr< net::WireStream > stream=nullptr, std::shared_ptr< service::Session > session=nullptr)
 Builds a runnable Action for a registered action.
 
absl::StatusOr< data::ActionMessageMakeActionMessage (std::string_view action_name, std::string action_id={})
 Builds the wire a11::data::ActionMessage for a registered action.
 
std::vector< std::string > ListRegisteredActions () const
 Returns the names of all registered actions.
 
std::shared_ptr< ActionRegistryCopy (bool clear_autofills=true) const
 Returns a copy of this registry.
 

Detailed Description

A thread-safe catalogue mapping action names to schema and handler.

Register an action once, then build ready-to-run a11::actions::Action instances from its name. The same registry can back many actions and is shared with a11::service::Session so incoming calls can be dispatched to the registered handler.

Member Function Documentation

◆ Copy()

std::shared_ptr< ActionRegistry > a11::actions::ActionRegistry::Copy ( bool  clear_autofills = true) const

Returns a copy of this registry.

Parameters
clear_autofillsWhen true, drop port autofill defaults in the copy.

◆ GetHandler()

absl::StatusOr< ActionHandler > a11::actions::ActionRegistry::GetHandler ( std::string_view  action_name) const

Returns the handler for action_name, or NotFound.

◆ GetSchema()

absl::StatusOr< ActionSchema > a11::actions::ActionRegistry::GetSchema ( std::string_view  action_name) const

Returns the schema for action_name, or NotFound.

◆ IsRegistered()

bool a11::actions::ActionRegistry::IsRegistered ( std::string_view  action_name) const

Whether action_name is registered.

◆ ListRegisteredActions()

std::vector< std::string > a11::actions::ActionRegistry::ListRegisteredActions ( ) const

Returns the names of all registered actions.

◆ MakeAction()

absl::StatusOr< std::shared_ptr< Action > > a11::actions::ActionRegistry::MakeAction ( std::string_view  action_name,
std::string  action_id = {},
std::shared_ptr< nodes::NodeMap node_map = nullptr,
std::shared_ptr< net::WireStream stream = nullptr,
std::shared_ptr< service::Session session = nullptr 
)

Builds a runnable Action for a registered action.

Parameters
action_nameName of the registered action.
action_idInstance id; a fresh one is generated when empty.
node_mapNode map backing the action's ports.
streamOptional wire stream; when supplied the action can be dispatched remotely with Action::Call.
sessionOptional owning session for tracking and dispatch.
Returns
The constructed action, or NotFound when the name is unknown.

◆ MakeActionMessage()

absl::StatusOr< data::ActionMessage > a11::actions::ActionRegistry::MakeActionMessage ( std::string_view  action_name,
std::string  action_id = {} 
)

Builds the wire a11::data::ActionMessage for a registered action.

Parameters
action_nameName of the registered action.
action_idInstance id; a fresh one is generated when empty.

◆ Register()

absl::Status a11::actions::ActionRegistry::Register ( std::string  action_name,
ActionSchema  schema,
ActionHandler  handler = {} 
)

Registers an action under action_name.

Parameters
action_nameName to register (must be unique).
schemaSchema describing the action's interface.
handlerAsynchronous handler; may be empty to register schema only.
Returns
OK, or AlreadyExists when the name is taken.

◆ RegisterSync()

absl::Status a11::actions::ActionRegistry::RegisterSync ( std::string  action_name,
ActionSchema  schema,
SyncActionHandler  handler 
)

Registers an action with a synchronous handler.

The handler is wrapped so it runs as an asynchronous action handler.

◆ Unregister()

absl::Status a11::actions::ActionRegistry::Unregister ( std::string_view  action_name)

Removes the registration for action_name.


The documentation for this class was generated from the following files: