Documentation
¶
Index ¶
- Variables
- type CommonDiscoveryService
- func (sp *CommonDiscoveryService) Context() context.Context
- func (sp *CommonDiscoveryService) ErrOnNotRunning() error
- func (sp *CommonDiscoveryService) GetListeningChan() <-chan PeerData
- func (sp *CommonDiscoveryService) PushToChan(data PeerData) bool
- func (sp *CommonDiscoveryService) RLock()
- func (sp *CommonDiscoveryService) RUnlock()
- func (sp *CommonDiscoveryService) Start(ctx context.Context, fn func() error) error
- func (sp *CommonDiscoveryService) Stop(stopFn func())
- func (sp *CommonDiscoveryService) WaitGroup() *sync.WaitGroup
- type CommonService
- type PeerData
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAlreadyStarted = errors.New("already started")
View Source
var ErrNotStarted = errors.New("not started")
Functions ¶
This section is empty.
Types ¶
type CommonDiscoveryService ¶
type CommonDiscoveryService struct {
// contains filtered or unexported fields
}
func NewCommonDiscoveryService ¶
func NewCommonDiscoveryService() *CommonDiscoveryService
func (*CommonDiscoveryService) Context ¶
func (sp *CommonDiscoveryService) Context() context.Context
func (*CommonDiscoveryService) ErrOnNotRunning ¶
func (sp *CommonDiscoveryService) ErrOnNotRunning() error
func (*CommonDiscoveryService) GetListeningChan ¶
func (sp *CommonDiscoveryService) GetListeningChan() <-chan PeerData
func (*CommonDiscoveryService) PushToChan ¶
func (sp *CommonDiscoveryService) PushToChan(data PeerData) bool
func (*CommonDiscoveryService) RLock ¶
func (sp *CommonDiscoveryService) RLock()
func (*CommonDiscoveryService) RUnlock ¶
func (sp *CommonDiscoveryService) RUnlock()
func (*CommonDiscoveryService) Start ¶
func (sp *CommonDiscoveryService) Start(ctx context.Context, fn func() error) error
func (*CommonDiscoveryService) Stop ¶
func (sp *CommonDiscoveryService) Stop(stopFn func())
func (*CommonDiscoveryService) WaitGroup ¶
func (sp *CommonDiscoveryService) WaitGroup() *sync.WaitGroup
type CommonService ¶
this is common layout for all the services that require mutex protection and a guarantee that all running goroutines will be finished before stop finishes execution. This guarantee comes from waitGroup all one has to use CommonService.WaitGroup() in the goroutines that should finish by the end of stop function.
func NewCommonService ¶
func NewCommonService() *CommonService
func (*CommonService) Context ¶
func (sp *CommonService) Context() context.Context
func (*CommonService) ErrOnNotRunning ¶
func (sp *CommonService) ErrOnNotRunning() error
This is not a mutex protected function, it is up to the caller to use it in a mutex protected context
func (*CommonService) Start ¶
func (sp *CommonService) Start(ctx context.Context, fn func() error) error
mutex protected start function creates internal context over provided context and runs fn safely fn is excerpt to be executed to start the protocol
func (*CommonService) WaitGroup ¶
func (sp *CommonService) WaitGroup() *sync.WaitGroup
Click to show internal directories.
Click to hide internal directories.