A11 (C++ runtime)
Native C++ implementation of the A11 streaming action 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< 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.
 
void SetAuthorizationContexts (std::shared_ptr< AuthorizationContextStore > contexts)
 Require incoming application actions to resolve installed authorization.
 
absl::Status ResolveAuthorization (const std::shared_ptr< Action > &action) const
 Bind the configured authorization context before an action starts.
 

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.

Re-registering a name replaces its schema and handler. An empty handler registers the schema alone and removes the existing handler.

Parameters
action_nameName to register.
schemaSchema describing the action's interface. Its name must equal action_name.
handlerAsynchronous handler; may be empty to register schema only.
Returns
OK, or InvalidArgument when the name or schema is not valid.

◆ 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.

◆ ResolveAuthorization()

absl::Status a11::actions::ActionRegistry::ResolveAuthorization ( const std::shared_ptr< Action > &  action) const

Bind the configured authorization context before an action starts.

◆ SetAuthorizationContexts()

void a11::actions::ActionRegistry::SetAuthorizationContexts ( std::shared_ptr< AuthorizationContextStore >  contexts)

Require incoming application actions to resolve installed authorization.

◆ 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: