载入中...
搜索中...
未找到
StateAccessAdapter.cpp
浏览该文件的文档.
17eve::Result<eve::MutationReceipt> failure(eve::DiagnosticCode code, std::string message, std::string path = {}) {
22eve::Result<eve::Value> readJsonValue(const Store& store, std::string_view subject, std::string_view key) {
42std::optional<eve::Value> StatePatchStateAdapter::value(std::string_view subject, std::string_view key) const {
48std::optional<bool> StatePatchStateAdapter::hasTag(std::string_view subject, std::string_view tag) const {
59std::optional<eve::Value> StatePatchStateAdapter::state(std::string_view subject, std::string_view key) const {
63eve::Result<eve::MutationReceipt> StatePatchStateAdapter::apply(std::span<const eve::StateMutation> mutations,
66 return failure(eve::DiagnosticCode::InvalidArgument, "persistent dialogue mutations require a transaction id",
76 return failure(eve::DiagnosticCode::StaleHandle, "StatePatch patch batch became stale during allocation",
88 return failure(eve::DiagnosticCode::Unsupported, "StatePatch adapter accepts persistent mutations only",
91 return failure(eve::DiagnosticCode::InvalidArgument, "persistent mutation requires subject and key", path);
135 return failure(eve::DiagnosticCode::InvalidArgument, "AddNumber requires a finite numeric value",
148 return failure(eve::DiagnosticCode::SerializationError, "AddNumber result cannot be serialized",
155 if (!appended) return failure(eve::DiagnosticCode::Failed, "StatePatch rejected a mutation", path);
158 eve::transaction::TransactionContext transaction(context.transactionId, context.correlationId, context.causationId);
168 eve::Status::success(summary.changedCount == 0 ? eve::StatusCode::NoOp : eve::StatusCode::Applied));
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:571
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
bool asBool() const
Return the boolean payload; the caller must have checked the kind.
Definition Value.cpp:201
std::optional< eve::Value > state(std::string_view subject, std::string_view key) const override
Query a persistent/world state value.
Definition StateAccessAdapter.cpp:59
std::optional< eve::Value > value(std::string_view subject, std::string_view key) const override
Query a generic world value.
Definition StateAccessAdapter.cpp:42
std::optional< bool > hasTag(std::string_view subject, std::string_view tag) const override
Query exact tag membership.
Definition StateAccessAdapter.cpp:48
eve::Result< eve::MutationReceipt > apply(std::span< const eve::StateMutation > mutations, const eve::MutationContext &context) override
Apply a complete mutation set atomically.
Definition StateAccessAdapter.cpp:63
Transaction participant that atomically applies one StatePatch batch.
Definition StatePatch.h:259
Deterministic subject-and-key JSON value store with atomic patching.
Definition StatePatch.h:140
bool has(const std::string &subject, const std::string &key) const
Returns whether a subject and key currently exist.
Definition StatePatch.cpp:306
std::string get(const std::string &subject, const std::string &key) const
Returns canonical JSON for a value, or an empty string when absent.
Definition StatePatch.cpp:311
eve::Result< void > releaseBatch(PatchBatchHandleRef reference)
Releases a store-owned patch batch.
Definition StatePatch.cpp:182
eve::script::Borrowed< PatchBatch > resolveBatch(PatchBatchHandleRef reference) noexcept
Resolves a live batch as a non-owning observation.
Definition StatePatch.cpp:178
eve::Result< PatchBatchHandleRef > newBatch()
Allocates a store-owned empty patch batch and returns its handle.
Definition StatePatch.cpp:176
Coordinates participant lifecycles with deterministic ordering.
Definition Transaction.h:179
Result< TransactionReceipt > execute(const TransactionContext &context, std::span< ITransactionParticipant * > participants) const
Execute borrowed participants with rollback and compensation.
Definition Transaction.cpp:156
Immutable context shared by every participant of one transaction.
Definition Transaction.h:31
Definition StateAccessAdapter.cpp:14
@ InvalidArgument
@ NotFound
@ SerializationError
@ Unsupported
@ Failed
@ StaleHandle
@ NoOp
@ Applied
Result< double > readNumericDoubleValue(const Value &value)
Read an Int64 or Double as a double without imposing a finite-value policy.
Definition Value.cpp:74
StatePatch implementation of the common world-state contracts.
Correlation metadata shared by a mutation transaction.
Definition StateAccess.h:57
Observable result of an all-or-nothing mutation request.
Definition StateAccess.h:64
Compatibility summary of the most recent batch commit attempt. @compatibility Prefer Store::commit → ...
Definition StatePatch.h:87