|
A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
|
A thread-safe catalogue mapping action names to schema and handler. More...
#include <cpp/a11/actions/registry.h>
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< ActionSchema > | GetSchema (std::string_view action_name) const |
Returns the schema for action_name, or NotFound. | |
| absl::StatusOr< ActionHandler > | GetHandler (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::ActionMessage > | MakeActionMessage (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< ActionRegistry > | Copy (bool clear_autofills=true) const |
| Returns a copy of this registry. | |
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.
| std::shared_ptr< ActionRegistry > a11::actions::ActionRegistry::Copy | ( | bool | clear_autofills = true | ) | const |
Returns a copy of this registry.
| clear_autofills | When true, drop port autofill defaults in the copy. |
| absl::StatusOr< ActionHandler > a11::actions::ActionRegistry::GetHandler | ( | std::string_view | action_name | ) | const |
Returns the handler for action_name, or NotFound.
| absl::StatusOr< ActionSchema > a11::actions::ActionRegistry::GetSchema | ( | std::string_view | action_name | ) | const |
Returns the schema for action_name, or NotFound.
| bool a11::actions::ActionRegistry::IsRegistered | ( | std::string_view | action_name | ) | const |
Whether action_name is registered.
| std::vector< std::string > a11::actions::ActionRegistry::ListRegisteredActions | ( | ) | const |
Returns the names of all registered actions.
| 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.
| action_name | Name of the registered action. |
| action_id | Instance id; a fresh one is generated when empty. |
| node_map | Node map backing the action's ports. |
| stream | Optional wire stream; when supplied the action can be dispatched remotely with Action::Call. |
| session | Optional owning session for tracking and dispatch. |
| 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.
| action_name | Name of the registered action. |
| action_id | Instance id; a fresh one is generated when empty. |
| absl::Status a11::actions::ActionRegistry::Register | ( | std::string | action_name, |
| ActionSchema | schema, | ||
| ActionHandler | handler = {} |
||
| ) |
Registers an action under action_name.
| action_name | Name to register (must be unique). |
| schema | Schema describing the action's interface. |
| handler | Asynchronous handler; may be empty to register schema only. |
| 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.
| absl::Status a11::actions::ActionRegistry::Unregister | ( | std::string_view | action_name | ) |
Removes the registration for action_name.