载入中...
搜索中...
未找到
eve::authority::Store类 参考

Generic, deterministic capability authority store. 更多...

#include <Authority.h>

Public 成员函数

 Store (eve::PersistentId instanceId={})
 Creates an authority store with an optional persistent identity.
 
eve::Result< std::string > grant (const std::string &actor, const std::string &scope, const std::string &capability, const std::string &source, int priority=0, double duration=0.0)
 Adds a grant rule and returns its stable ID.
 
eve::Result< std::string > deny (const std::string &actor, const std::string &scope, const std::string &capability, const std::string &source, int priority=0, double duration=0.0)
 Adds a deny rule and returns its stable ID.
 
eve::Result< void > revoke (const std::string &id, const std::string &reason="revoked")
 Revokes a rule by stable ID.
 
int revokeBySource (const std::string &source, const std::string &reason="source_revoked")
 Revokes every rule from a source and returns the number removed.
 
int revokeByActor (const std::string &actor, const std::string &reason="actor_revoked")
 Revokes every rule whose actor field equals actor.
 
int revokeByScope (const std::string &scope, const std::string &reason="scope_revoked")
 Revokes every rule whose scope field equals scope.
 
int revokeByCapability (const std::string &capability, const std::string &reason="capability_revoked")
 Revokes every rule whose capability field equals capability.
 
void update (double dtSeconds)
 Advances finite rule durations and expires rules reaching zero.
 
bool can (const std::string &actor, const std::string &scope, const std::string &capability) const
 Returns whether the winning rule allows a capability. @cost Linear in candidate rules for the query triple (exact key plus wildcard rules).
 
Decision explain (const std::string &actor, const std::string &scope, const std::string &capability) const
 Returns an explainable decision and its winning rule. @cost Linear in candidate rules for the query triple (exact key plus wildcard rules).
 
const Rule * find (const std::string &id) const
 Returns a rule by stable ID, or nullptr. @ownership Borrowed from this store; callers must not delete or retain it. @nullable Null when the id is absent. @lifetime Until the rule is revoked/expired or the store is restored/destroyed.
 
int queryActor (const std::string &actor)
 Queries rules for an actor in deterministic creation order.
 
int queryScope (const std::string &scope)
 Queries rules for a scope in deterministic creation order.
 
int queryCapability (const std::string &capability)
 Queries rules for a capability in deterministic creation order.
 
int query (const std::string &actor, const std::string &scope, const std::string &capability)
 Queries rules matching actor, scope, and capability.
 
const Rule * queryAt (int index) const
 Returns a rule from the latest query, or nullptr. @ownership Borrowed from this store; callers must not delete or retain it. @nullable Null when the index is outside the latest query range. @lifetime Until the next query/mutation/restore or store destruction.
 
eve::Result< void > setEventCapacity (int capacity)
 Sets the maximum number of retained lifecycle events.
 
int eventCapacity () const noexcept
 Returns the event retention capacity; 0 means unlimited.
 
int eventCount () const
 Returns retained authority event count.
 
const Event * eventAt (int index) const
 Returns a retained event, or nullptr. @ownership Borrowed from this store's retained event deque. @nullable Null when the index is outside the retained range. @lifetime Until clearEvents, capacity trim, restore, or destruction; do not retain it across those calls.
 
void clearEvents ()
 Clears retained events without resetting sequence allocation.
 
std::string snapshotJson () const
 Exports persistent state as deterministic compact JSON.
 
eve::Result< void > restoreJson (const std::string &json)
 Transactionally restores a snapshot produced by snapshotJson().
 
eve::Result< eve::SnapshotEnvelope > snapshot (const eve::SnapshotHashProvider &hashProvider) const
 Captures this store in the common versioned snapshot envelope.
 
eve::Result< void > restoreSnapshot (const eve::SnapshotEnvelope &snapshot, const eve::SnapshotHashProvider &hashProvider)
 Restores a verified or migratable snapshot transactionally.
 
eve::Result< std::string > snapshotEnvelopeJson (const eve::SnapshotHashProvider &hashProvider) const
 Serializes the common snapshot envelope as canonical JSON.
 
eve::Result< void > restoreSnapshotJson (std::string_view json, const eve::SnapshotHashProvider &hashProvider)
 Parses and transactionally restores a common snapshot envelope.
 

详细描述

Generic, deterministic capability authority store.

在文件 Authority.h 第 76 行定义.

构造及析构函数说明

◆ Store()

eve::authority::Store::Store ( eve::PersistentId  instanceId = {})
explicit

Creates an authority store with an optional persistent identity.

参数
instanceIdIdentity carried by new SnapshotEnvelope values; nil is a valid legacy identity.

在文件 Authority.cpp 第 111 行定义.

成员函数说明

◆ can()

bool eve::authority::Store::can ( const std::string &  actor,
const std::string &  scope,
const std::string &  capability 
) const

Returns whether the winning rule allows a capability. @cost Linear in candidate rules for the query triple (exact key plus wildcard rules).

在文件 Authority.cpp 第 317 行定义.

引用了 eve::authority::Decision::allowed, explain() , 以及 scope.

◆ clearEvents()

void eve::authority::Store::clearEvents ( )

Clears retained events without resetting sequence allocation.

在文件 Authority.cpp 第 357 行定义.

◆ deny()

eve::Result< std::string > eve::authority::Store::deny ( const std::string &  actor,
const std::string &  scope,
const std::string &  capability,
const std::string &  source,
int  priority = 0,
double  duration = 0.0 
)

Adds a deny rule and returns its stable ID.

参数
actorOpaque actor identity, or kWildcard to match any actor.
scopeOpaque scope identity, or kWildcard to match any scope.
capabilityOpaque capability name, or kWildcard to match any capability.
sourceOpaque provenance used by revokeBySource and explain.
priorityHigher values win; ties prefer deny, then earlier creation order.
durationSeconds until expiry; 0 means the rule does not auto-expire.
返回
The stable rule id, or InvalidArgument when any required field is empty or duration is non-finite.

在文件 Authority.cpp 第 231 行定义.

引用了 eve::authority::Deny, duration, priority, scope , 以及 source.

◆ eventAt()

const Event * eve::authority::Store::eventAt ( int  index) const

Returns a retained event, or nullptr. @ownership Borrowed from this store's retained event deque. @nullable Null when the index is outside the retained range. @lifetime Until clearEvents, capacity trim, restore, or destruction; do not retain it across those calls.

在文件 Authority.cpp 第 354 行定义.

引用了 index.

◆ eventCapacity()

int eve::authority::Store::eventCapacity ( ) const
inlinenoexcept

Returns the event retention capacity; 0 means unlimited.

在文件 Authority.h 第 192 行定义.

◆ eventCount()

int eve::authority::Store::eventCount ( ) const

Returns retained authority event count.

在文件 Authority.cpp 第 353 行定义.

◆ explain()

Decision eve::authority::Store::explain ( const std::string &  actor,
const std::string &  scope,
const std::string &  capability 
) const

Returns an explainable decision and its winning rule. @cost Linear in candidate rules for the query triple (exact key plus wildcard rules).

备注
Rule fields equal to kWildcard match any query value on that dimension.

在文件 Authority.cpp 第 302 行定义.

引用了 eve::authority::Rule::effect, find(), eve::authority::Grant, scope , 以及 winner.

被这些函数引用 can().

◆ find()

const Rule * eve::authority::Store::find ( const std::string &  id) const

Returns a rule by stable ID, or nullptr. @ownership Borrowed from this store; callers must not delete or retain it. @nullable Null when the id is absent. @lifetime Until the rule is revoked/expired or the store is restored/destroyed.

在文件 Authority.cpp 第 320 行定义.

被这些函数引用 explain().

◆ grant()

eve::Result< std::string > eve::authority::Store::grant ( const std::string &  actor,
const std::string &  scope,
const std::string &  capability,
const std::string &  source,
int  priority = 0,
double  duration = 0.0 
)

Adds a grant rule and returns its stable ID.

参数
actorOpaque actor identity, or kWildcard to match any actor.
scopeOpaque scope identity, or kWildcard to match any scope.
capabilityOpaque capability name, or kWildcard to match any capability.
sourceOpaque provenance used by revokeBySource and explain.
priorityHigher values win; ties prefer deny, then earlier creation order.
durationSeconds until expiry; 0 means the rule does not auto-expire.
返回
The stable rule id, or InvalidArgument when any required field is empty or duration is non-finite.

在文件 Authority.cpp 第 227 行定义.

引用了 duration, eve::authority::Grant, priority, scope , 以及 source.

◆ query()

int eve::authority::Store::query ( const std::string &  actor,
const std::string &  scope,
const std::string &  capability 
)

Queries rules matching actor, scope, and capability.

备注
Empty query fields act as wildcards over stored rules. Stored kWildcard fields also match the corresponding non-empty query field.

在文件 Authority.cpp 第 325 行定义.

引用了 eve::authority::kWildcard , 以及 scope.

被这些函数引用 queryActor(), queryCapability() , 以及 queryScope().

◆ queryActor()

int eve::authority::Store::queryActor ( const std::string &  actor)

Queries rules for an actor in deterministic creation order.

在文件 Authority.cpp 第 335 行定义.

引用了 query().

◆ queryAt()

const Rule * eve::authority::Store::queryAt ( int  index) const

Returns a rule from the latest query, or nullptr. @ownership Borrowed from this store; callers must not delete or retain it. @nullable Null when the index is outside the latest query range. @lifetime Until the next query/mutation/restore or store destruction.

在文件 Authority.cpp 第 338 行定义.

引用了 index.

◆ queryCapability()

int eve::authority::Store::queryCapability ( const std::string &  capability)

Queries rules for a capability in deterministic creation order.

在文件 Authority.cpp 第 337 行定义.

引用了 query().

◆ queryScope()

int eve::authority::Store::queryScope ( const std::string &  scope)

Queries rules for a scope in deterministic creation order.

在文件 Authority.cpp 第 336 行定义.

引用了 query() , 以及 scope.

◆ restoreJson()

eve::Result< void > eve::authority::Store::restoreJson ( const std::string &  json)

Transactionally restores a snapshot produced by snapshotJson().

参数
jsonSnapshot JSON to parse and validate.
返回
Success, or a structured parse/invariant diagnostic; failure leaves every observable store field unchanged. @thread Call on the store's owning simulation thread. @reentrancy Does not invoke callbacks.

在文件 Authority.cpp 第 382 行定义.

引用了 eve::authority::Rule::actor, eve::authority::Rule::capability, eve::authority::Deny, eve::authority::Rule::duration, eve::authority::Rule::effect, effect, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::authority::Grant, eve::authority::Rule::id, eve::InvariantViolation, eve::authority::Rule::order, order, eve::json::Document::parse(), eve::ParseError, eve::authority::Rule::priority, eve::authority::Rule::remaining, root, eve::authority::Rule::scope, eve::authority::Rule::source, eve::Result< T >::success() , 以及 values.

被这些函数引用 restoreSnapshot().

◆ restoreSnapshot()

eve::Result< void > eve::authority::Store::restoreSnapshot ( const eve::SnapshotEnvelope &  snapshot,
const eve::SnapshotHashProvider &  hashProvider 
)

Restores a verified or migratable snapshot transactionally.

参数
snapshotSource envelope. Its schema must be authority:store.
hashProviderExplicit provider used to verify and reseal the payload.
返回
Success, or a failure leaving all store state unchanged.

在文件 Authority.cpp 第 450 行定义.

引用了 eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::detail::Id128< Tag >::isNil(), payload, restoreJson(), source, eve::Result< T >::success() , 以及 eve::validateSnapshotPayloadMetadata().

被这些函数引用 restoreSnapshotJson().

◆ restoreSnapshotJson()

eve::Result< void > eve::authority::Store::restoreSnapshotJson ( std::string_view  json,
const eve::SnapshotHashProvider &  hashProvider 
)

Parses and transactionally restores a common snapshot envelope.

参数
jsonCanonical snapshot envelope JSON.
hashProviderExplicit provider used to verify contentHash.
返回
Success, or a failure leaving all store state unchanged.

在文件 Authority.cpp 第 486 行定义.

引用了 eve::Result< T >::failure(), eve::parseSnapshotEnvelope(), restoreSnapshot() , 以及 source.

◆ revoke()

eve::Result< void > eve::authority::Store::revoke ( const std::string &  id,
const std::string &  reason = "revoked" 
)

Revokes a rule by stable ID.

返回
Applied on success, or NotFound when the id is absent.

在文件 Authority.cpp 第 236 行定义.

引用了 eve::Applied, eve::authority::Revoked, eve::Status::success() , 以及 eve::Result< T >::success().

◆ revokeByActor()

int eve::authority::Store::revokeByActor ( const std::string &  actor,
const std::string &  reason = "actor_revoked" 
)

Revokes every rule whose actor field equals actor.

备注
Use when an actor entity is destroyed; does not match wildcard actors.

在文件 Authority.cpp 第 268 行定义.

引用了 eve::authority::Rule::actor.

◆ revokeByCapability()

int eve::authority::Store::revokeByCapability ( const std::string &  capability,
const std::string &  reason = "capability_revoked" 
)

Revokes every rule whose capability field equals capability.

备注
Does not match wildcard capabilities.

在文件 Authority.cpp 第 276 行定义.

引用了 eve::authority::Rule::capability.

◆ revokeByScope()

int eve::authority::Store::revokeByScope ( const std::string &  scope,
const std::string &  reason = "scope_revoked" 
)

Revokes every rule whose scope field equals scope.

备注
Use when a scope entity is destroyed; does not match wildcard scopes.

在文件 Authority.cpp 第 272 行定义.

引用了 eve::authority::Rule::scope , 以及 scope.

◆ revokeBySource()

int eve::authority::Store::revokeBySource ( const std::string &  source,
const std::string &  reason = "source_revoked" 
)

Revokes every rule from a source and returns the number removed.

备注
0 is a valid no-op outcome, not a failure.

在文件 Authority.cpp 第 264 行定义.

引用了 source , 以及 eve::authority::Rule::source.

◆ setEventCapacity()

eve::Result< void > eve::authority::Store::setEventCapacity ( int  capacity)

Sets the maximum number of retained lifecycle events.

参数
capacity0 keeps unlimited retention (default). Positive values discard the oldest events once the cap is exceeded. Negative values are rejected.
返回
Applied, or InvalidArgument when capacity is negative.

在文件 Authority.cpp 第 342 行定义.

引用了 eve::Applied, capacity, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success() , 以及 eve::Result< T >::success().

◆ snapshot()

eve::Result< eve::SnapshotEnvelope > eve::authority::Store::snapshot ( const eve::SnapshotHashProvider &  hashProvider) const

Captures this store in the common versioned snapshot envelope.

参数
hashProviderExplicit content-digest provider; it is never defaulted silently.
返回
A sealed snapshot, or a structured serialization/hash failure. @cost Allocates and hashes the full rule set; amortize across save / sync boundaries.

在文件 Authority.cpp 第 443 行定义.

引用了 eve::Result< T >::failure(), eve::Value::fromJson(), eve::makeSnapshotEnvelope(), payload , 以及 snapshotJson().

被这些函数引用 snapshotEnvelopeJson().

◆ snapshotEnvelopeJson()

eve::Result< std::string > eve::authority::Store::snapshotEnvelopeJson ( const eve::SnapshotHashProvider &  hashProvider) const

Serializes the common snapshot envelope as canonical JSON.

参数
hashProviderExplicit content-digest provider.
返回
Canonical envelope JSON or a structured failure.

在文件 Authority.cpp 第 479 行定义.

引用了 eve::Result< T >::failure(), eve::serializeSnapshotEnvelope(), snapshot() , 以及 value.

◆ snapshotJson()

std::string eve::authority::Store::snapshotJson ( ) const

Exports persistent state as deterministic compact JSON.

在文件 Authority.cpp 第 364 行定义.

引用了 eve::authority::effectName(), first, out , 以及 quote.

被这些函数引用 snapshot().

◆ update()

void eve::authority::Store::update ( double  dtSeconds)

Advances finite rule durations and expires rules reaching zero.

参数
dtSecondsInjected simulation delta; non-positive or non-finite values are ignored.

在文件 Authority.cpp 第 280 行定义.

引用了 changed , 以及 eve::authority::Expired.


该类的文档由以下文件生成: