CCF
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
ccf::endpoints::EndpointRegistry Class Reference

#include <endpoint_registry.h>

Inherits ccf::endpoints::Endpoint::Installer.

Inherited by ccf::BaseEndpointRegistry.

Classes

struct  OpenApiInfo
 

Public Types

enum  ReadWrite { Read , Write }
 

Public Member Functions

template<typename T >
bool get_path_param (const ccf::PathParams &params, const std::string &param_name, T &value, std::string &error)
 
template<>
bool get_path_param (const ccf::PathParams &params, const std::string &param_name, std::string &value, std::string &error)
 
 EndpointRegistry (const std::string &method_prefix_)
 
virtual ~EndpointRegistry ()
 
virtual Endpoint make_endpoint (const std::string &method, RESTVerb verb, const EndpointFunction &f, const AuthnPolicies &ap)
 
virtual Endpoint make_read_only_endpoint (const std::string &method, RESTVerb verb, const ReadOnlyEndpointFunction &f, const AuthnPolicies &ap)
 
virtual Endpoint make_endpoint_with_local_commit_handler (const std::string &method, RESTVerb verb, const EndpointFunction &f, const LocallyCommittedEndpointFunction &l, const AuthnPolicies &ap)
 
virtual Endpoint make_read_only_endpoint_with_local_commit_handler (const std::string &method, RESTVerb verb, const ReadOnlyEndpointFunction &f, const LocallyCommittedEndpointFunction &l, const AuthnPolicies &ap)
 
virtual Endpoint make_command_endpoint (const std::string &method, RESTVerb verb, const CommandEndpointFunction &f, const AuthnPolicies &ap)
 
void install (Endpoint &endpoint) override
 
void set_default (EndpointFunction f, const AuthnPolicies &ap)
 
virtual void build_api (nlohmann::json &document, ccf::kv::ReadOnlyTx &)
 
virtual void init_handlers ()
 
virtual EndpointDefinitionPtr find_endpoint (ccf::kv::Tx &, ccf::RpcContext &rpc_ctx)
 
virtual void execute_endpoint (EndpointDefinitionPtr e, EndpointContext &ctx)
 
virtual void execute_endpoint_locally_committed (EndpointDefinitionPtr e, CommandEndpointContext &ctx, const TxID &tx_id)
 
virtual std::set< RESTVerbget_allowed_verbs (ccf::kv::Tx &, const ccf::RpcContext &rpc_ctx)
 
virtual bool request_needs_root (const ccf::RpcContext &rpc_ctx)
 
virtual void report_ambiguous_templated_path (const std::string &path, const std::vector< EndpointDefinitionPtr > &matches)
 
virtual void tick (std::chrono::milliseconds)
 
void set_consensus (ccf::kv::Consensus *c)
 
void set_history (ccf::kv::TxHistory *h)
 
virtual void handle_event_request_completed (const ccf::endpoints::RequestCompletedEvent &event)
 
virtual void handle_event_dispatch_failed (const ccf::endpoints::DispatchFailedEvent &event)
 
virtual bool apply_uncommitted_tx_backpressure () const
 

Public Attributes

const std::string method_prefix
 
struct ccf::endpoints::EndpointRegistry::OpenApiInfo openapi_info
 

Protected Attributes

EndpointPtr default_endpoint
 
std::map< std::string, std::map< RESTVerb, EndpointPtr > > fully_qualified_endpoints
 
std::map< std::string, std::map< RESTVerb, std::shared_ptr< PathTemplatedEndpoint > > > templated_endpoints
 
ccf::kv::Consensusconsensus = nullptr
 
ccf::kv::TxHistoryhistory = nullptr
 

Detailed Description

The EndpointRegistry records the user-defined endpoints for a given CCF application.

This is the abstract base for several more complete registrys. For a versioned API wrapping access to common CCF properties, see BaseEndpointRegistry. For implementation of several common endpoints see CommonEndpointRegistry.

Member Enumeration Documentation

◆ ReadWrite

Enumerator
Read 
Write 

Constructor & Destructor Documentation

◆ EndpointRegistry()

ccf::endpoints::EndpointRegistry::EndpointRegistry ( const std::string &  method_prefix_)
inline

◆ ~EndpointRegistry()

virtual ccf::endpoints::EndpointRegistry::~EndpointRegistry ( )
inlinevirtual

Member Function Documentation

◆ apply_uncommitted_tx_backpressure()

virtual bool ccf::endpoints::EndpointRegistry::apply_uncommitted_tx_backpressure ( ) const
inlinevirtual

Reimplemented in ccf::NodeEndpoints.

◆ build_api()

void ccf::endpoints::EndpointRegistry::build_api ( nlohmann::json &  document,
ccf::kv::ReadOnlyTx tx 
)
virtual

Populate document with all supported methods

This is virtual since derived classes may do their own dispatch internally, so must be able to populate the document with the supported endpoints however it defines them.

Reimplemented in ccf::js::BaseDynamicJSEndpointRegistry.

◆ execute_endpoint()

void ccf::endpoints::EndpointRegistry::execute_endpoint ( EndpointDefinitionPtr  e,
EndpointContext ctx 
)
virtual

◆ execute_endpoint_locally_committed()

void ccf::endpoints::EndpointRegistry::execute_endpoint_locally_committed ( EndpointDefinitionPtr  e,
CommandEndpointContext ctx,
const TxID tx_id 
)
virtual

◆ find_endpoint()

EndpointDefinitionPtr ccf::endpoints::EndpointRegistry::find_endpoint ( ccf::kv::Tx tx,
ccf::RpcContext rpc_ctx 
)
virtual

◆ get_allowed_verbs()

std::set< RESTVerb > ccf::endpoints::EndpointRegistry::get_allowed_verbs ( ccf::kv::Tx tx,
const ccf::RpcContext rpc_ctx 
)
virtual

◆ get_path_param() [1/2]

template<>
bool ccf::endpoints::EndpointRegistry::get_path_param ( const ccf::PathParams params,
const std::string &  param_name,
std::string &  value,
std::string &  error 
)
inline

◆ get_path_param() [2/2]

template<typename T >
bool ccf::endpoints::EndpointRegistry::get_path_param ( const ccf::PathParams params,
const std::string &  param_name,
T &  value,
std::string &  error 
)
inline

◆ handle_event_dispatch_failed()

virtual void ccf::endpoints::EndpointRegistry::handle_event_dispatch_failed ( const ccf::endpoints::DispatchFailedEvent event)
inlinevirtual

◆ handle_event_request_completed()

virtual void ccf::endpoints::EndpointRegistry::handle_event_request_completed ( const ccf::endpoints::RequestCompletedEvent event)
inlinevirtual

◆ init_handlers()

void ccf::endpoints::EndpointRegistry::init_handlers ( )
virtual

◆ install()

void ccf::endpoints::EndpointRegistry::install ( Endpoint endpoint)
overridevirtual

Install the given endpoint, using its method and verb

If an implementation is already installed for this method and verb, it will be replaced.

Parameters
endpointEndpoint object describing the new resource to install

Implements ccf::endpoints::Endpoint::Installer.

◆ make_command_endpoint()

Endpoint ccf::endpoints::EndpointRegistry::make_command_endpoint ( const std::string &  method,
RESTVerb  verb,
const CommandEndpointFunction f,
const AuthnPolicies ap 
)
virtual

Create a new command endpoint.

Commands are endpoints which do not read or write from the KV. See make_endpoint().

◆ make_endpoint()

Endpoint ccf::endpoints::EndpointRegistry::make_endpoint ( const std::string &  method,
RESTVerb  verb,
const EndpointFunction f,
const AuthnPolicies ap 
)
virtual

Create a new endpoint.

Caller should set any additional properties on the returned Endpoint object, and finally call Endpoint::install() to install it.

Parameters
methodThe URI at which this endpoint will be installed
verbThe HTTP verb which this endpoint will respond to
fFunctor which will be invoked for requests to VERB /method
apPolicies which will be checked against each request before the endpoint is executed.
See also
ccf::EndpointDefinition::authn_policies
Returns
The new Endpoint for further modification

◆ make_endpoint_with_local_commit_handler()

Endpoint ccf::endpoints::EndpointRegistry::make_endpoint_with_local_commit_handler ( const std::string &  method,
RESTVerb  verb,
const EndpointFunction f,
const LocallyCommittedEndpointFunction l,
const AuthnPolicies ap 
)
virtual

Create a new endpoint with a commit handler.

Like make_endpoint but takes a functor to call once the transaction has been committed, but before consensus has completed.

◆ make_read_only_endpoint()

Endpoint ccf::endpoints::EndpointRegistry::make_read_only_endpoint ( const std::string &  method,
RESTVerb  verb,
const ReadOnlyEndpointFunction f,
const AuthnPolicies ap 
)
virtual

Create a read-only endpoint.

◆ make_read_only_endpoint_with_local_commit_handler()

Endpoint ccf::endpoints::EndpointRegistry::make_read_only_endpoint_with_local_commit_handler ( const std::string &  method,
RESTVerb  verb,
const ReadOnlyEndpointFunction f,
const LocallyCommittedEndpointFunction l,
const AuthnPolicies ap 
)
virtual

See make_read_only_endpoint and make_endpoint_with_local_commit_handler.

◆ report_ambiguous_templated_path()

void ccf::endpoints::EndpointRegistry::report_ambiguous_templated_path ( const std::string &  path,
const std::vector< EndpointDefinitionPtr > &  matches 
)
virtual

◆ request_needs_root()

bool ccf::endpoints::EndpointRegistry::request_needs_root ( const ccf::RpcContext rpc_ctx)
virtual

Reimplemented in ccf::GovEndpointRegistry.

◆ set_consensus()

void ccf::endpoints::EndpointRegistry::set_consensus ( ccf::kv::Consensus c)

◆ set_default()

void ccf::endpoints::EndpointRegistry::set_default ( EndpointFunction  f,
const AuthnPolicies ap 
)

Set a default EndpointFunction

The default EndpointFunction is only invoked if no specific EndpointFunction was found.

Parameters
fMethod implementation
apAuthentication policy

◆ set_history()

void ccf::endpoints::EndpointRegistry::set_history ( ccf::kv::TxHistory h)

◆ tick()

void ccf::endpoints::EndpointRegistry::tick ( std::chrono::milliseconds  duration)
virtual

Member Data Documentation

◆ consensus

ccf::kv::Consensus* ccf::endpoints::EndpointRegistry::consensus = nullptr
protected

◆ default_endpoint

EndpointPtr ccf::endpoints::EndpointRegistry::default_endpoint
protected

◆ fully_qualified_endpoints

std::map<std::string, std::map<RESTVerb, EndpointPtr> > ccf::endpoints::EndpointRegistry::fully_qualified_endpoints
protected

◆ history

ccf::kv::TxHistory* ccf::endpoints::EndpointRegistry::history = nullptr
protected

◆ method_prefix

const std::string ccf::endpoints::EndpointRegistry::method_prefix

◆ openapi_info

struct ccf::endpoints::EndpointRegistry::OpenApiInfo ccf::endpoints::EndpointRegistry::openapi_info

◆ templated_endpoints

std::map< std::string, std::map<RESTVerb, std::shared_ptr<PathTemplatedEndpoint> > > ccf::endpoints::EndpointRegistry::templated_endpoints
protected

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