service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package service defines the bootstrap service implementation.

Index

Constants

View Source
const (
	InMemoryStore = "in-memory"
	FileStore     = "file"
)

Types of store supported.

View Source
const (
	DefaultStorePath = "data/network/proposals.json"
)

Default config values.

View Source
const (
	// ServiceID used by the bootstrap service.
	ServiceID = "bootstrap"
)

Variables

View Source
var (
	// ErrNotEnoughPeers is returned when not enough peers are connected.
	ErrNotEnoughPeers = errors.New("number of connected peers is under configuration threshold")

	// ErrUnavailable is returned from gRPC methods when the service is not
	// available.
	ErrUnavailable = errors.New("the service is not available")

	// ErrNotAllowed is return from gRPC methods when the command is not allowed
	// in the current configuration.
	ErrNotAllowed = errors.New("operation not allowed")
)
View Source
var (
	ErrNotHost          = errors.New("connected service is not a host")
	ErrNotSwarm         = errors.New("connected service is not a swarm")
	ErrInvalidStoreType = errors.New("invalid store type")
)

Configuration errors.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host is the name of the host service.
	Host string `toml:"host" comment:"The name of the host service."`

	// Swarm is the name of the swarm service.
	Swarm string `toml:"swarm" comment:"The name of the swarm service."`

	// Needs are services that should be started in addition to the host
	// before bootstrapping.
	Needs []string `toml:"needs" comment:"Services that should be started in addition to the host before bootstrapping."`

	// Addresses is a list of known peer addresses.
	Addresses []string `toml:"addresses" comment:"A list of known peer addresses."`

	// MinPeerThreshold is the number of peers under which to bootstrap
	// connections.
	MinPeerThreshold int `toml:"min_peer_threshold" comment:"The number of peers under which to bootstrap connections."`

	// Interval is the duration of the interval between bootstrap jobs.
	Interval string `toml:"interval" comment:"Interval between bootstrap jobs."`

	// ConnectionTimeout is the connection timeout. It should be less than
	// the interval.
	ConnectionTimeout string `toml:"connection_timeout" comment:"The connection timeout. It should be less than the interval."`

	// StoreConfig configures the store used for network update proposals.
	StoreConfig *StoreConfig `toml:"store_config" comment:"Configure the store used for network update proposals."`
}

Config contains configuration options for the Bootstrap service.

func (*Config) NewStore

func (c *Config) NewStore(ctx context.Context) (proposal.Store, error)

NewStore configures a store for network update proposals.

type Host

type Host ihost.Host

Host represents a Stratumn Node host.

type Service

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

Service is the Bootstrap service.

func (*Service) AddToGRPCServer

func (s *Service) AddToGRPCServer(gs *grpc.Server)

AddToGRPCServer adds the service to a gRPC server.

func (*Service) Config

func (s *Service) Config() interface{}

Config returns the current service configuration or creates one with good default values.

func (*Service) Desc

func (s *Service) Desc() string

Desc returns a description of what the service does.

func (*Service) Expose

func (s *Service) Expose() interface{}

Expose exposes an empty struct, so that other services know it is ready.

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

func (*Service) Name

func (s *Service) Name() string

Name returns the human friendly name of the service.

func (*Service) Needs

func (s *Service) Needs() map[string]struct{}

Needs returns the set of services this service depends on.

func (*Service) Plug

func (s *Service) Plug(exposed map[string]interface{}) error

Plug sets the connected services.

func (*Service) Run

func (s *Service) Run(ctx context.Context, running, stopping func()) error

Run starts the service.

func (*Service) SetConfig

func (s *Service) SetConfig(config interface{}) error

SetConfig configures the service.

type StoreConfig

type StoreConfig struct {
	// Type is the type of store used.
	Type string `toml:"type" comment:"Type of store to use.\n Supported values: in-memory and file."`

	// Path to the store files (when applicable).
	Path string `toml:"path" comment:"Path to the store files (when applicable)."`
}

StoreConfig configures the store used for network update proposals.

Directories

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

Jump to

Keyboard shortcuts

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