Files
BountyBoard/internal/http/providers.go
T
etalon 4e01b64bbd feat: ticketing sync workers with idempotent import and orphan flagging (phase 6)
- task domain model + exhaustive §4.4 status machine tests (single source of truth)
- per-customer polling workers reconciled every 30s from the customers
  collection; panic-safe runs; manual sync-now trigger; status provider
  for the admin panel
- §5.3 upsert keyed on (system, key, customerId): refreshes content while
  status=imported, records upstream_changed timeline + notification after
- attachments cached into GridFS via connector-authorized downloads
- orphaned tickets flagged with timeline + consultant notification, never
  deleted; idempotent across polls
- consultant identity from users.extra.ticketingIdentities per system
- notifications store (insert/list/unread-count/mark-read)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 19:03:13 +02:00

69 lines
2.1 KiB
Go

package httpx
import "context"
// Late-bound providers: these are wired by later subsystems (atomizer
// client, work-performer client, sync manager, job runner) after the server
// is constructed. All accessors are nil-safe so the admin status panel
// degrades gracefully while subsystems are absent (e.g. in tests).
// BreakerInfo exposes a circuit breaker's state for the status panel.
type BreakerInfo interface {
BreakerState() string // closed | open | half-open
}
// StatusProvider returns arbitrary JSON-marshalable status payloads.
type StatusProvider interface {
Statuses() any
}
func (s *Server) SetAtomizerInfo(b BreakerInfo) { s.atomizer = b }
func (s *Server) SetPerformerInfo(b BreakerInfo) { s.performer = b }
// SetSyncTrigger wires the sync manager's "sync now" entry point.
func (s *Server) SetSyncTrigger(f func(customerID string)) { s.syncTrigger = f }
// Publish forwards a live event to connected clients. Until the WebSocket
// hub lands this is a metrics-only no-op, so subsystems can emit events
// unconditionally.
func (s *Server) Publish(channel, event string, payload any) {
s.metrics.Inc("events_published_total", 1)
if s.publishFn != nil {
s.publishFn(channel, event, payload)
}
}
// SetPublishFn wires the actual hub broadcast.
func (s *Server) SetPublishFn(f func(channel, event string, payload any)) { s.publishFn = f }
func (s *Server) SetSyncStatusProvider(p StatusProvider) {
s.syncProvider = p
}
func (s *Server) SetJobsStatusProvider(p StatusProvider) {
s.jobsProvider = p
}
func (s *Server) syncStatuses() any {
if s.syncProvider == nil {
return []any{}
}
return s.syncProvider.Statuses()
}
func (s *Server) jobStatuses() any {
if s.jobsProvider == nil {
return map[string]any{}
}
return s.jobsProvider.Statuses()
}
// effectiveAtomizerBaseURL honors the admin settings override (§3) over the
// env default.
func (s *Server) effectiveAtomizerBaseURL(ctx context.Context) string {
if s.store != nil {
if st, err := s.store.GetSettings(ctx); err == nil && st.AtomizerBaseURLOverride != "" {
return st.AtomizerBaseURLOverride
}
}
return s.cfg.AtomizerBaseURL
}