载入中...
搜索中...
未找到
StepKindRegistry.cpp
浏览该文件的文档.
13 const bool accepted = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') ||
55 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "step type must be a non-empty bare word", "type", {}, "dnut.step-registry"));
58 eve::Diagnostic::error(eve::DiagnosticCode::AlreadyExists, "step type '" + descriptor.type + "' is already registered", descriptor.type, {}, "dnut.step-registry"));
62 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "step '" + descriptor.type + "' declares an invalid field name", field.name, {}, "dnut.step-registry"));
73 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "step type '" + key + "' must be declared before a handler is bound", key, {}, "dnut.step-registry"));
76 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "step handler for '" + key + "' must be callable", key, {}, "dnut.step-registry"));
87bool StepKindRegistry::contains(std::string_view type) const { return descriptors_.contains(type); }
101bool StepKindRegistry::hasHandler(std::string_view type) const { return handlers_.contains(type); }
107 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "node '" + node.id + "' uses unregistered step type '" + node.type + "'", "nodes." + node.id + ".type", {}, "dnut.step-registry"));
110 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "node '" + node.id + "' payload must be an object", "nodes." + node.id + ".payload", {}, "dnut.step-registry"));
117 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "step '" + node.type + "' on node '" + node.id + "' requires field '" +
123 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "step '" + node.type + "' field '" + field.name + "' must be " +
124 fieldTypeName(field.type), "nodes." + node.id + ".payload." + field.name, {}, "dnut.step-registry"));
137 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "step '" + node.type + "' does not accept field '" + key + "'", "nodes." + node.id + ".payload." + key, {}, "dnut.step-registry"));
142 eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation, "step '" + node.type + "' is instant but has no handler bound", "nodes." + node.id + ".type", {}, "dnut.step-registry"));
150StepOutcome StepKindRegistry::dispatch(const SequenceNode& node, const StepContext& context) const {
Extensible step vocabulary, payload schema and dispatch.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:124
StepOutcome dispatch(const SequenceNode &node, const StepContext &context) const
Route one already validated node to its handler.
Definition StepKindRegistry.cpp:150
eve::Result< void > registerHandler(std::string_view type, StepHandler handler)
Bind an owning handler to an already declared step type.
Definition StepKindRegistry.cpp:69
eve::Result< void > registerStep(StepKindDescriptor descriptor)
Declare one step type.
Definition StepKindRegistry.cpp:52
eve::Result< void > validate(const SequenceNode &node) const
Validate one node against its declared payload schema.
Definition StepKindRegistry.cpp:103
bool contains(std::string_view type) const
Return whether type is declared.
Definition StepKindRegistry.cpp:87
bool hasHandler(std::string_view type) const
Return whether a handler is bound for type.
Definition StepKindRegistry.cpp:101
const StepKindDescriptor * descriptor(std::string_view type) const
Return the declared contract for type.
Definition StepKindRegistry.cpp:89
void unregisterStep(std::string_view type)
Remove a step type and its handler; absent types are a no-op.
Definition StepKindRegistry.cpp:81
std::vector< StepKindDescriptor > descriptors() const
Return every declared contract in lexical type order.
Definition StepKindRegistry.cpp:94
Definition ConversationDialect.cpp:13
@ String
@ Boolean
@ Integer
@ Number
std::function< StepOutcome(const SequenceNode &, const StepContext &)> StepHandler
Consumer-owned handler for one registered step type.
Definition StepKindRegistry.h:96
StepShape
Declares whether a step completes inside its call or suspends the runtime.
Definition StepKindRegistry.h:20
@ Instant
The step completes synchronously; Completed continues at next.
@ Blocked
@ Failed
const char * stepShapeName(StepShape shape) noexcept
Return the stable lowercase spelling of a step shape.
Definition StepKindRegistry.cpp:44
@ InvalidArgument
@ NotFound
@ PreconditionViolation
@ AlreadyExists
Borrowed execution context handed to one step handler.
Definition StepKindRegistry.h:79
Owning authoring/runtime contract for one step type.
Definition StepKindRegistry.h:45