Documentation ¶
Index ¶
- type BaseWorker
- func (b *BaseWorker) GetID() string
- func (b *BaseWorker) GetStopChan() *chan struct{}
- func (b *BaseWorker) GetSyncGroup() *sync.WaitGroup
- func (b *BaseWorker) GetWorkerType() string
- func (b *BaseWorker) HasTerminated() bool
- func (b *BaseWorker) IsRunning() bool
- func (b *BaseWorker) SetIsRunning(val bool)
- func (b *BaseWorker) StartWorker(w Worker)
- func (b *BaseWorker) StopWorker(w Worker)
- type LeaderElectionManager
- type Reconciler
- type ReconcilerConfig
- type Worker
- type WorkerMock
- func (mock *WorkerMock) GetID() string
- func (mock *WorkerMock) GetIDCalls() []struct{}
- func (mock *WorkerMock) GetStopChan() *chan struct{}
- func (mock *WorkerMock) GetStopChanCalls() []struct{}
- func (mock *WorkerMock) GetSyncGroup() *sync.WaitGroup
- func (mock *WorkerMock) GetSyncGroupCalls() []struct{}
- func (mock *WorkerMock) GetWorkerType() string
- func (mock *WorkerMock) GetWorkerTypeCalls() []struct{}
- func (mock *WorkerMock) HasTerminated() bool
- func (mock *WorkerMock) HasTerminatedCalls() []struct{}
- func (mock *WorkerMock) IsRunning() bool
- func (mock *WorkerMock) IsRunningCalls() []struct{}
- func (mock *WorkerMock) Reconcile() []error
- func (mock *WorkerMock) ReconcileCalls() []struct{}
- func (mock *WorkerMock) SetIsRunning(val bool)
- func (mock *WorkerMock) SetIsRunningCalls() []struct{ ... }
- func (mock *WorkerMock) Start()
- func (mock *WorkerMock) StartCalls() []struct{}
- func (mock *WorkerMock) Stop()
- func (mock *WorkerMock) StopCalls() []struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseWorker ¶
type BaseWorker struct { Id string WorkerType string Reconciler Reconciler // contains filtered or unexported fields }
func (*BaseWorker) GetID ¶
func (b *BaseWorker) GetID() string
func (*BaseWorker) GetStopChan ¶
func (b *BaseWorker) GetStopChan() *chan struct{}
func (*BaseWorker) GetSyncGroup ¶
func (b *BaseWorker) GetSyncGroup() *sync.WaitGroup
func (*BaseWorker) GetWorkerType ¶
func (b *BaseWorker) GetWorkerType() string
func (*BaseWorker) HasTerminated ¶
func (b *BaseWorker) HasTerminated() bool
func (*BaseWorker) IsRunning ¶
func (b *BaseWorker) IsRunning() bool
func (*BaseWorker) SetIsRunning ¶
func (b *BaseWorker) SetIsRunning(val bool)
func (*BaseWorker) StartWorker ¶
func (b *BaseWorker) StartWorker(w Worker)
func (*BaseWorker) StopWorker ¶
func (b *BaseWorker) StopWorker(w Worker)
type LeaderElectionManager ¶
type LeaderElectionManager struct {
// contains filtered or unexported fields
}
func NewLeaderElectionManager ¶
func NewLeaderElectionManager(workers []Worker, connectionFactory *db.ConnectionFactory, reconcilerConfig *ReconcilerConfig) *LeaderElectionManager
func (*LeaderElectionManager) Start ¶
func (s *LeaderElectionManager) Start()
func (*LeaderElectionManager) Stop ¶
func (s *LeaderElectionManager) Stop()
impl. Stoppable Workers started with Leader Election manager should be stop from here
type Reconciler ¶
type Reconciler struct { di.Inject SignalBus signalbus.SignalBus ReconcilerConfig *ReconcilerConfig // contains filtered or unexported fields }
func (*Reconciler) Start ¶
func (r *Reconciler) Start(worker Worker)
func (*Reconciler) Stop ¶
func (r *Reconciler) Stop(worker Worker)
func (*Reconciler) Wakeup ¶
func (r *Reconciler) Wakeup(wait bool)
Wakeup causes the worker reconcile to be performed as soon as possible. If wait is true, the this function blocks until the reconcile is completed, otherwise this function does not block.
type ReconcilerConfig ¶
type ReconcilerConfig struct { ReconcilerRepeatInterval time.Duration `json:"reconciler_repeat_interval"` LeaderLeaseExpirationTime time.Duration `json:"leader_lease_expiration_time"` LeaderElectionReconcilerRepeatInterval time.Duration `json:"leader_election_reconciler_repeat_interval"` }
func NewReconcilerConfig ¶
func NewReconcilerConfig() *ReconcilerConfig
func (*ReconcilerConfig) AddFlags ¶
func (r *ReconcilerConfig) AddFlags(fs *pflag.FlagSet)
func (*ReconcilerConfig) ReadFiles ¶
func (c *ReconcilerConfig) ReadFiles() error
type WorkerMock ¶
type WorkerMock struct { // GetIDFunc mocks the GetID method. GetIDFunc func() string // GetStopChanFunc mocks the GetStopChan method. GetStopChanFunc func() *chan struct{} // GetSyncGroupFunc mocks the GetSyncGroup method. GetSyncGroupFunc func() *sync.WaitGroup // GetWorkerTypeFunc mocks the GetWorkerType method. GetWorkerTypeFunc func() string // HasTerminatedFunc mocks the HasTerminated method. HasTerminatedFunc func() bool // IsRunningFunc mocks the IsRunning method. IsRunningFunc func() bool // ReconcileFunc mocks the Reconcile method. ReconcileFunc func() []error // SetIsRunningFunc mocks the SetIsRunning method. SetIsRunningFunc func(val bool) // StartFunc mocks the Start method. StartFunc func() // StopFunc mocks the Stop method. StopFunc func() // contains filtered or unexported fields }
WorkerMock is a mock implementation of Worker.
func TestSomethingThatUsesWorker(t *testing.T) { // make and configure a mocked Worker mockedWorker := &WorkerMock{ GetIDFunc: func() string { panic("mock out the GetID method") }, GetStopChanFunc: func() *chan struct{} { panic("mock out the GetStopChan method") }, GetSyncGroupFunc: func() *sync.WaitGroup { panic("mock out the GetSyncGroup method") }, GetWorkerTypeFunc: func() string { panic("mock out the GetWorkerType method") }, HasTerminatedFunc: func() bool { panic("mock out the HasTerminated method") }, IsRunningFunc: func() bool { panic("mock out the IsRunning method") }, ReconcileFunc: func() []error { panic("mock out the Reconcile method") }, SetIsRunningFunc: func(val bool) { panic("mock out the SetIsRunning method") }, StartFunc: func() { panic("mock out the Start method") }, StopFunc: func() { panic("mock out the Stop method") }, } // use mockedWorker in code that requires Worker // and then make assertions. }
func (*WorkerMock) GetIDCalls ¶
func (mock *WorkerMock) GetIDCalls() []struct { }
GetIDCalls gets all the calls that were made to GetID. Check the length with:
len(mockedWorker.GetIDCalls())
func (*WorkerMock) GetStopChan ¶
func (mock *WorkerMock) GetStopChan() *chan struct{}
GetStopChan calls GetStopChanFunc.
func (*WorkerMock) GetStopChanCalls ¶
func (mock *WorkerMock) GetStopChanCalls() []struct { }
GetStopChanCalls gets all the calls that were made to GetStopChan. Check the length with:
len(mockedWorker.GetStopChanCalls())
func (*WorkerMock) GetSyncGroup ¶
func (mock *WorkerMock) GetSyncGroup() *sync.WaitGroup
GetSyncGroup calls GetSyncGroupFunc.
func (*WorkerMock) GetSyncGroupCalls ¶
func (mock *WorkerMock) GetSyncGroupCalls() []struct { }
GetSyncGroupCalls gets all the calls that were made to GetSyncGroup. Check the length with:
len(mockedWorker.GetSyncGroupCalls())
func (*WorkerMock) GetWorkerType ¶
func (mock *WorkerMock) GetWorkerType() string
GetWorkerType calls GetWorkerTypeFunc.
func (*WorkerMock) GetWorkerTypeCalls ¶
func (mock *WorkerMock) GetWorkerTypeCalls() []struct { }
GetWorkerTypeCalls gets all the calls that were made to GetWorkerType. Check the length with:
len(mockedWorker.GetWorkerTypeCalls())
func (*WorkerMock) HasTerminated ¶
func (mock *WorkerMock) HasTerminated() bool
HasTerminated calls HasTerminatedFunc.
func (*WorkerMock) HasTerminatedCalls ¶
func (mock *WorkerMock) HasTerminatedCalls() []struct { }
HasTerminatedCalls gets all the calls that were made to HasTerminated. Check the length with:
len(mockedWorker.HasTerminatedCalls())
func (*WorkerMock) IsRunning ¶
func (mock *WorkerMock) IsRunning() bool
IsRunning calls IsRunningFunc.
func (*WorkerMock) IsRunningCalls ¶
func (mock *WorkerMock) IsRunningCalls() []struct { }
IsRunningCalls gets all the calls that were made to IsRunning. Check the length with:
len(mockedWorker.IsRunningCalls())
func (*WorkerMock) Reconcile ¶
func (mock *WorkerMock) Reconcile() []error
Reconcile calls ReconcileFunc.
func (*WorkerMock) ReconcileCalls ¶
func (mock *WorkerMock) ReconcileCalls() []struct { }
ReconcileCalls gets all the calls that were made to Reconcile. Check the length with:
len(mockedWorker.ReconcileCalls())
func (*WorkerMock) SetIsRunning ¶
func (mock *WorkerMock) SetIsRunning(val bool)
SetIsRunning calls SetIsRunningFunc.
func (*WorkerMock) SetIsRunningCalls ¶
func (mock *WorkerMock) SetIsRunningCalls() []struct { Val bool }
SetIsRunningCalls gets all the calls that were made to SetIsRunning. Check the length with:
len(mockedWorker.SetIsRunningCalls())
func (*WorkerMock) StartCalls ¶
func (mock *WorkerMock) StartCalls() []struct { }
StartCalls gets all the calls that were made to Start. Check the length with:
len(mockedWorker.StartCalls())
func (*WorkerMock) StopCalls ¶
func (mock *WorkerMock) StopCalls() []struct { }
StopCalls gets all the calls that were made to Stop. Check the length with:
len(mockedWorker.StopCalls())