feat: show daemon config in 'bd daemon --status' output

Add auto-commit, auto-push, local mode, sync interval, and daemon mode
to the status output when querying a running daemon.

This helps users understand the current daemon configuration without
having to check logs or remember what flags were used at startup.

Changes:
- Add config fields to StatusResponse in protocol.go
- Add SetConfig() method to Server for daemon to set its config
- Update handleStatus() to include config in response
- Update showDaemonStatus() to query and display config via RPC
- Add comprehensive test coverage for new functionality

Co-authored-by: Christian Catalan <crcatala@gmail.com>
This commit is contained in:
cc-vps
2025-12-15 09:03:20 -08:00
parent bc3e8f6359
commit 4e87ae18e5
6 changed files with 305 additions and 6 deletions

View File

@@ -54,6 +54,12 @@ type Server struct {
recentMutations []MutationEvent
recentMutationsMu sync.RWMutex
maxMutationBuffer int
// Daemon configuration (set via SetConfig after creation)
autoCommit bool
autoPush bool
localMode bool
syncInterval string
daemonMode string
}
// Mutation event types
@@ -152,6 +158,17 @@ func (s *Server) MutationChan() <-chan MutationEvent {
return s.mutationChan
}
// SetConfig sets the daemon configuration for status reporting
func (s *Server) SetConfig(autoCommit, autoPush, localMode bool, syncInterval, daemonMode string) {
s.mu.Lock()
defer s.mu.Unlock()
s.autoCommit = autoCommit
s.autoPush = autoPush
s.localMode = localMode
s.syncInterval = syncInterval
s.daemonMode = daemonMode
}
// ResetDroppedEventsCount resets the dropped events counter and returns the previous value
func (s *Server) ResetDroppedEventsCount() int64 {
return s.droppedEvents.Swap(0)