Documentation
¶
Index ¶
- Variables
- func BuiltinConnContext(ctx context.Context, _ net.Conn) context.Context
- func ComputeManifest(entities []*pb.Entity, idx missionpkg.Index) *missionpkg.Manifest
- func NewAPIMux(engine *WorldServer, promHandler http.Handler, bridges *media.BridgeManager, ...) *http.ServeMux
- func NewBuiltinServer(handler http.Handler) *http.Server
- func ParseEntities(b []byte) ([]*pb.Entity, error)
- func StartEngine(ctx context.Context, cfg EngineConfig) (string, error)
- func StartMetricsUpdater(server *WorldServer)
- type Bus
- type Consumer
- type EngineConfig
- type EntityMetricsCollector
- type LogRing
- type PolicyEvaluator
- type WorldServer
- func (s *WorldServer) ConnContext(ctx context.Context, c net.Conn) context.Context
- 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) GC()
- 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) GetSelf(ctx context.Context, req *connect.Request[pb.GetSelfRequest]) (*connect.Response[pb.GetSelfResponse], error)
- func (s *WorldServer) HardReset(ctx context.Context, req *connect.Request[pb.HardResetRequest]) (*connect.Response[pb.HardResetResponse], error)
- func (s *WorldServer) InitNodeIdentity()
- func (s *WorldServer) InitNodeSecrets()
- func (s *WorldServer) ListEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest]) (*connect.Response[pb.ListEntitiesResponse], error)
- func (s *WorldServer) LoadDefaultEntities(entities []*pb.Entity) error
- func (s *WorldServer) LoadDefaults(b []byte) error
- func (s *WorldServer) LoadFromFile(path string) error
- func (s *WorldServer) LoadMission(ctx context.Context, req *connect.Request[pb.LoadMissionRequest]) (*connect.Response[pb.LoadMissionResponse], 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) SetNodeID(id string)
- func (s *WorldServer) SetStreamEpoch(entityID string, streamIndex int, epoch time.Time)
- func (s *WorldServer) SetWorldFile(path string)
- func (s *WorldServer) StartPeriodicFlush(interval time.Duration)
- func (s *WorldServer) TimeSync(ctx context.Context, req *connect.Request[pb.TimeSyncRequest]) (*connect.Response[pb.TimeSyncResponse], error)
- func (s *WorldServer) WatchEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest], ...) error
Constants ¶
This section is empty.
Variables ¶
var NodeTLSCert *tls.Certificate
NodeTLSCert holds the node's TLS certificate once loaded, for use by federation and other subsystems that need to present it as a client cert.
Functions ¶
func BuiltinConnContext ¶ added in v0.0.23
func ComputeManifest ¶ added in v0.0.23
func ComputeManifest(entities []*pb.Entity, idx missionpkg.Index) *missionpkg.Manifest
ComputeManifest records what's about to be packed so receivers can compare against observed state after apply. Pure function over the snapshotted entities and the already-populated Index. Exported so the CLI's mission build can write the same metadata into offline packs.
func NewAPIMux ¶ added in v0.0.20
func NewAPIMux(engine *WorldServer, promHandler http.Handler, bridges *media.BridgeManager, ring *LogRing) *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 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 (*Bus) CloseAll ¶ added in v0.0.20
func (b *Bus) CloseAll()
CloseAll cancels all consumers, forcing their WatchEntities streams to terminate.
func (*Bus) Unregister ¶
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 ¶
type EngineConfig struct {
WorldFile string
NoDefaults bool
DisableSecurity bool
LogRing *LogRing
// AdvertiseURL is the externally-reachable base URL for this node (e.g.
// https://node.example.com). When set it is shown in the startup banner.
AdvertiseURL string
}
EngineConfig holds configuration for starting the engine
type EntityMetricsCollector ¶ added in v1.0.0
type EntityMetricsCollector struct {
// contains filtered or unexported fields
}
EntityMetricsCollector exposes every Metric component currently held in head as prometheus gauges.
func NewEntityMetricsCollector ¶ added in v1.0.0
func NewEntityMetricsCollector(server *WorldServer) *EntityMetricsCollector
func (*EntityMetricsCollector) Collect ¶ added in v1.0.0
func (c *EntityMetricsCollector) Collect(ch chan<- prometheus.Metric)
func (*EntityMetricsCollector) Describe ¶ added in v1.0.0
func (c *EntityMetricsCollector) Describe(ch chan<- *prometheus.Desc)
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.
type PolicyEvaluator ¶ added in v0.0.23
type PolicyEvaluator struct {
// contains filtered or unexported fields
}
func NewPolicyEvaluator ¶ added in v0.0.23
func NewPolicyEvaluator(world *WorldServer) *PolicyEvaluator
func (*PolicyEvaluator) AllowMedia ¶ added in v1.0.0
func (pe *PolicyEvaluator) AllowMedia(remoteAddr string) bool
AllowMedia reports whether a media client from remoteAddr may access camera streams. Media is gated by the ordinary read entitlement: it evaluates the global policy as an anonymous read of a /media/ path (RTSP carries no per-request credentials, so the caller is anonymous). Localhost remains allowed via is.local.
func (*PolicyEvaluator) Interceptor ¶ added in v0.0.23
func (pe *PolicyEvaluator) Interceptor() connect.Interceptor
Interceptor returns the policy interceptor. It implements connect.Interceptor (not just the unary func) so that client-streaming handlers — notably ArtifactService.UploadArtifact — are also authenticated and authorized; a unary-only interceptor would leave streaming uploads completely open.
func (*PolicyEvaluator) Middleware ¶ added in v0.0.23
func (pe *PolicyEvaluator) Middleware(next http.Handler) http.Handler
Middleware wraps an http.Handler with policy evaluation for non-Connect HTTP endpoints (media, artifacts, plugins, etc.). Connect RPC paths are skipped here because the Connect interceptor handles them with richer request context.
func (*PolicyEvaluator) Rebuild ¶ added in v0.0.23
func (pe *PolicyEvaluator) Rebuild()
Rebuild recompiles the authorization chain (authz.policy) and the connection-identity chain (authn.policy) from their singleton entities (shipped in defaults.yaml, editable at runtime). If authz.policy carries no PolicyComponent — e.g. defaults were disabled — it falls back to a fail-closed chain so a node is never left wide open. Caller must NOT hold world.l.
type WorldServer ¶
type WorldServer struct {
// contains filtered or unexported fields
}
func NewWorldServer ¶
func NewWorldServer() *WorldServer
func (*WorldServer) ConnContext ¶ added in v0.0.23
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, reduced to their durable components. 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 (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) GetSelf ¶ added in v1.0.0
func (s *WorldServer) GetSelf(ctx context.Context, req *connect.Request[pb.GetSelfRequest]) (*connect.Response[pb.GetSelfResponse], error)
GetSelf reports the identity the caller is authenticated as, along with that identity's entity (carrying its policy) when present.
func (*WorldServer) HardReset ¶ added in v0.0.20
func (s *WorldServer) HardReset(ctx context.Context, req *connect.Request[pb.HardResetRequest]) (*connect.Response[pb.HardResetResponse], 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) InitNodeSecrets ¶ added in v1.0.0
func (s *WorldServer) InitNodeSecrets()
InitNodeSecrets ensures the node has a TLS identity: a long-lived, self-signed ed25519 certificate persisted as a plaintext PEM file on disk, exactly like a conventional server TLS key. Because the file lives outside the world graph, it survives a HardReset, so the node keeps a stable fingerprint and a stable bootstrap secret across resets.
func (*WorldServer) ListEntities ¶
func (s *WorldServer) ListEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest]) (*connect.Response[pb.ListEntitiesResponse], error)
func (*WorldServer) LoadDefaultEntities ¶ added in v1.0.0
func (s *WorldServer) LoadDefaultEntities(entities []*pb.Entity) error
LoadDefaultEntities loads entities as defaults: each is stamped with a Unix epoch lifetime so it loses the last-writer-wins merge against any persisted or runtime entity, letting operators override it. Used both for the YAML defaults and for engine-provided defaults (e.g. the policy chain) so they go through one identical path.
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) LoadMission ¶ added in v0.0.23
func (s *WorldServer) LoadMission(ctx context.Context, req *connect.Request[pb.LoadMissionRequest]) (*connect.Response[pb.LoadMissionResponse], 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) 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) SetStreamEpoch ¶ added in v0.0.23
func (s *WorldServer) SetStreamEpoch(entityID string, streamIndex int, epoch time.Time)
SetStreamEpoch records the epoch for a stream and notifies subscribers.
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 (s *WorldServer) TimeSync(ctx context.Context, req *connect.Request[pb.TimeSyncRequest]) (*connect.Response[pb.TimeSyncResponse], error)
func (*WorldServer) WatchEntities ¶
func (s *WorldServer) WatchEntities(ctx context.Context, req *connect.Request[pb.ListEntitiesRequest], stream *connect.ServerStream[pb.EntityChangeEvent]) error