sdk_world_engine

package
v0.51.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourceClient added in v0.51.2

type ResourceClient interface {
	CreateResourceReference(resourceID uint32) resource_client.ResourceRef
}

ResourceClient creates references for resource IDs returned by world RPCs.

type SDKEngine

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

SDKEngine implements world.Engine over SRPC by delegating to EngineResourceService calls on a remote resource.

func NewSDKEngine

func NewSDKEngine(client ResourceClient, ref resource_client.ResourceRef) (*SDKEngine, error)

NewSDKEngine creates a new SDKEngine wrapping a resource reference.

func (*SDKEngine) AccessWorldState

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

AccessWorldState builds a bucket lookup cursor with an optional ref.

func (*SDKEngine) BuildStorageCursor

func (e *SDKEngine) BuildStorageCursor(ctx context.Context) (*bucket_lookup.Cursor, error)

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

func (*SDKEngine) GetSeqno

func (e *SDKEngine) GetSeqno(ctx context.Context) (uint64, error)

GetSeqno returns the current sequence number of the world state.

func (*SDKEngine) NewTransaction

func (e *SDKEngine) NewTransaction(ctx context.Context, write bool) (world.Tx, error)

NewTransaction creates a new transaction against the world state. Set write=true if the transaction will perform write operations. Always call Discard() when done with the transaction. Note: Engine might return a read-only transaction even if write=true.

func (*SDKEngine) Release

func (e *SDKEngine) Release()

Release releases the underlying resource reference.

func (*SDKEngine) WaitSeqno

func (e *SDKEngine) WaitSeqno(ctx context.Context, value uint64) (uint64, error)

WaitSeqno waits for the world state sequence number to reach or exceed the specified value.

type SDKObjectIterator

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

SDKObjectIterator implements world.ObjectIterator over SRPC by delegating to ObjectIteratorResourceService calls on a remote resource.

SDKObjectIterator functions are NOT thread safe, use from one goroutine at a time.

Note: the world.ObjectIterator interface does not pass context on its methods, but SRPC calls require one. The context from the IterateObjects call is captured and used for all subsequent calls.

func NewSDKObjectIterator

func NewSDKObjectIterator(ctx context.Context, ref resource_client.ResourceRef) (*SDKObjectIterator, error)

NewSDKObjectIterator creates a new SDKObjectIterator wrapping a resource reference. The context is used for all subsequent SRPC calls on the iterator.

func (*SDKObjectIterator) Close

func (it *SDKObjectIterator) Close()

Close releases the iterator.

func (*SDKObjectIterator) Err

func (it *SDKObjectIterator) Err() error

Err returns any error that has closed the iterator.

func (*SDKObjectIterator) Key

func (it *SDKObjectIterator) Key() string

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

func (*SDKObjectIterator) Next

func (it *SDKObjectIterator) Next() bool

Next advances to the next entry and returns Valid.

func (*SDKObjectIterator) Seek

func (it *SDKObjectIterator) Seek(k string) error

Seek moves the iterator to the first key >= the provided key (or <= in reverse mode). Pass empty string to seek to the beginning (or end if reversed).

func (*SDKObjectIterator) Valid

func (it *SDKObjectIterator) Valid() bool

Valid returns if the iterator points to a valid entry.

type SDKObjectState

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

SDKObjectState implements world.ObjectState over SRPC by delegating to ObjectStateResourceService calls on a remote resource.

func NewSDKObjectState

func NewSDKObjectState(client ResourceClient, ref resource_client.ResourceRef, objectKey string) (*SDKObjectState, error)

NewSDKObjectState creates a new SDKObjectState wrapping a resource reference.

func (*SDKObjectState) AccessWorldState

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

AccessWorldState builds a bucket lookup cursor with an optional ref.

func (*SDKObjectState) ApplyObjectOp

func (os *SDKObjectState) ApplyObjectOp(ctx context.Context, op world.Operation, sender peer.ID) (uint64, bool, error)

ApplyObjectOp applies a batch operation at the object level. Returns rev, sysErr, err.

func (*SDKObjectState) GetKey

func (os *SDKObjectState) GetKey() string

GetKey returns the key this state object is for.

func (*SDKObjectState) GetRootRef

func (os *SDKObjectState) GetRootRef(ctx context.Context) (*bucket.ObjectRef, uint64, error)

GetRootRef returns the root reference and current revision number.

func (*SDKObjectState) IncrementRev

func (os *SDKObjectState) IncrementRev(ctx context.Context) (uint64, error)

IncrementRev increments the revision of the object. Returns revision just after the change was applied.

func (*SDKObjectState) Release

func (os *SDKObjectState) Release()

Release releases the underlying resource reference.

func (*SDKObjectState) SetRootRef

func (os *SDKObjectState) SetRootRef(ctx context.Context, rootRef *bucket.ObjectRef) (uint64, error)

SetRootRef changes the root reference of the object. Increments the revision of the object if changed. Returns revision just after the change was applied.

func (*SDKObjectState) WaitRev

func (os *SDKObjectState) WaitRev(ctx context.Context, rev uint64, ignoreNotFound bool) (uint64, error)

WaitRev waits until the object rev is >= the specified. Returns ErrObjectNotFound if the object is deleted. If ignoreNotFound is set, waits for the object to exist. Returns the new rev.

type SDKTx

type SDKTx struct {
	*SDKWorldState
	// contains filtered or unexported fields
}

SDKTx implements world.Tx over SRPC by delegating to TxResourceService and WorldStateResourceService calls.

func NewSDKTx

func NewSDKTx(client ResourceClient, ref resource_client.ResourceRef, readOnly bool) (*SDKTx, error)

NewSDKTx creates a new SDKTx wrapping a resource reference. The reference must point to a TxResource on the server.

func (*SDKTx) Commit

func (tx *SDKTx) Commit(ctx context.Context) error

Commit commits the transaction to storage.

func (*SDKTx) Discard

func (tx *SDKTx) Discard()

Discard cancels the transaction. If called after Commit, does nothing. Releasing the resource reference triggers server-side cleanup which includes discarding the underlying transaction.

type SDKWorldState

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

SDKWorldState implements world.WorldState over SRPC by delegating to WorldStateResourceService calls on a remote resource.

func NewSDKWorldState

func NewSDKWorldState(client ResourceClient, ref resource_client.ResourceRef, readOnly bool) (*SDKWorldState, error)

NewSDKWorldState creates a new SDKWorldState wrapping a resource reference.

func (*SDKWorldState) AccessCayleyGraph

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

AccessCayleyGraph calls a callback with a temporary Cayley graph handle.

func (*SDKWorldState) AccessWorldState

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

AccessWorldState builds a bucket lookup cursor with an optional ref.

func (*SDKWorldState) ApplyWorldOp

func (ws *SDKWorldState) ApplyWorldOp(ctx context.Context, op world.Operation, sender peer.ID) (uint64, bool, error)

ApplyWorldOp applies a batch operation at the world level. The handling of the operation is operation-type specific. Returns seqno, sysErr, err.

func (*SDKWorldState) BuildStorageCursor

func (ws *SDKWorldState) BuildStorageCursor(ctx context.Context) (*bucket_lookup.Cursor, error)

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

func (*SDKWorldState) CreateObject

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

CreateObject creates an object with a key and initial root ref. Returns ErrObjectExists if the object already exists.

func (*SDKWorldState) DeleteGraphObject

func (ws *SDKWorldState) DeleteGraphObject(ctx context.Context, value string) error

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

func (*SDKWorldState) DeleteGraphQuad

func (ws *SDKWorldState) DeleteGraphQuad(ctx context.Context, q world.GraphQuad) error

DeleteGraphQuad deletes a quad from the graph store.

func (*SDKWorldState) DeleteObject

func (ws *SDKWorldState) DeleteObject(ctx context.Context, key string) (bool, error)

DeleteObject deletes an object and associated graph quads by ID. Returns false, nil if not found.

func (*SDKWorldState) GetObject

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

GetObject looks up an object by key. Returns nil, false if not found.

func (*SDKWorldState) GetReadOnly

func (ws *SDKWorldState) GetReadOnly() bool

GetReadOnly returns if the state is read-only.

func (*SDKWorldState) GetSeqno

func (ws *SDKWorldState) GetSeqno(ctx context.Context) (uint64, error)

GetSeqno returns the current sequence number of the world state.

func (*SDKWorldState) IterateObjects

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

IterateObjects returns an iterator with the given object key prefix. The prefix is NOT clipped from the output keys. Keys are returned in sorted order. Must call Next() or Seek() before valid. Call Close when done with the iterator.

func (*SDKWorldState) ListObjectsWithType

func (ws *SDKWorldState) ListObjectsWithType(ctx context.Context, typeID string) ([]string, error)

ListObjectsWithType lists object keys with the given type identifier.

func (*SDKWorldState) LookupGraphQuads

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

LookupGraphQuads searches for graph quads in the store.

func (*SDKWorldState) Release

func (ws *SDKWorldState) Release()

Release releases the underlying resource reference.

func (*SDKWorldState) RenameObject

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

RenameObject renames an object key and updates associated graph quads.

func (*SDKWorldState) SetGraphQuad

func (ws *SDKWorldState) SetGraphQuad(ctx context.Context, q world.GraphQuad) error

SetGraphQuad sets a quad in the graph store.

func (*SDKWorldState) WaitSeqno

func (ws *SDKWorldState) WaitSeqno(ctx context.Context, value uint64) (uint64, error)

WaitSeqno waits for the world state sequence number to reach or exceed the specified value.

Jump to

Keyboard shortcuts

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