service

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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

type CommonService struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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) Stop

func (sp *CommonService) Stop(fn func())

mutex protected stop function

func (*CommonService) WaitGroup

func (sp *CommonService) WaitGroup() *sync.WaitGroup

type PeerData

type PeerData struct {
	Origin       wps.Origin
	AddrInfo     peer.AddrInfo
	ENR          *enode.Node
	PubsubTopics []string
}

PeerData contains information about a peer useful in establishing connections with it.

Jump to

Keyboard shortcuts

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