discovery

package
v1.0.0-preview Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: Apache-2.0 Imports: 9 Imported by: 3,688

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAliveExpirationCheckInterval

func SetAliveExpirationCheckInterval(interval time.Duration)

SetAliveExpirationCheckInterval sets the expiration check interval

func SetAliveTimeInternal

func SetAliveTimeInternal(interval time.Duration)

SetAliveTimeInternal sets the alive time interval

func SetExpirationTimeout

func SetExpirationTimeout(timeout time.Duration)

SetExpirationTimeout sets the expiration timeout

func SetReconnectInterval

func SetReconnectInterval(interval time.Duration)

SetReconnectInterval sets the reconnect interval

Types

type CommService

type CommService interface {
	// Gossip gossips a message
	Gossip(msg *proto.GossipMessage)

	// SendToPeer sends to a given peer a message.
	// The nonce can be anything since the communication module handles the nonce itself
	SendToPeer(peer *NetworkMember, msg *proto.GossipMessage)

	// Ping probes a remote peer and returns if it's responsive or not
	Ping(peer *NetworkMember) bool

	// Accept returns a read-only channel for membership messages sent from remote peers
	Accept() <-chan *proto.GossipMessage

	// PresumedDead returns a read-only channel for peers that are presumed to be dead
	PresumedDead() <-chan common.PKIidType

	// CloseConn orders to close the connection with a certain peer
	CloseConn(peer *NetworkMember)
}

CommService is an interface that the discovery expects to be implemented and passed on creation

type CryptoService

type CryptoService interface {
	// ValidateAliveMsg validates that an Alive message is authentic
	ValidateAliveMsg(*proto.GossipMessage) bool

	// SignMessage signs a message
	SignMessage(m *proto.GossipMessage) *proto.GossipMessage
}

CryptoService is an interface that the discovery expects to be implemented and passed on creation

type Discovery

type Discovery interface {

	// Self returns this instance's membership information
	Self() NetworkMember

	// UpdateMetadata updates this instance's metadata
	UpdateMetadata([]byte)

	// UpdateEndpoint updates this instance's endpoint
	UpdateEndpoint(string)

	// Stops this instance
	Stop()

	// GetMembership returns the alive members in the view
	GetMembership() []NetworkMember

	// InitiateSync makes the instance ask a given number of peers
	// for their membership information
	InitiateSync(peerNum int)

	// Connect makes this instance to connect to a remote instance
	Connect(NetworkMember)
}

Discovery is the interface that represents a discovery module

func NewDiscoveryService

func NewDiscoveryService(bootstrapPeers []string, self NetworkMember, comm CommService, crypt CryptoService) Discovery

NewDiscoveryService returns a new discovery service with the comm module passed and the crypto service passed

type NetworkMember

type NetworkMember struct {
	Endpoint string
	Metadata []byte
	PKIid    common.PKIidType
}

NetworkMember is a peer's representation

Jump to

Keyboard shortcuts

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