feat(nest): POST/GET nest messages, Jev-first tagging, event-driven crow response (#10)

This commit is contained in:
Smokey committed 2026-10-28 03:34:37 -06:00
1 parent ba5dbbc7ae
commit e4e4d12dea
5 files changed
+281 -1

No files matched your search

+16
View File
@@ -116,6 +116,22 @@ func (h *Hub) Publish(listID, name string, fields map[string]any) {
}
}
// OpenNest lazily opens a stream for a nest's conversation. Nest ids are
// slugs and list ids are hex, so the same map serves both without collision.
func (h *Hub) OpenNest(nestID string) {
h.mu.Lock()
defer h.mu.Unlock()
if h.lists[nestID] == nil {
h.lists[nestID] = &listStream{created: time.Now(), subs: map[chan sseMsg]struct{}{}}
}
}
// PublishNest records one nest event and sends it to subscribers.
func (h *Hub) PublishNest(nestID, name string, fields map[string]any) {
h.OpenNest(nestID)
h.Publish(nestID, name, fields)
}
// Subscribe returns the history after lastID and a channel for what comes next.
// The channel closes if the subscriber falls too far behind.
func (h *Hub) Subscribe(listID string, lastID int) ([]sseMsg, chan sseMsg, bool) {