world_types

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TypesPrefix = "types/"

TypesPrefix is the prefix string for all types identifiers.

Variables

View Source
var (
	// ErrTypeIDEmpty is returned if the given type ID was empty.
	ErrTypeIDEmpty = errors.New("type ID empty")
	// ErrUnknownObjectType indicates the object type was not known.
	ErrUnknownObjectType = errors.New("unknown object type")
)
View Source
var TypePred quad.Value = quad.IRI("type")

TypePred is the predicate linking a object to its type.

Functions

func BuildTypeObjectKey

func BuildTypeObjectKey(typeID string) string

BuildTypeObjectKey returns the object key referring to the type.

func BuildTypeQuad

func BuildTypeQuad(objKey, typeID string) quad.Quad

BuildTypeQuad returns a type quad for a key and type.

func BuildTypeQuadValue

func BuildTypeQuadValue(typeID string) quad.Value

BuildTypeQuadValue returns the quad value referring to the type.

func CheckObjectType

func CheckObjectType(ctx context.Context, ws world.WorldState, key, typeID string) error

CheckObjectType asserts that the object key exists and has the given type.

func EnsureTypeExists

func EnsureTypeExists(ctx context.Context, ws world.WorldState, typeID string) (created bool, err error)

EnsureTypeExists creates the object representing the type ID if it doesn't exist.

The world state answers HasObject from transaction-local knowledge when it can, so repeated calls with the same type within one transaction avoid re-reading the type object. Creating the object only when HasObject reports it absent is safe under the single-writer transaction discipline; concurrent creation is not a concern within one transaction.

func GetObjectType

func GetObjectType(ctx context.Context, ws world.WorldState, key string) (string, error)

GetObjectType returns the type of a given object. Returns "" if the object has no type.

func IterateObjectsWithType

func IterateObjectsWithType(
	rctx context.Context,
	ws world.WorldState,
	typeID string,
	cb func(objKey string) (bool, error),
) error

IterateObjectsWithType iterates over object keys with the given type ID.

func LimitNodesToTypes

func LimitNodesToTypes(path *cayley.Path, typeIDs ...string) *cayley.Path

LimitNodesToTypes limits the matched nodes to the given types in the Path.

func ListCollectObjectsWithType

func ListCollectObjectsWithType[T block.Block](ctx context.Context, ws world.WorldState, typeID string, ctor func() block.Block) ([]T, []string, error)

ListCollectObjectsWithType returns the list of object keys with the given type id. Unmarshals the bodies of the matched objects.

ctor must return an object of type T returns two slices of length objKeys if any objects are not found, returns nil for that object state / value and objs, objsStates, ErrNotFound returns nil, nil, err for any other error

func ListObjectsWithType

func ListObjectsWithType(ctx context.Context, ws world.WorldState, typeID string) ([]string, error)

ListObjectsWithType returns the list of object keys with the given type id.

func SetObjectType

func SetObjectType(ctx context.Context, ws world.WorldState, key, typeID string) error

SetObjectType sets the type of a given object by writing a graph quad.

Types

type ObjectMetadata

type ObjectMetadata struct {
	// ObjectKey is the object key.
	ObjectKey string
	// TypeID is the type of the object, empty if none.
	TypeID string
	// ParentObjectKey is the parent object key, empty if none.
	ParentObjectKey string
}

ObjectMetadata holds the type and parent metadata for a single object.

func GetObjectMetadataBatch

func GetObjectMetadataBatch(ctx context.Context, ws world.WorldState, keys []string) ([]*ObjectMetadata, error)

GetObjectMetadataBatch returns the type and parent metadata for a list of object keys using exact graph lookups. This intentionally avoids the local Cayley handle API so remote and TinyGo callers can use the same path.

The result slice preserves the input key order.

type ObjectMetadataBatcher added in v0.51.6

type ObjectMetadataBatcher interface {
	// GetObjectMetadataBatch returns graph metadata for object keys.
	GetObjectMetadataBatch(ctx context.Context, keys []string) ([]*ObjectMetadata, error)
}

ObjectMetadataBatcher returns metadata for object keys without requiring a Cayley handle.

type ObjectTypeLister added in v0.51.6

type ObjectTypeLister interface {
	// ListObjectsWithType lists object keys with the given type identifier.
	ListObjectsWithType(ctx context.Context, typeID string) ([]string, error)
}

ObjectTypeLister lists objects by type without requiring a Cayley handle.

Jump to

Keyboard shortcuts

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