control

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2019 License: GPL-3.0 Imports: 49 Imported by: 2

Documentation

Overview

Package control provides a set of Services (in the Supervisor terminology) that are started by the main sync process.

Index

Constants

View Source
const (
	TopicGlobal  = "cmd"
	TopicSyncAll = "sync"
	TopicSync_   = "sync-"
	TopicState   = "state"
	TopicStore_  = "store"
	TopicUpdate  = "update"
)
View Source
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 GetBus

func GetBus() *pubsub.PubSub

func MessageFromString

func MessageFromString(text string) (int, error)

Types

type CommandMessage

type CommandMessage int

type HttpServer

type HttpServer struct {
	WebSocket *melody.Melody
	LogSocket *melody.Melody
	// contains filtered or unexported fields
}

func NewHttpServer

func NewHttpServer() *HttpServer

func (*HttpServer) InitHandlers

func (h *HttpServer) InitHandlers()

func (*HttpServer) ListenStatus

func (h *HttpServer) ListenStatus()

func (*HttpServer) Serve

func (h *HttpServer) Serve()

func (*HttpServer) Stop

func (h *HttpServer) Stop()

func (*HttpServer) Sync

func (h *HttpServer) Sync() error

func (*HttpServer) Write

func (h *HttpServer) Write(p []byte) (n int, err error)

type MemoryStateStore

type MemoryStateStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMemoryStateStore

func NewMemoryStateStore(config *config.Task) *MemoryStateStore

func (*MemoryStateStore) BothConnected

func (b *MemoryStateStore) BothConnected() bool

func (*MemoryStateStore) LastState

func (b *MemoryStateStore) LastState() common.SyncState

func (*MemoryStateStore) TouchLastOpsTime

func (b *MemoryStateStore) TouchLastOpsTime(t ...time.Time)

func (*MemoryStateStore) UpdateConnection

func (b *MemoryStateStore) UpdateConnection(c bool, i model.EndpointInfo) common.SyncState

func (*MemoryStateStore) UpdateEndpointStats

func (*MemoryStateStore) UpdateProcessStatus

func (b *MemoryStateStore) UpdateProcessStatus(processStatus model.Status, status ...model.TaskStatus) common.SyncState

func (*MemoryStateStore) UpdateSyncStatus

func (b *MemoryStateStore) UpdateSyncStatus(s model.TaskStatus) common.SyncState

func (*MemoryStateStore) UpdateWatcherActivity

func (b *MemoryStateStore) UpdateWatcherActivity(a bool, i model.EndpointInfo) common.SyncState

type PatchesRequest

type PatchesRequest struct {
	SyncUUID string `uri:"uuid" binding:"required"`
	Offset   int    `uri:"offset" binding:"numeric"`
	Limit    int    `uri:"limit"`
}

type PatchesResponse

type PatchesResponse struct {
	Patches []merger.Patch
}

type Profiler

type Profiler struct {
	// contains filtered or unexported fields
}

func (*Profiler) Serve

func (p *Profiler) Serve()

func (*Profiler) Stop

func (p *Profiler) Stop()

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler(tasks []*config.Task) *Scheduler

func (*Scheduler) Serve

func (s *Scheduler) Serve()

func (*Scheduler) Stop

func (s *Scheduler) Stop()

type StateStore

type StateStore interface {
	LastState() common.SyncState
	BothConnected() bool
	TouchLastOpsTime(t ...time.Time)

	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
}

type StdInner

type StdInner struct {
	// contains filtered or unexported fields
}

func (*StdInner) Serve

func (s *StdInner) Serve()

func (*StdInner) Stop

func (s *StdInner) Stop()

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() *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
}

func NewSyncer

func NewSyncer(conf *config.Task) (syncer *Syncer)

func (*Syncer) Serve

func (s *Syncer) Serve()

func (*Syncer) Stop

func (s *Syncer) Stop()

type TreeRequest

type TreeRequest struct {
	EndpointURI string
	Path        string
	// contains filtered or unexported fields
}

type TreeResponse

type TreeResponse struct {
	Node     *tree.Node
	Children []*tree.Node
}

func (*TreeResponse) MarshalJSON

func (l *TreeResponse) MarshalJSON() ([]byte, error)

func (*TreeResponse) ProtoMessage

func (l *TreeResponse) ProtoMessage()

func (*TreeResponse) Reset

func (l *TreeResponse) Reset()

func (*TreeResponse) String

func (l *TreeResponse) String() string

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater() *Updater

func (*Updater) ApplyUpdate

func (u *Updater) ApplyUpdate(ctx context.Context, p *update.Package, dryRun bool, busTopic string)

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

func (*Updater) LoadUpdates

func (u *Updater) LoadUpdates(ctx context.Context, busTopic string) (packages []*update.Package, outErr error)

LoadUpdates will post a Json query to the update server to detect if there are any updates available

func (*Updater) Serve

func (u *Updater) Serve()

func (*Updater) Stop

func (u *Updater) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL