Documentation
¶
Index ¶
- func StartEngine(ctx context.Context, cfg EngineConfig) (string, error)
- func StartMetricsUpdater(server *WorldServer)
- type Bus
- type Consumer
- type EngineConfig
- type Event
- type Store
- type WorldServer
- func (s *WorldServer) EntityCount() int
- func (s *WorldServer) ExpireEntity(ctx context.Context, req *connect.Request[pb.ExpireEntityRequest]) (*connect.Response[pb.ExpireEntityResponse], error)
- func (s *WorldServer) FlushToFile() error
- func (s *WorldServer) GetEntity(ctx context.Context, req *connect.Request[pb.GetEntityRequest]) (*connect.Response[pb.GetEntityResponse], error)
- func (s *WorldServer) GetHead(id string) *pb.Entity
- func (s *WorldServer) GetLocalNode(ctx context.Context, req *connect.Request[pb.GetLocalNodeRequest]) (*connect.Response[pb.GetLocalNodeResponse], error)
- func (s *WorldServer) GetTimeline(ctx context.Context, req *connect.Request[pb.GetTimelineRequest], ...) error
- func (s *WorldServer) InitNodeIdentity()
- func (s *WorldServer) ListEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest]) (*connect.Response[pb.ListEntitiesResponse], error)
- func (s *WorldServer) LoadDefaults(b []byte) error
- func (s *WorldServer) LoadFromFile(path string) error
- func (s *WorldServer) MoveTimeline(ctx context.Context, req *connect.Request[pb.MoveTimelineRequest]) (*connect.Response[pb.MoveTimelineResponse], error)
- func (s *WorldServer) Push(ctx context.Context, req *connect.Request[pb.EntityChangeRequest]) (*connect.Response[pb.EntityChangeResponse], error)
- func (s *WorldServer) RunTask(ctx context.Context, req *connect.Request[pb.RunTaskRequest]) (*connect.Response[pb.RunTaskResponse], error)
- func (s *WorldServer) SetWorldFile(path string)
- func (s *WorldServer) StartPeriodicFlush(interval time.Duration)
- func (s *WorldServer) WatchEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest], ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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 ¶
type EngineConfig ¶
EngineConfig holds configuration for starting the engine
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
remember to design this to sync over nats AND into kv
func (*Store) GetEventsInTimeRange ¶
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) ExpireEntity ¶
func (s *WorldServer) ExpireEntity(ctx context.Context, req *connect.Request[pb.ExpireEntityRequest]) (*connect.Response[pb.ExpireEntityResponse], error)
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) GetEntity ¶
func (s *WorldServer) GetEntity(ctx context.Context, req *connect.Request[pb.GetEntityRequest]) (*connect.Response[pb.GetEntityResponse], error)
func (*WorldServer) GetLocalNode ¶
func (s *WorldServer) GetLocalNode(ctx context.Context, req *connect.Request[pb.GetLocalNodeRequest]) (*connect.Response[pb.GetLocalNodeResponse], error)
func (*WorldServer) GetTimeline ¶
func (s *WorldServer) GetTimeline(ctx context.Context, req *connect.Request[pb.GetTimelineRequest], stream *connect.ServerStream[pb.GetTimelineResponse]) error
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) ListEntities ¶
func (s *WorldServer) ListEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest]) (*connect.Response[pb.ListEntitiesResponse], error)
func (*WorldServer) LoadDefaults ¶ added in v0.0.19
func (s *WorldServer) LoadDefaults(b []byte) error
LoadDefaults loads default entities, hard-setting lifetime.from to a very old timestamp so that any entity written with a real timestamp wins via LWW. Entities that don't yet exist in head are inserted; existing ones are only overwritten if they have an older timestamp (which in practice won't happen).
func (*WorldServer) LoadFromFile ¶
func (s *WorldServer) LoadFromFile(path string) error
func (*WorldServer) MoveTimeline ¶
func (s *WorldServer) MoveTimeline(ctx context.Context, req *connect.Request[pb.MoveTimelineRequest]) (*connect.Response[pb.MoveTimelineResponse], error)
func (*WorldServer) Push ¶
func (s *WorldServer) Push(ctx context.Context, req *connect.Request[pb.EntityChangeRequest]) (*connect.Response[pb.EntityChangeResponse], error)
func (*WorldServer) RunTask ¶
func (s *WorldServer) RunTask(ctx context.Context, req *connect.Request[pb.RunTaskRequest]) (*connect.Response[pb.RunTaskResponse], error)
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) WatchEntities ¶
func (s *WorldServer) WatchEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest], stream *connect.ServerStream[pb.EntityChangeEvent]) error