Documentation ¶
Index ¶
- type AdaptersMap
- type BaseHandler
- type BaseHandlerInterface
- type BaseWorker
- func (w *BaseWorker) CloseAdapters() error
- func (w *BaseWorker) GetName() string
- func (w *BaseWorker) IsMonitoringEnable() bool
- func (w *BaseWorker) SetAdapter(adap adapter.AdapterInterface)
- func (w *BaseWorker) SetMicroserviceName(name string)
- func (w *BaseWorker) SetMonitoring(enabled bool)
- func (w *BaseWorker) SetName(name string)
- func (w *BaseWorker) SetupAdapters() error
- type WorkerAdapters
- type WorkerInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdaptersMap ¶ added in v0.2.2
type AdaptersMap map[string]adapter.AdapterInterface
type BaseHandler ¶ added in v0.3.1
type BaseHandler struct { Logger *logrus.Entry Adapters *WorkerAdapters }
func (*BaseHandler) Handle ¶ added in v0.3.1
func (h *BaseHandler) Handle() error
func (*BaseHandler) SetAdapters ¶ added in v0.3.1
func (h *BaseHandler) SetAdapters(a *WorkerAdapters)
func (*BaseHandler) SetLogger ¶ added in v0.3.1
func (h *BaseHandler) SetLogger(l *logrus.Entry)
type BaseHandlerInterface ¶ added in v0.3.1
type BaseHandlerInterface interface { Handle() error SetLogger(l *logrus.Entry) SetAdapters(a *WorkerAdapters) }
type BaseWorker ¶ added in v0.2.2
type BaseWorker struct { Logger *logrus.Entry Adapters *WorkerAdapters // contains filtered or unexported fields }
Worker structure contains an adapter list and implements functions to control adapters. All new workers must inherit BaseWorker and implement only Setup(), Run() and Stop() functions from WorkerInterface.
func NewBaseWorker ¶ added in v0.2.2
func NewBaseWorker(name string) *BaseWorker
Function allocates BaseWorker structure with JSON logger and an empty (but not nil!) adapter list.
func (*BaseWorker) CloseAdapters ¶ added in v0.2.2
func (w *BaseWorker) CloseAdapters() error
Function clears all adapters and is used in the main framework loop.
func (*BaseWorker) GetName ¶ added in v0.2.2
func (w *BaseWorker) GetName() string
Get current worker name.
func (*BaseWorker) IsMonitoringEnable ¶ added in v0.2.8
func (w *BaseWorker) IsMonitoringEnable() bool
Function returns monitoring status.
func (*BaseWorker) SetAdapter ¶ added in v0.2.2
func (w *BaseWorker) SetAdapter(adap adapter.AdapterInterface)
Function appends an adapter to the worker's adapter list. If the adapter with the same name is already registred the first one will be overwritten by the new one.
func (*BaseWorker) SetMicroserviceName ¶ added in v0.3.1
func (w *BaseWorker) SetMicroserviceName(name string)
Set current worker name.
func (*BaseWorker) SetMonitoring ¶ added in v0.2.8
func (w *BaseWorker) SetMonitoring(enabled bool)
Function enables or disables pushing metrics to the prometheus.
func (*BaseWorker) SetName ¶ added in v0.2.2
func (w *BaseWorker) SetName(name string)
Set current worker name.
func (*BaseWorker) SetupAdapters ¶ added in v0.2.2
func (w *BaseWorker) SetupAdapters() error
Function setups all adapters and is used in the main framework loop.
type WorkerAdapters ¶ added in v0.2.2
type WorkerAdapters struct {
// contains filtered or unexported fields
}
Structure holds adapter map.
func NewWorkerAdapters ¶ added in v0.2.2
func NewWorkerAdapters() *WorkerAdapters
Function allocates WorkerAdapters structure with an empty (but not nil!) adapter list.
func (*WorkerAdapters) CloseAdapters ¶ added in v0.2.2
func (w *WorkerAdapters) CloseAdapters() (err error)
Function clears all adapters and is used in the main framework loop.
func (*WorkerAdapters) Get ¶ added in v0.2.2
func (w *WorkerAdapters) Get(name string) (adapter.AdapterInterface, error)
Function receives an adapter interface that can be converted to a particular adapter structure.
func (*WorkerAdapters) SetAdapter ¶ added in v0.2.2
func (w *WorkerAdapters) SetAdapter(adapter adapter.AdapterInterface)
Function appends an adapter to the worker's adapter list. If the adapter with the same name is already registred the first one will be overwritten by the new one.
func (*WorkerAdapters) SetupAdapters ¶ added in v0.2.2
func (w *WorkerAdapters) SetupAdapters() (err error)
Function setups all adapters and is used in the main framework loop.
type WorkerInterface ¶
type WorkerInterface interface { GetName() string SetName(string) SetMicroserviceName(string) SetAdapter(adapter.AdapterInterface) SetupAdapters() error CloseAdapters() error Setup() Run() Stop() SetMonitoring(enabled bool) IsMonitoringEnable() bool }
Interface implements basic worker functions. All new workers must inherit BaseWorker structure and implement only Setup(), Run() and Stop() functions.