Implement event-driven daemon improvements for bd-85
- Add mutation events for label/dep/comment operations - Create separate export-only and import-only functions - Add dropped events counter with safety net export - Complete bd-80 mutation channel implementation Event-driven mode now: - Emits mutation events for ALL write operations (not just create/update/close) - Uses createExportFunc() for mutations (export+commit/push only, no pull) - Uses createAutoImportFunc() for file changes (pull+import only, no export) - Tracks dropped events and triggers safety export every 60s if any dropped - Achieves <500ms latency target by avoiding full sync on each trigger Behind BEADS_DAEMON_MODE=events flag (poll is still default)
This commit is contained in:
@@ -47,7 +47,8 @@ type Server struct {
|
||||
// Auto-import single-flight guard
|
||||
importInProgress atomic.Bool
|
||||
// Mutation events for event-driven daemon
|
||||
mutationChan chan MutationEvent
|
||||
mutationChan chan MutationEvent
|
||||
droppedEvents atomic.Int64 // Counter for dropped mutation events
|
||||
}
|
||||
|
||||
// MutationEvent represents a database mutation for event-driven sync
|
||||
@@ -105,7 +106,8 @@ func (s *Server) emitMutation(eventType, issueID string) {
|
||||
}:
|
||||
// Event sent successfully
|
||||
default:
|
||||
// Channel full, event dropped (not critical - sync will happen eventually)
|
||||
// Channel full, increment dropped events counter
|
||||
s.droppedEvents.Add(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,3 +115,13 @@ func (s *Server) emitMutation(eventType, issueID string) {
|
||||
func (s *Server) MutationChan() <-chan MutationEvent {
|
||||
return s.mutationChan
|
||||
}
|
||||
|
||||
// DroppedEventsCount returns the number of dropped mutation events
|
||||
func (s *Server) DroppedEventsCount() int64 {
|
||||
return s.droppedEvents.Load()
|
||||
}
|
||||
|
||||
// ResetDroppedEventsCount resets the dropped events counter and returns the previous value
|
||||
func (s *Server) ResetDroppedEventsCount() int64 {
|
||||
return s.droppedEvents.Swap(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user