Documentation
¶
Index ¶
- Variables
- func EngineIDFromContext(ctx context.Context) string
- func SessionPeerIDFromContext(ctx context.Context) peer.ID
- func WithEngineID(ctx context.Context, engineID string) context.Context
- func WithSessionPeerID(ctx context.Context, peerID peer.ID) context.Context
- type LookupObjectType
- type LookupObjectTypeValue
- type ObjectType
- type ObjectTypeFactory
Constants ¶
This section is empty.
Variables ¶
var ErrWorldStateRequired = errors.New("world state is required")
ErrWorldStateRequired is returned when the factory requires a WorldState but it is nil.
Functions ¶
func EngineIDFromContext ¶
EngineIDFromContext returns the world engine ID from the context. Returns empty string if not set.
func SessionPeerIDFromContext ¶
SessionPeerIDFromContext returns the session peer ID from the context. Returns empty peer.ID if not set.
func WithEngineID ¶
WithEngineID returns a context with the world engine ID attached.
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.