载入中...
搜索中...
未找到
StateAccessAdapter.cpp
浏览该文件的文档.
16eve::Result<eve::MutationReceipt> failure(eve::DiagnosticCode code, std::string message, std::string path = {}) {
21eve::Result<eve::Value> readJsonValue(const Store& store, std::string_view subject, std::string_view key) {
46std::optional<eve::Value> StatePatchStateAdapter::value(std::string_view subject, std::string_view key) const {
52std::optional<bool> StatePatchStateAdapter::hasTag(std::string_view subject, std::string_view tag) const {
63std::optional<eve::Value> StatePatchStateAdapter::state(std::string_view subject, std::string_view key) const {
67eve::Result<eve::MutationReceipt> StatePatchStateAdapter::apply(std::span<const eve::StateMutation> mutations,
70 return failure(eve::DiagnosticCode::InvalidArgument, "persistent dialogue mutations require a transaction id",
80 return failure(eve::DiagnosticCode::StaleHandle, "StatePatch patch batch became stale during allocation",
92 return failure(eve::DiagnosticCode::Unsupported, "StatePatch adapter accepts persistent mutations only",
95 return failure(eve::DiagnosticCode::InvalidArgument, "persistent mutation requires subject and key", path);
139 return failure(eve::DiagnosticCode::InvalidArgument, "AddNumber requires a finite numeric value",
152 return failure(eve::DiagnosticCode::SerializationError, "AddNumber result cannot be serialized",
159 if (!appended) return failure(eve::DiagnosticCode::Failed, "StatePatch rejected a mutation", path);
162 eve::transaction::TransactionContext transaction(context.transactionId, context.correlationId, context.causationId);
172 eve::Status::success(result.changedCount == 0 ? eve::StatusCode::NoOp : eve::StatusCode::Applied));
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
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:537
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
Result< std::string > toJson() const
Serialize this value as deterministic compact JSON.
Definition Value.cpp:67
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
bool asBool() const
Return the boolean payload; the caller must have checked the kind.
Definition Value.cpp:81
std::optional< eve::Value > state(std::string_view subject, std::string_view key) const override
Query a persistent/world state value.
Definition StateAccessAdapter.cpp:63
std::optional< eve::Value > value(std::string_view subject, std::string_view key) const override
Query a generic world value.
Definition StateAccessAdapter.cpp:46
std::optional< bool > hasTag(std::string_view subject, std::string_view tag) const override
Query exact tag membership.
Definition StateAccessAdapter.cpp:52
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:67
Transaction participant that atomically applies one StatePatch batch.
Definition StatePatch.h:230
Deterministic subject-and-key JSON value store with atomic patching.
Definition StatePatch.h:119
bool has(const std::string &subject, const std::string &key) const
Returns whether a subject and key currently exist.
Definition StatePatch.cpp:291
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:296
eve::Result< void > releaseBatch(PatchBatchHandleRef reference)
Releases a store-owned patch batch.
Definition StatePatch.cpp:203
eve::script::Borrowed< PatchBatch > resolveBatch(PatchBatchHandleRef reference) noexcept
Resolves a live batch as a non-owning observation.
Definition StatePatch.cpp:199
eve::Result< PatchBatchHandleRef > newBatch()
Allocates a store-owned empty patch batch and returns its handle.
Definition StatePatch.cpp:197
Coordinates participant lifecycles with deterministic ordering.
Definition Transaction.h:178
Result< TransactionReceipt > execute(const TransactionContext &context, std::span< ITransactionParticipant * > participants) const
Atomically execute borrowed participants for one context.
Definition Transaction.cpp:176
Immutable context shared by every participant of one transaction.
Definition Transaction.h:30
Definition StateAccessAdapter.cpp:13
@ InvalidArgument
@ NotFound
@ SerializationError
@ Unsupported
@ Failed
@ StaleHandle
@ NoOp
@ Applied
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
Summary of the most recent batch commit attempt.
Definition StatePatch.h:66