Documentation ¶
Overview ¶
Package service defines a service that maintains a swarm of connections between this node and its peers.
Index ¶
- Constants
- Variables
- type Config
- type CoordinatorConfig
- type ProtectorConfig
- type Service
- func (s *Service) AddToGRPCServer(gs *grpc.Server)
- func (s *Service) Config() interface{}
- func (s *Service) Desc() string
- func (s *Service) Expose() interface{}
- func (s *Service) ID() string
- func (s *Service) Name() string
- func (s *Service) Needs() map[string]struct{}
- func (s *Service) Plug(exposed map[string]interface{}) error
- func (s *Service) Run(ctx context.Context, running, stopping func()) (err error)
- func (s *Service) SetConfig(config interface{}) error
- type Swarm
- type Transport
Constants ¶
const (
// ServiceID used by the swarm service.
ServiceID = "swarm"
)
Variables ¶
var ( ErrInvalidProtectionMode = errors.New("invalid network protection mode") ErrInvalidCoordinatorConfig = errors.New("invalid network coordinator config") )
Configuration errors.
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.
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") // 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 ¶
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) 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
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.