service

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WaitForStatusUpdate is the delay time to update new status. Currently set 1 second for development. Should be 30 minutes for production.
	WaitForStatusUpdate = time.Minute * 1
)

Constants for timing.

Variables

View Source
var (
	GroupIDShards       map[nodeconfig.ShardID]nodeconfig.GroupID
	GroupIDShardClients map[nodeconfig.ShardID]nodeconfig.GroupID
)

GroupIDShards is a map of ShardGroupID ID key is the shard ID value is the corresponding group ID

Functions

This section is empty.

Types

type Action

type Action struct {
	Action      ActionType
	ServiceType Type
	Params      map[string]interface{}
}

Action is type of service action.

type ActionType

type ActionType byte

ActionType is the input for Service Manager to operate.

const (
	Start ActionType = iota
	Stop
	Notify
)

Constants for Action Type.

type Interface

type Interface interface {
	StartService()
	SetMessageChan(msgChan chan *msg_pb.Message)
	StopService()
	NotifyService(map[string]interface{})

	// APIs retrieves the list of RPC descriptors the service provides
	APIs() []rpc.API
}

Interface is the collection of functions any service needs to implement.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager stores all services for service manager.

func (*Manager) GetServices

func (m *Manager) GetServices() map[Type]Interface

GetServices returns all registered services.

func (*Manager) InitServiceMap

func (m *Manager) InitServiceMap()

InitServiceMap initializes service map.

func (*Manager) Register

func (m *Manager) Register(t Type, service Interface)

Register registers new service to service store.

func (*Manager) RegisterService

func (m *Manager) RegisterService(t Type, service Interface)

RegisterService is used for testing.

func (*Manager) RunServices

func (m *Manager) RunServices()

RunServices run registered services.

func (*Manager) SendAction

func (m *Manager) SendAction(action *Action)

SendAction sends action to action channel which is observed by service manager.

func (*Manager) SetupServiceManager

func (m *Manager) SetupServiceManager()

SetupServiceManager inits service map and start service manager.

func (*Manager) SetupServiceMessageChan

func (m *Manager) SetupServiceMessageChan(mapServiceTypeChan map[Type]chan *msg_pb.Message)

SetupServiceMessageChan sets up message channel to services.

func (*Manager) StartServiceManager

func (m *Manager) StartServiceManager() chan *Action

StartServiceManager starts service manager.

func (*Manager) StopService

func (m *Manager) StopService(t Type)

StopService stops service with type t.

func (*Manager) StopServicesByRole

func (m *Manager) StopServicesByRole(liveServices []Type)

StopServicesByRole stops all service of the given role.

func (*Manager) TakeAction

func (m *Manager) TakeAction(action *Action)

TakeAction is how service manager handles the action.

type NodeConfig

type NodeConfig struct {
	// The three groupID design, please refer to https://github.com/harmony-one/harmony/blob/master/node/node.md#libp2p-integration
	Beacon          nodeconfig.GroupID                           // the beacon group ID
	ShardGroupID    nodeconfig.GroupID                           // the group ID of the shard
	Client          nodeconfig.GroupID                           // the client group ID of the shard
	IsClient        bool                                         // whether this node is a client node, such as wallet/txgen
	IsBeacon        bool                                         // whether this node is a beacon node or not
	ShardID         uint32                                       // shardID of this node
	Actions         map[nodeconfig.GroupID]nodeconfig.ActionType // actions on the groups
	PushgatewayIP   string                                       // prometheus pushgateway ip
	PushgatewayPort string                                       // prometheus pushgateway port
	MetricsFlag     bool                                         // flag to collect metrics or not
}

NodeConfig defines a structure of node configuration that can be used in services. This is to pass node configuration to services and prvent cyclic imports

type Type

type Type byte

Type is service type.

const (
	SupportSyncing Type = iota
	ClientSupport
	SupportExplorer
	Consensus
	Metrics
	Randomness
	BlockProposal
	NetworkInfo
	PeerDiscovery
	Resharding
	Staking
	Test
	Done
)

Constants for Type.

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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