node

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatadirUsed    = errors.New("datadir already used by another process")
	ErrNodeStopped    = errors.New("node not started")
	ErrNodeRunning    = errors.New("node already running")
	ErrServiceUnknown = errors.New("unknown service")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// ChainId is network id. Builtins are "main", "test" and "dev".
	// Nodes with different chain id can't talk with each other.
	ChainId string `toml:",omitempty"`

	// Name refers the name of node's instance
	Name string

	// MinDiskSpaceInGB refers the minimum disk space requirement in GB
	MinDiskSpaceInGB int

	// Version should be set to the version number of the program.
	Version string `toml:"-"`

	// DataDir is the root folder that store data and service-configs
	DataDir string `toml:",omitempty"`

	// HTTPHost is the host interface on which to start the HTTP RPC server.
	HTTPHost string `toml:",omitempty"`

	// HTTPPort is the TCP port number on which to start the HTTP RPC server.
	HTTPPort int `toml:",omitempty"`

	LogLevel string `toml:",omitempty"`

	GRPC service_configs.GRPCConfig

	Consensus service_configs.ConsensusConfig

	P2P service_configs.P2PConfig

	HealthCheck service_configs.HCheck

	Database *service_configs.DatabaseConfig
}

func (*Config) NodeDB

func (c *Config) NodeDB() string

DB returns the path to the discovery database.

func (*Config) NodeName

func (c *Config) NodeName() string

GetName returns the node's complete name

func (*Config) ResolvePath

func (c *Config) ResolvePath(path string) string

ResolvePath resolves path in the instance directory.

type DuplicateServiceError

type DuplicateServiceError struct {
	//Kind reflect.Type
	Kind string
}

func (*DuplicateServiceError) Error

func (e *DuplicateServiceError) Error() string

type NamedServiceConstructor

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

type Node

type Node struct {
	MainLoop *eventloop.EventLoop
	EvBus    EventBus.Bus

	//log log.Logger
	Log *logrus.Logger

	StartArgs map[string]interface{}
	// contains filtered or unexported fields
}

Node is a container and manager of services

func New

func New(conf *Config) (*Node, error)

func (*Node) Register

func (n *Node) Register(name string, constructor ServiceConstructor) error

func (*Node) Restart

func (n *Node) Restart() error

func (*Node) Service

func (n *Node) Service(serviceName string) (interface{}, error)

func (*Node) Start

func (n *Node) Start() error

func (*Node) StartWithArgs added in v1.0.8

func (n *Node) StartWithArgs(args map[string]interface{}) error

func (*Node) Stop

func (n *Node) Stop() error

func (*Node) Wait

func (n *Node) Wait()

type Service

type Service interface {
	Start(node *Node) error

	// stop all goroutines belonging to the service,
	// blocking until all of them are terminated.
	Stop() error
}

type ServiceConstructor

type ServiceConstructor func(ctx *ServiceContext) (Service, error)

type ServiceContext

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

func (*ServiceContext) ChainId added in v1.0.2

func (ctx *ServiceContext) ChainId() prototype.ChainId

func (*ServiceContext) Config

func (ctx *ServiceContext) Config() Config

func (*ServiceContext) ResetConfig added in v1.0.2

func (ctx *ServiceContext) ResetConfig(cfg *Config)

func (*ServiceContext) ResetServices added in v1.0.2

func (ctx *ServiceContext) ResetServices(s map[string]Service)

func (*ServiceContext) ResolvePath

func (ctx *ServiceContext) ResolvePath(path string) string

func (*ServiceContext) Service

func (ctx *ServiceContext) Service(name string) (interface{}, error)

func (*ServiceContext) UpdateChainId added in v1.0.2

func (ctx *ServiceContext) UpdateChainId()

type StopError

type StopError struct {
	Server   error
	Services map[string]error
}

StopError is returned if a Node fails to stop either any of its registered services or itself.

type StopError struct {
	Server   error
	Services map[reflect.Type]error
}

func (*StopError) Error

func (e *StopError) Error() string

Error generates a textual representation of the stop error.

Jump to

Keyboard shortcuts

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