engine

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAPIMux added in v0.0.20

func NewAPIMux(engine *WorldServer, promHandler http.Handler, bridges *media.BridgeManager, logHandler ...http.Handler) *http.ServeMux

NewAPIMux creates an http.ServeMux with the gRPC-Connect APIs, WHEP/media endpoints, healthz, and metrics registered. It does NOT serve the frontend — callers can add a "/" handler for that. Used by both StartEngine and the Wails desktop app.

func ParseEntities added in v0.0.22

func ParseEntities(b []byte) ([]*pb.Entity, error)

func StartEngine

func StartEngine(ctx context.Context, cfg EngineConfig) (string, error)

StartEngine starts the Hydris engine and returns the server address. If worldFile is provided, it loads entities from that file on startup and periodically flushes the current state back to the file.

func StartMetricsUpdater

func StartMetricsUpdater(server *WorldServer)

Types

type Bus

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

func NewBus

func NewBus() *Bus

func (*Bus) CloseAll added in v0.0.20

func (b *Bus) CloseAll()

CloseAll cancels all consumers, forcing their WatchEntities streams to terminate.

func (*Bus) Dirty

func (b *Bus) Dirty(entityID string, entity *pb.Entity, change pb.EntityChange)

func (*Bus) Register

func (b *Bus) Register(c *Consumer)

func (*Bus) Unregister

func (b *Bus) Unregister(c *Consumer)

type Consumer

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

func NewConsumer

func NewConsumer(world *WorldServer, limiter *pb.WatchBehavior, filter *pb.EntityFilter) *Consumer

func (*Consumer) SenderLoop

func (c *Consumer) SenderLoop(ctx context.Context, send func(*pb.EntityChangeEvent) error) error

type EngineConfig

type EngineConfig struct {
	WorldFile  string
	PolicyFile string
	NoDefaults bool
	LogHandler http.Handler
}

EngineConfig holds configuration for starting the engine

type LogRing added in v0.0.21

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

LogRing is a lock-free ring buffer that implements io.Writer. Each Write call is stored as one log line with ANSI escapes stripped.

func (*LogRing) ServeHTTP added in v0.0.21

func (r *LogRing) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP renders the log buffer as plain text.

func (*LogRing) Write added in v0.0.21

func (r *LogRing) Write(p []byte) (n int, err error)

type WorldServer

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

func NewWorldServer

func NewWorldServer() *WorldServer

func (*WorldServer) EntityCount

func (s *WorldServer) EntityCount() int

func (*WorldServer) FlushToFile

func (s *WorldServer) FlushToFile() error

FlushToFile writes the current head state to the world file atomically. Only local entities (controller.node == this node) are persisted, and only the config and device components are kept. Entities with lifetime.until (expiring/temporary) are skipped entirely.

func (*WorldServer) GC added in v0.0.21

func (s *WorldServer) GC()

func (*WorldServer) GetEntity

func (*WorldServer) GetHead

func (s *WorldServer) GetHead(id string) *pb.Entity

func (*WorldServer) GetSourceURL added in v0.0.20

func (s *WorldServer) GetSourceURL(entityID string, streamIndex int) string

GetSourceURL returns the original source URL for a camera stream before the MediaTransformer rewrote it to a proxy URL.

func (*WorldServer) HardReset added in v0.0.20

func (*WorldServer) InitNodeIdentity

func (s *WorldServer) InitNodeIdentity()

InitNodeIdentity finds or creates a stable node identity. It looks for an existing entity with a DeviceComponent containing a NodeDevice. If none is found, it derives one from hardware MAC addresses.

func (*WorldServer) LoadDefaults added in v0.0.19

func (s *WorldServer) LoadDefaults(b []byte) error

LoadDefaults loads default entities. Entities that don't yet exist in head are inserted; existing ones are merged. Defaults use a very old timestamp (Unix epoch) so they never overwrite entities that were loaded from persistence with a real timestamp.

func (*WorldServer) LoadFromFile

func (s *WorldServer) LoadFromFile(path string) error

func (*WorldServer) RunTask

func (*WorldServer) SetNodeID added in v0.0.21

func (s *WorldServer) SetNodeID(id string)

SetNodeID overrides the node identity. Used in tests to simulate distinct nodes on the same machine. Must be called after InitNodeIdentity.

func (*WorldServer) SetWorldFile

func (s *WorldServer) SetWorldFile(path string)

SetWorldFile sets the path for world state persistence

func (*WorldServer) StartPeriodicFlush

func (s *WorldServer) StartPeriodicFlush(interval time.Duration)

StartPeriodicFlush starts a goroutine that periodically flushes the head to the world file. It also starts a debounce goroutine that flushes shortly after config changes.

func (*WorldServer) TimeSync added in v0.0.22

func (*WorldServer) WatchEntities

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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