svc

package
v0.0.0-...-04d676d Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package svc provides definitions for services that run on the center.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCfgService

func NewCfgService(c *CfgServiceCfg) *cfgService

NewCfgService creates and initializes a new instance of cfgService.

func NewDataService

func NewDataService(c *DataServiceCfg) *dataService

NewDataService creates and initializes a new instance of dataService.

func NewStreamService

func NewStreamService(c *StreamServiceCfg) *streamService

NewStreamService creates and initializes a new instance of streamService service.

Types

type CfgServiceCfg

type CfgServiceCfg struct {
	Log       log.Logger
	Ctrl      Ctrl
	Metric    *metric.Metric
	Store     CfgStorer
	Publisher Publisher
	SubChan   <-chan *model.Cfg
}

CfgServiceCfg is used to initialize an instance of cfgService.

type CfgStorer

type CfgStorer interface {
	InitCfg(*model.Meta) (*model.Cfg, error)
	SetCfg(devID string, t model.Type, c *model.Cfg) error
	GetCfg(devID string, t model.Type) (*model.Cfg, error)
	GetDefaultCfg(devID string, t model.Type) (*model.Cfg, error)
	SetMeta(m *model.Meta) error
	IsRegistered(devID string, t model.Type) (bool, error)
}

CfgStorer is a contract for the configuration storer.

type Ctrl

type Ctrl struct {
	StopChan chan struct{}
}

Ctrl contains StopChan that allows to terminate all the services that listen to the channel.

func (*Ctrl) Terminate

func (c *Ctrl) Terminate()

Terminate closes StopChan to signal all the services to shutdown.

func (*Ctrl) Wait

func (c *Ctrl) Wait(t time.Duration)

Wait waits until StopChan will be closed and then makes a pause for the amount seconds defined in variable timeForRoutineTermination in order to give time for all the services to shutdown gracefully.

type DataPublisher

type DataPublisher interface {
	Publish(msg interface{}, channel string) (int64, error)
}

Publisher .

type DataServiceCfg

type DataServiceCfg struct {
	Log     log.Logger
	Ctrl    Ctrl
	Metric  *metric.Metric
	Store   DataStorer
	PubChan chan<- *model.Data
}

DataServiceCfg is used to initialize an instance of dataService.

type DataStorer

type DataStorer interface {
	GetDevsData() ([]model.Data, error)
	GetDevData(devID string) (*model.Data, error)
	SaveData(*model.Data) error
}

DataStorer is a contract for the data storer.

type Publisher

type Publisher interface {
	Publish(devID, data string) error
}

Publisher .

type StreamServiceCfg

type StreamServiceCfg struct {
	Log                log.Logger
	Ctrl               Ctrl
	Metric             *metric.Metric
	SubChan            <-chan *model.Data
	PortWS             uint32
	TerminationTimeout time.Duration
}

StreamServiceCfg is used to initialize an instance of streamService.

Directories

Path Synopsis
Package mock_svc is a generated GoMock package.
Package mock_svc is a generated GoMock package.

Jump to

Keyboard shortcuts

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