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: 23 Imported by: 0

Documentation

Overview

Package service defines a service that maintains a swarm of connections between this node and its peers.

Index

Constants

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

Variables

View Source
var (
	ErrInvalidProtectionMode    = errors.New("invalid network protection mode")
	ErrInvalidCoordinatorConfig = errors.New("invalid network coordinator config")
)

Configuration errors.

View Source
var (
	Connections = &view.View{
		Name:        "stratumn-node/views/connections",
		Description: "open connections",
		Measure:     connections.Measure,
		Aggregation: view.LastValue(),
	}

	Peers = &view.View{
		Name:        "stratumn-node/views/peers",
		Description: "connected peers",
		Measure:     peers.Measure,
		Aggregation: view.LastValue(),
	}

	Latency = &view.View{
		Name:        "stratumn-node/views/latency",
		Description: "peer latency distribution",
		Measure:     latency.Measure,
		TagKeys:     []tag.Key{monitoring.PeerIDTag.OCTag},
		Aggregation: monitoring.DefaultLatencyDistribution,
	}
)

Views exposed by the swarm network layer.

View Source
var (
	// ErrPeerIDMismatch is returned when the peer ID does not match the
	// private key.
	ErrPeerIDMismatch = errors.New("the peer ID does not match the private key")

	// ErrNotStreamMuxer is returned when a specified service is not a
	// stream muxer.
	ErrNotStreamMuxer = errors.New("connected service is not a stream muxer")

	// ErrNotMonitoring is returned when a specified service is not a monitoring.
	ErrNotMonitoring = errors.New("connected service is not a monitoring")

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

Functions

This section is empty.

Types

type Config

type Config struct {
	// PeerID is the peer ID of the node.
	PeerID string `toml:"peer_id" comment:"The peer ID of the host."`

	// PrivateKey is the private key of the node.
	PrivateKey string `toml:"private_key" comment:"The private key of the host."`

	// Addresses are the list of addresses to bind to.
	Addresses []string `toml:"addresses" comment:"List of addresses to bind to."`

	// StreamMuxer is the name of the stream muxer service.
	StreamMuxer string `toml:"stream_muxer" comment:"The name of the stream muxer service."`

	// Monitoring is the name of the monitoring service.
	Monitoring string `toml:"monitoring" comment:"The name of the monitoring service."`

	// ProtectionMode describes the network protection mode.
	ProtectionMode string `toml:"protection_mode" comment:"Protection mode for private network (blank = disabled)."`

	// CoordinatorConfig contains configuration options for the network coordinator (if enabled).
	CoordinatorConfig *CoordinatorConfig `toml:"coordinator" comment:"Configure settings for the network coordinator in the following section."`
}

Config contains configuration options for the Swarm service.

func (Config) ParseNetworkMode

func (c Config) ParseNetworkMode() (*protector.NetworkMode, error)

ParseNetworkMode parses network mode details from the configuration.

type CoordinatorConfig

type CoordinatorConfig struct {
	// IsCoordinator is true when the node is the coordinator of a private network.
	IsCoordinator bool `toml:"is_coordinator" comment:"True if we are the coordinator node."`

	// CoordinatorID is the peer ID of the coordinator node.
	CoordinatorID string `toml:"coordinator_id" comment:"The peer ID of the coordinator."`

	// CoordinatorAddresses is the list of addresses of the coordinator node.
	CoordinatorAddresses []string `toml:"coordinator_addresses" comment:"Coordinator addresses."`

	// Path to the signed network configuration file.
	ConfigPath string `toml:"config_path" comment:"Path to the signed network configuration file."`
}

CoordinatorConfig contains configuration options for the network coordinator (if enabled).

type ProtectorConfig

type ProtectorConfig interface {
	Configure(context.Context, *Service, peerstore.Peerstore) (ipnet.Protector, protector.NetworkConfig, error)
}

ProtectorConfig configures the right protector for the swarm service.

func NewProtectorConfig

func NewProtectorConfig(config *Config) (ProtectorConfig, error)

NewProtectorConfig returns the right protector configuration depending on the network parameters.

type Service

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

Service is the Swarm 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.

It can panic but it can only happen during `stratumn-node init`.

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 the swarm to other services.

It exposes the type:

github.com/stratumn/go-node/core/service/*swarm.Swarm

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()) (err error)

Run starts the service.

func (*Service) SetConfig

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

SetConfig configures the service.

type Swarm

type Swarm struct {
	NetworkConfig protector.NetworkConfig
	NetworkMode   *protector.NetworkMode
	Swarm         *swarm.Swarm
}

Swarm wraps a swarm with other data that could be useful to services. It's the type exposed by the swarm service.

type Transport

type Transport = smux.Transport

Transport represents a transport.

Jump to

Keyboard shortcuts

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