Documentation
¶
Overview ¶
Package activity provides a small in-process pub/sub hub for qui-owned server events ("server activity"). Background services publish lightweight signals when their state changes; the SSE layer subscribes and forwards them to connected browsers, which invalidate the matching cached query and refetch on demand instead of polling on a timer.
Events are deliberately signals, not data: they carry identifiers only (kind, instance id, resource id), never payloads. A dropped event is therefore safe - the next event, a stream reconnect, or a low-rate safety refetch reconciles the client - so the hub favours never blocking a publisher over guaranteed delivery.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Kind Kind `json:"kind"`
InstanceID int `json:"instanceId,omitempty"`
ResourceID string `json:"resourceId,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
Event is a small, JSON-serializable signal that some qui-owned state changed. InstanceID and ResourceID are optional and scope the invalidation when set.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub fans out published events to all current subscribers. The zero value is not usable; construct with NewHub.
func (*Hub) Close ¶
func (h *Hub) Close()
Close shuts the hub down, closing all subscriber channels. Subsequent Publish/Subscribe calls are no-ops.
func (*Hub) Dropped ¶
Dropped reports the lifetime count of events dropped due to full subscriber buffers.
type Kind ¶
type Kind string
Kind identifies the category of a server activity event. The frontend maps each kind to the react-query keys it should invalidate.
const ( KindBackupRun Kind = "backup.run" KindDirScanRun Kind = "dirscan.run" KindOrphanScanRun Kind = "orphanscan.run" KindCrossSeedStatus Kind = "crossseed.status" KindCrossSeedSearch Kind = "crossseed.search" KindReannounceActivity Kind = "reannounce.activity" KindAutomationActivity Kind = "automation.activity" KindIndexerActivity Kind = "indexer.activity" KindSearchHistory Kind = "search.history" KindTrackerIcons Kind = "tracker.icons" )
type NopPublisher ¶
type NopPublisher struct{}
NopPublisher is a no-op Publisher used as the default so services run normally when no hub is wired (e.g. in tests).