clone

a self-hosted multitenant nostr relay with sites, file storage, git hosting, and inbox and outbox delivery

feat/tinyagent
tinyrelay / internal / daemon / callbacks_service.go
callbacks_service.go 1.7K
1package daemon23import (4 "net/http"5 "sync"67 "github.com/FelineStateMachine/tinyrelay/internal/catalog"8 "github.com/FelineStateMachine/tinyrelay/internal/community"9 "github.com/FelineStateMachine/tinyrelay/internal/gates"10 "github.com/FelineStateMachine/tinyrelay/internal/policy"11 "github.com/FelineStateMachine/tinyrelay/internal/storage"12 "github.com/FelineStateMachine/tinyrelay/internal/telemetry"13)1415// callbackService owns callback registration, matching and durable delivery.16// It borrows the tenant store, community and gate. Per-registration locks17// serialize remote delivery; the daemon owns worker startup and shutdown.18type callbackService struct {19 store *storage.Store20 community *community.Service21 gate *gates.Gate22 policy func() policy.Policy23 publicURL string24 relayURL string25 tenant catalog.Tenant26 telemetry *telemetry.Telemetry2728 callbackMu sync.Mutex29 callbackIndex map[int][]callbackRecord30 callbackLocks map[string]*sync.Mutex31 callbackClient *http.Client32}3334// callbackServiceConfig binds storage, current policy and visibility checks.35// PublicURL identifies the HTTP relay in deliveries; RelayURL supplies the36// WebSocket address used by event visibility checks.37type callbackServiceConfig struct {38 Store *storage.Store39 Community *community.Service40 Gate *gates.Gate41 Policy func() policy.Policy42 PublicURL string43 RelayURL string44 Tenant catalog.Tenant45 Telemetry *telemetry.Telemetry46}4748func newCallbackService(cfg callbackServiceConfig) *callbackService {49 return &callbackService{50 store: cfg.Store, community: cfg.Community, gate: cfg.Gate,51 policy: cfg.Policy, publicURL: cfg.PublicURL, relayURL: cfg.RelayURL,52 tenant: cfg.Tenant, telemetry: cfg.Telemetry,53 }54}