Documentation ¶
Overview ¶
Package control provides a set of Services (in the Supervisor terminology) that are started by the main sync process.
Index ¶
- Constants
- func GetBus() *pubsub.PubSub
- func MessageFromString(text string) (int, error)
- type CommandMessage
- type FileStateStore
- type HttpServer
- type MemoryStateStore
- func (b *MemoryStateStore) BothConnected() bool
- func (b *MemoryStateStore) Close()
- func (b *MemoryStateStore) LastState() common.SyncState
- func (b *MemoryStateStore) TouchLastOpsTime(t ...time.Time)
- func (b *MemoryStateStore) UpdateConnection(c bool, i model.EndpointInfo) common.SyncState
- func (b *MemoryStateStore) UpdateEndpointStats(s *model.EndpointRootStat, i model.EndpointInfo) common.SyncState
- func (b *MemoryStateStore) UpdateProcessStatus(processStatus model.Status, status ...model.TaskStatus) common.SyncState
- func (b *MemoryStateStore) UpdateSyncStatus(s model.TaskStatus) common.SyncState
- func (b *MemoryStateStore) UpdateWatcherActivity(a bool, i model.EndpointInfo) common.SyncState
- type PatchesRequest
- type PatchesResponse
- type Profiler
- type Scheduler
- type SpawnedService
- type StateStore
- type StdInner
- type Supervisor
- type Syncer
- type TreeRequest
- type TreeResponse
- type Updater
Constants ¶
const ( TopicGlobal = "cmd" TopicSyncAll = "sync" TopicSync_ = "sync-" TopicState = "state" TopicStore_ = "store" TopicUpdate = "update" )
const ( MessageHalt = iota MessageRestart MessageInterrupt MessagePause MessageResume MessageEnable MessageDisable MessageSyncLoop MessageResync MessageResyncDry MessagePublishState MessagePublishStore MessageRestartClean // Restart an clean snapshots MessageHaltClean // Halt task and remove all configs )
Variables ¶
This section is empty.
Functions ¶
func MessageFromString ¶
MessageFromString converts string to MessageXXX integers
Types ¶
type CommandMessage ¶
type CommandMessage int
type FileStateStore ¶ added in v0.8.0
type FileStateStore struct { MemoryStateStore PreviousState model.TaskStatus FileError error // contains filtered or unexported fields }
FileStateStore extends MemoryStore by storing the Status inside a file that stays open. It is used at restart to check if the last processing state was Idle, otherwise something may have been stopped in the middle and we trigger a full resync.
func NewFileStateStore ¶ added in v0.8.0
func NewFileStateStore(config *config.Task, folderPath string) *FileStateStore
NewFileStateStore creates a FileStateStore with the state file in the target folder.
func (*FileStateStore) Close ¶ added in v0.8.0
func (f *FileStateStore) Close()
Close closes the state file
func (*FileStateStore) UpdateProcessStatus ¶ added in v0.8.0
func (f *FileStateStore) UpdateProcessStatus(processStatus model.Status, status ...model.TaskStatus) common.SyncState
UpdateProcessStatus stores the status in the state file
func (*FileStateStore) UpdateSyncStatus ¶ added in v0.8.0
func (f *FileStateStore) UpdateSyncStatus(s model.TaskStatus) common.SyncState
UpdateSyncStatus stores the status in the state file
type HttpServer ¶
type HttpServer struct { WebSocket *melody.Melody LogSocket *melody.Melody // contains filtered or unexported fields }
func NewHttpServer ¶
func NewHttpServer() *HttpServer
NewHttpServer creates a supervisor service for spinning the http server.
func (*HttpServer) InitHandlers ¶
func (h *HttpServer) InitHandlers()
InitHandlers initialize WebSocket handlers.
func (*HttpServer) ListenAuthorities ¶ added in v0.8.0
func (h *HttpServer) ListenAuthorities()
ListenAuthorities listens to a config watcher for transmitting Authority changes. It should be called as a goroutine.
func (*HttpServer) ListenStatus ¶
func (h *HttpServer) ListenStatus()
ListenStatus is hooked to the general Bus to listen for SyncStates and UpdateMessages. It should be called as a goroutine
func (*HttpServer) Serve ¶
func (h *HttpServer) Serve()
Serve implements supervisor service interface. It basically starts the http server.
type MemoryStateStore ¶
MemoryStateStore keeps all SyncStates in memory.
func NewMemoryStateStore ¶
func NewMemoryStateStore(config *config.Task) *MemoryStateStore
NewMemoryStateStore creates a MemoryStateStore.
func (*MemoryStateStore) BothConnected ¶
func (b *MemoryStateStore) BothConnected() bool
BothConnected returns true if both Endpoints have a connected status.
func (*MemoryStateStore) Close ¶ added in v0.8.0
func (b *MemoryStateStore) Close()
Close closes the state store
func (*MemoryStateStore) LastState ¶
func (b *MemoryStateStore) LastState() common.SyncState
LastState returns the last known state of the task.
func (*MemoryStateStore) TouchLastOpsTime ¶
func (b *MemoryStateStore) TouchLastOpsTime(t ...time.Time)
TouchLastOps updates the time of last known operation.
func (*MemoryStateStore) UpdateConnection ¶
func (b *MemoryStateStore) UpdateConnection(c bool, i model.EndpointInfo) common.SyncState
UpdateConnection updates the connection status of one endpoint.
func (*MemoryStateStore) UpdateEndpointStats ¶
func (b *MemoryStateStore) UpdateEndpointStats(s *model.EndpointRootStat, i model.EndpointInfo) common.SyncState
UpdateEndpointStats updates the statistics about the root of one endpoint.
func (*MemoryStateStore) UpdateProcessStatus ¶
func (b *MemoryStateStore) UpdateProcessStatus(processStatus model.Status, status ...model.TaskStatus) common.SyncState
UpdateProcessStatus updates the status of one endpoint. It is recognized based on its EndpointURI.
func (*MemoryStateStore) UpdateSyncStatus ¶
func (b *MemoryStateStore) UpdateSyncStatus(s model.TaskStatus) common.SyncState
UpdateSyncStatus updates the internal status.
func (*MemoryStateStore) UpdateWatcherActivity ¶
func (b *MemoryStateStore) UpdateWatcherActivity(a bool, i model.EndpointInfo) common.SyncState
UpdateWatcherActivity updates the watcher status of one endpoint.
type PatchesRequest ¶
type PatchesResponse ¶
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler is a supervisor service for serving internal golang pprof debugs on 6060
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is a supervisor service emitting various commands on a timely manner.
func NewScheduler ¶
NewScheduler creates a scheduler and register the schedules from the tasks configs.
type SpawnedService ¶ added in v0.8.0
type SpawnedService struct {
// contains filtered or unexported fields
}
SpawnedService is a supervisor service for launching a command and automatically restarting if it fails.
func NewSpawnedService ¶ added in v0.8.0
func NewSpawnedService(name string, args []string) *SpawnedService
NewSpawnedService creates a SpawnedService
func (*SpawnedService) Serve ¶ added in v0.8.0
func (c *SpawnedService) Serve()
Serve implements supervisor service interface.
func (*SpawnedService) Stop ¶ added in v0.8.0
func (c *SpawnedService) Stop()
Stop implements supervisor service interface.
type StateStore ¶
type StateStore interface { LastState() common.SyncState BothConnected() bool TouchLastOpsTime(t ...time.Time) Close() UpdateConnection(c bool, i model.EndpointInfo) common.SyncState UpdateWatcherActivity(a bool, i model.EndpointInfo) common.SyncState UpdateEndpointStats(s *model.EndpointRootStat, i model.EndpointInfo) common.SyncState UpdateSyncStatus(s model.TaskStatus) common.SyncState UpdateProcessStatus(processStatus model.Status, status ...model.TaskStatus) common.SyncState }
StateStore is used to maintain the states of the sync tasks
type StdInner ¶
type StdInner struct {
// contains filtered or unexported fields
}
StdInner is a supervisor service for scanning StdIn
type Supervisor ¶
type Supervisor struct { sync.Mutex *suture.Supervisor // contains filtered or unexported fields }
Supervisor is a service manager for starting syncs and other services and restarting them if necessary
func NewSupervisor ¶
func NewSupervisor(noUi bool) *Supervisor
NewSupervisor creates a new Supervisor
func (*Supervisor) Serve ¶
func (s *Supervisor) Serve() error
Serve starts all services and start listening to config and bus The call is blocking until all services are stopped
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer is a supervisor service wrapping a sync task.
type TreeRequest ¶
type TreeResponse ¶
TreeResponse is a fake protobuf used for marshaling responses to tree requests.
func (*TreeResponse) MarshalJSON ¶
func (l *TreeResponse) MarshalJSON() ([]byte, error)
MarshalJSON uses jsonpb for marshaling struct to JSON
func (*TreeResponse) ProtoMessage ¶
func (l *TreeResponse) ProtoMessage()
ProtoMessage implements Proto() interface
func (*TreeResponse) String ¶
func (l *TreeResponse) String() string
String implements Proto() interface
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater is a supervisor service for checking for available updates
func (*Updater) ApplyUpdate ¶
ApplyUpdate uses the info of an update.Package to download the binary and replace the current running binary. A restart is necessary afterward. The dryRun option will download the binary and just put it in the /tmp folder