T5.2: Introduce autostart.Manager interface + per-platform impls
Define Manager with Set/Status in autostart.go; add concrete types (windowsManager, linuxManager, otherManager) in the per-platform files. Service gains a manager field wired by Open() via autostart.New(); AutostartStatus and ApplyAutostart delegate to it instead of calling package-level functions directly. Tests that don't need autostart get a nil manager, which is safe (no-op returns). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-1
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"gitea.mixdep.ru/mix/gosentry/src/domain"
|
||||
"gitea.mixdep.ru/mix/gosentry/src/platform/autostart"
|
||||
"gitea.mixdep.ru/mix/gosentry/src/runner"
|
||||
"gitea.mixdep.ru/mix/gosentry/src/scheduler"
|
||||
"gitea.mixdep.ru/mix/gosentry/src/storage"
|
||||
@@ -58,6 +59,10 @@ type Service struct {
|
||||
sched *scheduler.Scheduler
|
||||
cancel context.CancelFunc
|
||||
|
||||
// manager is the platform autostart implementation. It is nil in tests that
|
||||
// do not exercise autostart; Open() wires it via autostart.New().
|
||||
manager autostart.Manager
|
||||
|
||||
// observers and their guard live in events.go. dispatchMu is separate from mu
|
||||
// so that emitting an event never requires (or is held under) the state lock:
|
||||
// the Service must release mu before dispatching, per the locking contract.
|
||||
@@ -136,7 +141,9 @@ func Open() (*Service, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewService(store, jobs), nil
|
||||
svc := NewService(store, jobs)
|
||||
svc.manager = autostart.New()
|
||||
return svc, nil
|
||||
}
|
||||
|
||||
// Store returns the underlying store. It is exposed so callers that still need
|
||||
|
||||
Reference in New Issue
Block a user