resource_world

package
v0.51.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterTypedObjectResource

func RegisterTypedObjectResource(mux srpc.Mux, le *logrus.Entry, b bus.Bus, ws world.WorldState, engine world.Engine)

RegisterTypedObjectResource registers the TypedObjectResourceService on a mux.

Types

type EngineResource

type EngineResource struct {
	// contains filtered or unexported fields
}

EngineResource wraps an Engine for resource access.

func NewEngineResource

func NewEngineResource(
	le *logrus.Entry,
	b bus.Bus,
	w world.Engine,
	lookupOp world.LookupOp,
	engineInfo *s4wave_world.EngineInfo,
	opts ...WorldStateResourceOption,
) *EngineResource

NewEngineResource creates a new EngineResource.

func (*EngineResource) AccessTypedObject

AccessTypedObject looks up an object, determines its type, and returns a typed resource.

func (*EngineResource) AccessWorldState

AccessWorldState builds a bucket lookup cursor with an optional ref.

func (*EngineResource) BuildStorageCursor

BuildStorageCursor builds a cursor to the world storage with an empty ref.

func (*EngineResource) GetEngineInfo

GetEngineInfo returns information about the world engine.

func (*EngineResource) GetMux

func (r *EngineResource) GetMux() srpc.Invoker

GetMux returns the rpc mux.

func (*EngineResource) GetSeqno

GetSeqno returns the current seqno of the world state.

func (*EngineResource) GetWorldRootSnapshot added in v0.51.7

GetWorldRootSnapshot returns the current committed World root.

func (*EngineResource) NewTransaction

NewTransaction creates a new transaction against the world state.

func (*EngineResource) WaitSeqno

WaitSeqno waits for the seqno of the world state to be >= value.

func (*EngineResource) WatchWorldRootSnapshots added in v0.51.7

WatchWorldRootSnapshots streams committed World root snapshots.

func (*EngineResource) WatchWorldState

WatchWorldState implements the streaming watch RPC. Change detection starts immediately as client accesses resources.

type GraphPathQueryResource added in v0.51.6

type GraphPathQueryResource struct {
	// contains filtered or unexported fields
}

GraphPathQueryResource wraps bounded graph path query results.

func NewGraphPathQueryResource added in v0.51.6

func NewGraphPathQueryResource(
	le *logrus.Entry,
	b bus.Bus,
	result *world.GraphPathQueryResult,
	pageSize uint32,
) *GraphPathQueryResource

NewGraphPathQueryResource creates a graph path query resource.

func (*GraphPathQueryResource) Close added in v0.51.6

Close closes the graph path query resource.

func (*GraphPathQueryResource) GetMux added in v0.51.6

func (r *GraphPathQueryResource) GetMux() srpc.Invoker

GetMux returns the rpc mux.

func (*GraphPathQueryResource) Next added in v0.51.6

Next returns the next page of path query results.

type ObjectIteratorResource

type ObjectIteratorResource struct {
	// contains filtered or unexported fields
}

ObjectIteratorResource wraps an ObjectIterator for resource access.

func NewObjectIteratorResource

func NewObjectIteratorResource(le *logrus.Entry, b bus.Bus, iter world.ObjectIterator) *ObjectIteratorResource

NewObjectIteratorResource creates a new ObjectIteratorResource.

func (*ObjectIteratorResource) Close

Close closes the iterator.

func (*ObjectIteratorResource) Err

Err returns any error that has closed the iterator.

func (*ObjectIteratorResource) GetMux

func (r *ObjectIteratorResource) GetMux() srpc.Invoker

GetMux returns the rpc mux.

func (*ObjectIteratorResource) Key

Key returns the current entry key, or empty if not valid.

func (*ObjectIteratorResource) Next

Next advances to the next entry and returns Valid.

func (*ObjectIteratorResource) Seek

Seek moves the iterator to the first key >= the provided key (or <= in reverse mode).

func (*ObjectIteratorResource) Valid

Valid returns if the iterator points to a valid entry.

type ObjectStateResource

type ObjectStateResource struct {
	// contains filtered or unexported fields
}

ObjectStateResource wraps an ObjectState for resource access.

func NewObjectStateResource

func NewObjectStateResource(le *logrus.Entry, b bus.Bus, obj world.ObjectState, lookupOp world.LookupOp) *ObjectStateResource

NewObjectStateResource creates a new ObjectStateResource.

lookupOp may be nil

func (*ObjectStateResource) AccessWorldState

AccessWorldState builds a bucket lookup cursor with an optional ref.

func (*ObjectStateResource) ApplyObjectOp

ApplyObjectOp applies a batch operation at the object level.

func (*ObjectStateResource) GetKey

GetKey returns the key identifier of the object.

func (*ObjectStateResource) GetMux

func (r *ObjectStateResource) GetMux() srpc.Invoker

GetMux returns the rpc mux.

func (*ObjectStateResource) GetRootRef

GetRootRef returns the root reference of the object.

func (*ObjectStateResource) IncrementRev

IncrementRev increments the revision of the object.

func (*ObjectStateResource) SetRootRef

SetRootRef updates the root reference of the object.

func (*ObjectStateResource) WaitRev

WaitRev waits until the object rev is >= the specified revision.

type TrackedWorldState

type TrackedWorldState struct {
	// contains filtered or unexported fields
}

TrackedWorldState wraps a WorldState and records all access patterns. Immediately starts change detection as accesses are recorded.

func NewTrackedWorldState

func NewTrackedWorldState(ws world.WorldState, initialSeqno uint64, ctx context.Context) *TrackedWorldState

NewTrackedWorldState creates a new TrackedWorldState.

func (*TrackedWorldState) AccessCayleyGraph

func (t *TrackedWorldState) AccessCayleyGraph(ctx context.Context, write bool, cb func(ctx context.Context, h world.CayleyHandle) error) error

func (*TrackedWorldState) AccessWorldState

func (t *TrackedWorldState) AccessWorldState(ctx context.Context, ref *bucket.ObjectRef, cb func(*bucket_lookup.Cursor) error) error

func (*TrackedWorldState) ApplyWorldOp

func (t *TrackedWorldState) ApplyWorldOp(ctx context.Context, op world.Operation, opSender peer.ID) (uint64, bool, error)

func (*TrackedWorldState) BuildStorageCursor

func (t *TrackedWorldState) BuildStorageCursor(ctx context.Context) (*bucket_lookup.Cursor, error)

func (*TrackedWorldState) Close

func (t *TrackedWorldState) Close()

Close stops the change detection routine.

func (*TrackedWorldState) CreateObject

func (t *TrackedWorldState) CreateObject(ctx context.Context, key string, rootRef *bucket.ObjectRef) (world.ObjectState, error)

func (*TrackedWorldState) DeleteGraphObject

func (t *TrackedWorldState) DeleteGraphObject(ctx context.Context, objKey string) error

func (*TrackedWorldState) DeleteGraphQuad

func (t *TrackedWorldState) DeleteGraphQuad(ctx context.Context, q world.GraphQuad) error

func (*TrackedWorldState) DeleteObject

func (t *TrackedWorldState) DeleteObject(ctx context.Context, key string) (bool, error)

func (*TrackedWorldState) GetObject

func (t *TrackedWorldState) GetObject(ctx context.Context, key string) (world.ObjectState, bool, error)

func (*TrackedWorldState) GetReadOnly

func (t *TrackedWorldState) GetReadOnly() bool

func (*TrackedWorldState) GetSeqno

func (t *TrackedWorldState) GetSeqno(ctx context.Context) (uint64, error)

func (*TrackedWorldState) IterateObjects

func (t *TrackedWorldState) IterateObjects(ctx context.Context, prefix string, reversed bool) world.ObjectIterator

func (*TrackedWorldState) LookupGraphQuads

func (t *TrackedWorldState) LookupGraphQuads(ctx context.Context, filter world.GraphQuad, limit uint32) ([]world.GraphQuad, error)

func (*TrackedWorldState) LookupGraphQuadsBatch added in v0.51.7

func (t *TrackedWorldState) LookupGraphQuadsBatch(ctx context.Context, filters []world.GraphQuad, limitPerFilter uint32) ([][]world.GraphQuad, error)

func (*TrackedWorldState) QueryGraphPath added in v0.51.6

func (*TrackedWorldState) RenameObject

func (t *TrackedWorldState) RenameObject(ctx context.Context, oldKey, newKey string, descendants bool) (world.ObjectState, error)

func (*TrackedWorldState) SetGraphQuad

func (t *TrackedWorldState) SetGraphQuad(ctx context.Context, q world.GraphQuad) error

func (*TrackedWorldState) WaitForChanges

func (t *TrackedWorldState) WaitForChanges(ctx context.Context) error

WaitForChanges waits until any tracked resource changes. Returns nil when changes detected, error on failure or context cancel.

func (*TrackedWorldState) WaitSeqno

func (t *TrackedWorldState) WaitSeqno(ctx context.Context, seqno uint64) (uint64, error)

type TxResource

type TxResource struct {
	*WorldStateResource
	// contains filtered or unexported fields
}

TxResource wraps a Tx for resource access. It embeds WorldStateResource and adds Commit/Discard operations.

func NewTxResource

func NewTxResource(
	le *logrus.Entry,
	b bus.Bus,
	tx world.Tx,
	lookupOp world.LookupOp,
	engine world.Engine,
	opts ...WorldStateResourceOption,
) *TxResource

NewTxResource creates a new TxResource.

engine is optional - if provided, TypedObjectResourceService is registered on the mux.

func (*TxResource) Commit

Commit commits the transaction.

func (*TxResource) Discard

Discard discards the transaction without committing changes.

func (*TxResource) Release added in v0.51.7

func (r *TxResource) Release()

Release discards the underlying transaction exactly once.

type TypedObjectResource

type TypedObjectResource struct {
	// contains filtered or unexported fields
}

TypedObjectResource implements TypedObjectResourceService. It provides access to typed resources from world objects.

func NewTypedObjectResource

func NewTypedObjectResource(le *logrus.Entry, b bus.Bus, ws world.WorldState, engine world.Engine) *TypedObjectResource

NewTypedObjectResource creates a new TypedObjectResource.

func (*TypedObjectResource) AccessTypedObject

AccessTypedObject looks up an object, determines its type, and returns a typed resource. Handles special prefixes:

  • plugin-dist/{plugin-id}: accesses the plugin's distribution filesystem
  • plugin-assets/{plugin-id}: accesses the plugin's assets filesystem

type WorldStateOperationObserver added in v0.51.7

type WorldStateOperationObserver func(WorldStateOperationRecord)

WorldStateOperationObserver observes WorldStateResource operation records.

type WorldStateOperationRecord added in v0.51.7

type WorldStateOperationRecord struct {
	// Name is the WorldStateResource method name.
	Name string
	// Duration is the elapsed wall-clock duration.
	Duration time.Duration
	// Error is set when the operation returned an error.
	Error string
	// FilterCount is the number of graph filters in the request.
	FilterCount int
	// Limit is the relevant request limit.
	Limit int
	// ResultSetCount is the number of result groups returned.
	ResultSetCount int
	// ResultQuadCount is the total number of graph quads returned.
	ResultQuadCount int
	// StartKeyCount is the number of graph path start keys.
	StartKeyCount int
	// StepCount is the number of graph path steps.
	StepCount int
	// PageSize is the requested page size for resource-backed operations.
	PageSize int
	// ResultObjectCount is the number of object keys returned by the operation.
	ResultObjectCount int
	// ResourceCreated indicates that the operation attached a resource.
	ResourceCreated bool
	// BlockReadCount is the number of block cursor fetches issued by the operation.
	BlockReadCount uint64
	// BlockReadBytes is the number of block bytes returned to block cursors.
	BlockReadBytes uint64
	// BlockReadMissCount is the number of block cursor fetches that missed.
	BlockReadMissCount uint64
	// ResourceGetBlockCount is the number of Resource SDK GetBlock calls.
	ResourceGetBlockCount uint64
	// ResourceGetBlockRefCount is the number of non-empty refs passed to Resource SDK GetBlock.
	ResourceGetBlockRefCount uint64
	// ResourceGetBlockBytes is the number of bytes returned by found Resource SDK GetBlock calls.
	ResourceGetBlockBytes uint64
	// ResourceGetBlockMissCount is the number of Resource SDK GetBlock calls that missed.
	ResourceGetBlockMissCount uint64
	// DecodedBlockUnmarshalCount is the number of decoded block unmarshals.
	DecodedBlockUnmarshalCount uint64
	// DecodedBlockUnmarshalBytes is the number of bytes passed to decoded block unmarshalling.
	DecodedBlockUnmarshalBytes uint64
	// DecodedBlockCacheAttemptCount is the number of decoded-block cache lookup attempts.
	DecodedBlockCacheAttemptCount uint64
	// DecodedBlockCacheHitCount is the number of decoded-block cache hits.
	DecodedBlockCacheHitCount uint64
	// DecodedBlockCacheMissCount is the number of decoded-block cache misses.
	DecodedBlockCacheMissCount uint64
	// DecodedBlockCloneCount is the number of clone-on-hit decoded block returns.
	DecodedBlockCloneCount uint64
	// DecodedBlockUncloneableCount is the number of cache candidates that could not be cloned.
	DecodedBlockUncloneableCount uint64
	// DecodedBlockUncacheableCount is the number of decoded-block cache bypasses for missing exact keys.
	DecodedBlockUncacheableCount uint64
}

WorldStateOperationRecord describes one WorldStateResource operation.

type WorldStateResource

type WorldStateResource struct {
	// contains filtered or unexported fields
}

WorldStateResource wraps a WorldState for resource access.

func NewEngineWorldStateResource added in v0.51.2

func NewEngineWorldStateResource(
	le *logrus.Entry,
	b bus.Bus,
	ws world.WorldState,
	lookupOp world.LookupOp,
	engine world.Engine,
	opts ...WorldStateResourceOption,
) *WorldStateResource

NewEngineWorldStateResource creates a WorldStateResource with typed object access.

func NewWorldStateResource

func NewWorldStateResource(
	le *logrus.Entry,
	b bus.Bus,
	ws world.WorldState,
	lookupOp world.LookupOp,
	opts ...WorldStateResourceOption,
) *WorldStateResource

NewWorldStateResource creates a new WorldStateResource.

lookupOp may be nil

func (*WorldStateResource) AccessWorldState

AccessWorldState builds a bucket lookup cursor with an optional ref.

func (*WorldStateResource) ApplyWorldOp

ApplyWorldOp applies a batch operation at the world level.

func (*WorldStateResource) BuildStorageCursor

BuildStorageCursor builds a cursor to the world storage with an empty ref.

func (*WorldStateResource) CreateObject

CreateObject creates an object with a key and initial root ref.

func (*WorldStateResource) DeleteGraphObject

DeleteGraphObject deletes all quads with Subject or Object set to value.

func (*WorldStateResource) DeleteGraphQuad

DeleteGraphQuad deletes a quad from the graph store.

func (*WorldStateResource) DeleteObject

DeleteObject deletes an object and associated graph quads by ID.

func (*WorldStateResource) GetMux

func (r *WorldStateResource) GetMux() srpc.Invoker

GetMux returns the rpc mux.

func (*WorldStateResource) GetObject

GetObject looks up an object by key.

func (*WorldStateResource) GetObjectMetadataBatch added in v0.51.6

GetObjectMetadataBatch returns graph metadata for object keys.

func (*WorldStateResource) GetObjectRootRefsBatch added in v0.51.7

GetObjectRootRefsBatch returns root references for object keys.

func (*WorldStateResource) GetReadOnly

GetReadOnly returns if the world state is read-only.

func (*WorldStateResource) GetSeqno

GetSeqno returns the current seqno of the world state.

func (*WorldStateResource) IterateObjects

IterateObjects returns an iterator with the given object key prefix.

func (*WorldStateResource) ListGraphEdgeBuckets added in v0.51.7

ListGraphEdgeBuckets lists grouped inbound/outbound graph edge buckets.

func (*WorldStateResource) ListObjectsWithType

ListObjectsWithType lists object keys with the given type identifier.

func (*WorldStateResource) LookupGraphQuads

LookupGraphQuads searches for graph quads in the store.

func (*WorldStateResource) LookupGraphQuadsBatch added in v0.51.6

LookupGraphQuadsBatch searches for graph quads using bounded indexed filters.

func (*WorldStateResource) QueryGraphPath added in v0.51.6

QueryGraphPath creates a resource for a bounded graph path query.

func (*WorldStateResource) RenameObject

RenameObject renames an object key and associated graph quads.

func (*WorldStateResource) SetGraphQuad

SetGraphQuad sets a quad in the graph store.

func (*WorldStateResource) WaitSeqno

WaitSeqno waits for the seqno of the world state to be >= value.

type WorldStateResourceOption added in v0.51.7

type WorldStateResourceOption func(*WorldStateResource)

WorldStateResourceOption configures a WorldStateResource.

func WithWorldStateOperationObserver added in v0.51.7

func WithWorldStateOperationObserver(observer WorldStateOperationObserver) WorldStateResourceOption

WithWorldStateOperationObserver configures WorldStateResource operation accounting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL