CCF
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions
ccf::endpoints Namespace Reference

Namespaces

namespace  Tables
 

Classes

struct  CommandEndpointContext
 
struct  DispatchFailedEvent
 
struct  Endpoint
 
struct  EndpointContext
 
struct  EndpointDefinition
 
struct  EndpointKey
 
struct  EndpointProperties
 
class  EndpointRegistry
 
struct  InterpreterReusePolicy
 
struct  PathTemplatedEndpoint
 
struct  PathTemplateSpec
 
struct  ReadOnlyEndpointContext
 
struct  RequestCompletedEvent
 

Typedefs

using URI = std::string
 
using EndpointDefinitionPtr = std::shared_ptr< const EndpointDefinition >
 
using EndpointsMap = ccf::ServiceMap< EndpointKey, EndpointProperties >
 
using EndpointPtr = std::shared_ptr< const Endpoint >
 
using CommandEndpointFunction = std::function< void(CommandEndpointContext &args)>
 
using EndpointFunction = std::function< void(EndpointContext &args)>
 
using LocallyCommittedEndpointFunction = std::function< void(CommandEndpointContext &ctx, const ccf::TxID &txid)>
 
using ReadOnlyEndpointFunction = std::function< void(ReadOnlyEndpointContext &args)>
 

Enumerations

enum class  ForwardingRequired { Sometimes , Always , Never }
 
enum class  RedirectionStrategy { None , ToPrimary , ToBackup }
 
enum class  Mode { ReadWrite , ReadOnly , Historical }
 
enum  QueryParamPresence { RequiredParameter , OptionalParameter }
 

Functions

 DECLARE_JSON_TYPE (EndpointKey)
 
 DECLARE_JSON_REQUIRED_FIELDS (EndpointKey, uri_path, verb)
 
 DECLARE_JSON_ENUM (ForwardingRequired, {{ForwardingRequired::Sometimes, "sometimes"}, {ForwardingRequired::Always, "always"}, {ForwardingRequired::Never, "never"}})
 
 DECLARE_JSON_ENUM (RedirectionStrategy, {{RedirectionStrategy::None, "none"}, {RedirectionStrategy::ToPrimary, "to_primary"}, {RedirectionStrategy::ToBackup, "to_backup"}})
 
 DECLARE_JSON_ENUM (Mode, {{Mode::ReadWrite, "readwrite"}, {Mode::ReadOnly, "readonly"}, {Mode::Historical, "historical"}})
 
void to_json (nlohmann::json &j, const InterpreterReusePolicy &grp)
 
void from_json (const nlohmann::json &j, InterpreterReusePolicy &grp)
 
std::string schema_name (const InterpreterReusePolicy *)
 
void fill_json_schema (nlohmann::json &schema, const InterpreterReusePolicy *)
 
 DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS (EndpointProperties)
 
 DECLARE_JSON_REQUIRED_FIELDS (EndpointProperties, forwarding_required, authn_policies)
 
 DECLARE_JSON_OPTIONAL_FIELDS (EndpointProperties, openapi, openapi_hidden, mode, js_module, js_function, interpreter_reuse, redirection_strategy)
 
void default_locally_committed_func (CommandEndpointContext &ctx, const TxID &tx_id)
 
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)
 
std::string camel_case (std::string s, bool camel_first=true, const std::string &separator_regex="[^[:alnum:]]")
 

Detailed Description

Defines the different types of context an Endpoint can operate over, and the types of handler functions which process them.

Typedef Documentation

◆ CommandEndpointFunction

using ccf::endpoints::CommandEndpointFunction = typedef std::function<void(CommandEndpointContext& args)>

◆ EndpointDefinitionPtr

using ccf::endpoints::EndpointDefinitionPtr = typedef std::shared_ptr<const EndpointDefinition>

◆ EndpointFunction

using ccf::endpoints::EndpointFunction = typedef std::function<void(EndpointContext& args)>

◆ EndpointPtr

using ccf::endpoints::EndpointPtr = typedef std::shared_ptr<const Endpoint>

◆ EndpointsMap

◆ LocallyCommittedEndpointFunction

using ccf::endpoints::LocallyCommittedEndpointFunction = typedef std::function<void(CommandEndpointContext& ctx, const ccf::TxID& txid)>

◆ ReadOnlyEndpointFunction

using ccf::endpoints::ReadOnlyEndpointFunction = typedef std::function<void(ReadOnlyEndpointContext& args)>

◆ URI

using ccf::endpoints::URI = typedef std::string

Enumeration Type Documentation

◆ ForwardingRequired

Enumerator
Sometimes 

ForwardingRequired::Sometimes is the default value, and should be used for most read-only operations. If this request is made to a backup node, it may be forwarded to the primary node for execution to maintain session consistency. Specifically, if this request is sent as part of a session which was already forwarded, then it will also be forwarded.

Always 

ForwardingRequired::Always should be used for operations which may produce writes. If this request is made to a backup node, it will be forwarded to the primary node for execution.

Never 

ForwardingRequired::Never should be used for operations which want to read node-local state rather than the latest replicated state, such as historical queries or local consensus information. This call will never be forwarded, and is always executed on the receiving node, potentiall breaking session consistency. If this attempts to write on a backup, this will fail.

◆ Mode

enum class ccf::endpoints::Mode
strong
Enumerator
ReadWrite 
ReadOnly 
Historical 

◆ QueryParamPresence

Enumerator
RequiredParameter 
OptionalParameter 

◆ RedirectionStrategy

Enumerator
None 

This operation does not need to be redirected, and can be executed on the receiving node. Most read-only operations can be executed on any node, so should be marked as None.

ToPrimary 

This operation must be executed on a primary. If the current node is not a primary, it should attempt to redirect to the primary, or else return an error. Any write operations must be executed on a primary, so should be marked as ToPrimary.

ToBackup 

This operation should be executed on a backup. If the current node is not a backup, it should attempt to redirect to a backup, or else return an error. Only read operations can be marked as ToBackup.

Function Documentation

◆ camel_case()

std::string ccf::endpoints::camel_case ( std::string  s,
bool  camel_first = true,
const std::string &  separator_regex = "[^[:alnum:]]" 
)

◆ DECLARE_JSON_ENUM() [1/3]

ccf::endpoints::DECLARE_JSON_ENUM ( ForwardingRequired  ,
{{ForwardingRequired::Sometimes, "sometimes"}, {ForwardingRequired::Always, "always"}, {ForwardingRequired::Never, "never"}}   
)

◆ DECLARE_JSON_ENUM() [2/3]

ccf::endpoints::DECLARE_JSON_ENUM ( Mode  ,
{{Mode::ReadWrite, "readwrite"}, {Mode::ReadOnly, "readonly"}, {Mode::Historical, "historical"}}   
)

◆ DECLARE_JSON_ENUM() [3/3]

ccf::endpoints::DECLARE_JSON_ENUM ( RedirectionStrategy  ,
{{RedirectionStrategy::None, "none"}, {RedirectionStrategy::ToPrimary, "to_primary"}, {RedirectionStrategy::ToBackup, "to_backup"}}   
)

◆ DECLARE_JSON_OPTIONAL_FIELDS()

ccf::endpoints::DECLARE_JSON_OPTIONAL_FIELDS ( EndpointProperties  ,
openapi  ,
openapi_hidden  ,
mode  ,
js_module  ,
js_function  ,
interpreter_reuse  ,
redirection_strategy   
)

◆ DECLARE_JSON_REQUIRED_FIELDS() [1/2]

ccf::endpoints::DECLARE_JSON_REQUIRED_FIELDS ( EndpointKey  ,
uri_path  ,
verb   
)

◆ DECLARE_JSON_REQUIRED_FIELDS() [2/2]

ccf::endpoints::DECLARE_JSON_REQUIRED_FIELDS ( EndpointProperties  ,
forwarding_required  ,
authn_policies   
)

◆ DECLARE_JSON_TYPE()

ccf::endpoints::DECLARE_JSON_TYPE ( EndpointKey  )

◆ DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS()

ccf::endpoints::DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS ( EndpointProperties  )

◆ default_locally_committed_func()

void ccf::endpoints::default_locally_committed_func ( CommandEndpointContext ctx,
const TxID tx_id 
)

◆ fill_json_schema()

void ccf::endpoints::fill_json_schema ( nlohmann::json &  schema,
const InterpreterReusePolicy policy 
)

◆ from_json()

void ccf::endpoints::from_json ( const nlohmann::json &  j,
InterpreterReusePolicy grp 
)

◆ get_path_param() [1/2]

template<>
bool ccf::endpoints::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::get_path_param ( const ccf::PathParams params,
const std::string &  param_name,
T &  value,
std::string &  error 
)
inline

◆ schema_name()

std::string ccf::endpoints::schema_name ( const InterpreterReusePolicy policy)

◆ to_json()

void ccf::endpoints::to_json ( nlohmann::json &  j,
const InterpreterReusePolicy grp 
)