objecttype

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWorldStateRequired = errors.New("world state is required")

ErrWorldStateRequired is returned when the factory requires a WorldState but it is nil.

Functions

func EngineIDFromContext

func EngineIDFromContext(ctx context.Context) string

EngineIDFromContext returns the world engine ID from the context. Returns empty string if not set.

func SessionPeerIDFromContext

func SessionPeerIDFromContext(ctx context.Context) peer.ID

SessionPeerIDFromContext returns the session peer ID from the context. Returns empty peer.ID if not set.

func WithEngineID

func WithEngineID(ctx context.Context, engineID string) context.Context

WithEngineID returns a context with the world engine ID attached.

func WithSessionPeerID

func WithSessionPeerID(ctx context.Context, peerID peer.ID) context.Context

WithSessionPeerID returns a context with the session peer ID attached. The factory can use SessionPeerIDFromContext to retrieve it.

Types

type LookupObjectType

type LookupObjectType interface {
	// Directive indicates LookupObjectType is a directive.
	directive.Directive

	// LookupObjectTypeID returns the object type ID to lookup.
	LookupObjectTypeID() string
}

LookupObjectType is a directive to look up an object type factory.

func NewLookupObjectType

func NewLookupObjectType(objectTypeID string) LookupObjectType

NewLookupObjectType constructs a new LookupObjectType directive.

type LookupObjectTypeValue

type LookupObjectTypeValue = ObjectType

LookupObjectTypeValue is the result type for LookupObjectType.

type ObjectType

type ObjectType interface {
	// GetObjectTypeID returns the type identifier this factory handles.
	// Format: "alpha/object-layout" or similar.
	GetObjectTypeID() string
	// GetFactory returns the factory function for creating typed resources.
	GetFactory() ObjectTypeFactory
}

ObjectType provides a factory for creating typed resources from objects.

func ExLookupObjectType

func ExLookupObjectType(
	ctx context.Context,
	b bus.Bus,
	typeID string,
) (ObjectType, directive.Reference, error)

ExLookupObjectType executes a lookup for a single object type on the bus.

typeID is the object type identifier to lookup. Returns the ObjectType or nil if not found.

func NewObjectType

func NewObjectType(typeID string, factory ObjectTypeFactory) ObjectType

NewObjectType creates a new ObjectType with the given type ID and factory.

type ObjectTypeFactory

type ObjectTypeFactory = func(
	ctx context.Context,
	le *logrus.Entry,
	b bus.Bus,
	engine world.Engine,
	ws world.WorldState,
	objectKey string,
) (srpc.Invoker, func(), error)

ObjectTypeFactory creates a typed srpc.Invoker from an object key.

ctx is the context for the factory operation. objectKey is the key of the object to create the typed resource for. ws is the WorldState containing this object (may be nil). engine is the world Engine for creating write transactions (may be nil).

Returns the invoker, a cleanup function, and any error. The cleanup function must be called when the resource is no longer needed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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