Sink pool cleanup and organization; better future support when we add more sinks

This commit is contained in:
Dane Everitt
2022-01-23 09:57:25 -05:00
parent 2a9c9e893e
commit a4904365c9
6 changed files with 79 additions and 49 deletions

View File

@@ -71,6 +71,8 @@ type Server struct {
wsBag *WebsocketBag
wsBagLocker sync.Mutex
sinks map[SinkName]*sinkPool
logSink *sinkPool
installSink *sinkPool
}
@@ -86,9 +88,10 @@ func New(client remote.Client) (*Server, error) {
installing: system.NewAtomicBool(false),
transferring: system.NewAtomicBool(false),
restoring: system.NewAtomicBool(false),
logSink: newSinkPool(),
installSink: newSinkPool(),
sinks: map[SinkName]*sinkPool{
LogSink: newSinkPool(),
InstallSink: newSinkPool(),
},
}
if err := defaults.Set(&s); err != nil {
return nil, errors.Wrap(err, "server: could not set default values for struct")
@@ -355,11 +358,3 @@ func (s *Server) ToAPIResponse() APIResponse {
Configuration: *s.Config(),
}
}
func (s *Server) LogSink() *sinkPool {
return s.logSink
}
func (s *Server) InstallSink() *sinkPool {
return s.installSink
}