store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SegmentsCreated = &view.View{
		Name:        "indigo-node/views/indigo/store/segments-created",
		Description: "number of segments created",
		Measure:     segmentsCreated.Measure,
		TagKeys:     []tag.Key{monitoring.ErrorTag.OCTag},
		Aggregation: view.Count(),
	}

	SegmentsReceived = &view.View{
		Name:        "indigo-node/views/indigo/store/segments-received",
		Description: "number of segments received",
		Measure:     segmentsReceived.Measure,
		TagKeys:     []tag.Key{monitoring.ErrorTag.OCTag},
		Aggregation: view.Count(),
	}

	InvalidSegments = &view.View{
		Name:        "indigo-node/views/indigo/store/segments-invalid",
		Description: "number of invalid segments received",
		Measure:     invalidSegments.Measure,
		Aggregation: view.Count(),
	}
)

Views exposed by the indigo store app.

View Source
var (
	// ErrInvalidNetworkID is returned at startup when the network is misconfigured.
	ErrInvalidNetworkID = errors.New("invalid or missing network ID")
)
View Source
var (
	ErrNetworkNotReady = errors.New("network not ready to receive messages")
)

Errors used by the NetworkManager.

View Source
var (
	// IndigoLinkProtocolID is the protocol used to share a new link between
	// network participants.
	IndigoLinkProtocolID = protocol.ID("/indigo/node/indigo/store/newlink/v1.0.0")
)

Functions

This section is empty.

Types

type Host

type Host = ihost.Host

Host represents an Indigo Node host.

type NetworkManager

type NetworkManager interface {
	// NodeID returns the ID of the node in the network.
	NodeID() peer.ID

	// Join joins a PoP network.
	Join(ctx context.Context, networkID string, host Host) error
	// Leave leaves a PoP network.
	Leave(ctx context.Context, networkID string) error

	// Publish sends a message to all the network.
	Publish(ctx context.Context, link *cs.Link) error
	// Listen to messages from the network. Cancel the context
	// to stop listening.
	Listen(ctx context.Context) error

	// AddListener adds a listeners for incoming segments.
	AddListener() <-chan *cs.Segment
	// RemoveListener removes a listener.
	RemoveListener(<-chan *cs.Segment)
}

NetworkManager provides methods to manage and join PoP networks.

func NewPrivateNetworkManager

func NewPrivateNetworkManager(streamProvider streamutil.Provider, networkCfg protector.NetworkConfigReader) NetworkManager

NewPrivateNetworkManager creates a new NetworkManager in a private network. It assumes that all network participants are interested in Indigo links and will connect to all participants to exchange links.

func NewPubSubNetworkManager

func NewPubSubNetworkManager() NetworkManager

NewPubSubNetworkManager creates a new NetworkManager that uses a PubSub mechanism to exchange messages with the network. This is particularly suited for public networks.

type PrivateNetworkManager

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

PrivateNetworkManager implements the NetworkManager interface. It directly connect to all participants of a private network.

func (*PrivateNetworkManager) AddListener

func (m *PrivateNetworkManager) AddListener() <-chan *cs.Segment

AddListener adds a listeners for incoming segments.

func (m *PrivateNetworkManager) HandleNewLink(
	ctx context.Context,
	span *monitoring.Span,
	stream inet.Stream,
	codec streamutil.Codec,
) error

HandleNewLink handles an incoming link. If the message can be decoded correctly, it's forwarded to listeners.

func (*PrivateNetworkManager) Join

func (m *PrivateNetworkManager) Join(ctx context.Context, _ string, host Host) error

Join assumes that the whole private network is part of the PoP network. It configures the host to accept Indigo message protocols.

func (*PrivateNetworkManager) Leave

Leave assumes that the whole private network is part of the PoP network. It removes Indigo-specific configuration from the host.

func (*PrivateNetworkManager) Listen

func (m *PrivateNetworkManager) Listen(ctx context.Context) error

Listen to messages from the network. Cancel the context to stop listening.

func (PrivateNetworkManager) NodeID

func (m PrivateNetworkManager) NodeID() peer.ID

NodeID returns the ID of the node in the network.

func (*PrivateNetworkManager) Publish

func (m *PrivateNetworkManager) Publish(ctx context.Context, link *cs.Link) error

Publish sends a message to all the network.

func (*PrivateNetworkManager) RemoveListener

func (m *PrivateNetworkManager) RemoveListener(c <-chan *cs.Segment)

RemoveListener removes a listener.

type PubSubNetworkManager

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

PubSubNetworkManager implements the NetworkManager interface.

func (*PubSubNetworkManager) AddListener

func (m *PubSubNetworkManager) AddListener() <-chan *cs.Segment

AddListener adds a listeners for incoming links.

func (*PubSubNetworkManager) Join

func (m *PubSubNetworkManager) Join(ctx context.Context, networkID string, host Host) (err error)

Join joins a PoP network that uses floodsub to share links. TODO: implement proper private networks / topic protection. It looks like floodsub is planning to implement authenticated topics and encryption modes (see in TopicDescriptor). It isn't implemented yet but once it is, this is what we should use.

func (*PubSubNetworkManager) Leave

func (m *PubSubNetworkManager) Leave(ctx context.Context, networkID string) (err error)

Leave unregisters from the underlying pubsub.

func (*PubSubNetworkManager) Listen

func (m *PubSubNetworkManager) Listen(ctx context.Context) error

Listen to network messages and forwards them to listeners.

func (*PubSubNetworkManager) NodeID

func (m *PubSubNetworkManager) NodeID() peer.ID

NodeID returns the base58 peerID.

func (*PubSubNetworkManager) Publish

func (m *PubSubNetworkManager) Publish(ctx context.Context, link *cs.Link) (err error)

Publish shares a message with the network.

func (*PubSubNetworkManager) RemoveListener

func (m *PubSubNetworkManager) RemoveListener(c <-chan *cs.Segment)

RemoveListener removes a listener.

type Store

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

Store implements github.com/stratumn/go-indigocore/store.Adapter.

func New

func New(
	ctx context.Context,
	networkMgr NetworkManager,
	sync sync.Engine,
	adapter store.Adapter,
	auditStore audit.Store,
	governanceManager validator.GovernanceManager,
) *Store

New creates a new Indigo store. It expects a NetworkManager connected to a PoP network.

func (*Store) AddEvidence

func (s *Store) AddEvidence(ctx context.Context, linkHash *types.Bytes32, evidence *cs.Evidence) error

AddEvidence forwards the request to the underlying store.

func (*Store) AddStoreEventChannel

func (s *Store) AddStoreEventChannel(c chan *store.Event)

AddStoreEventChannel forwards the request to the underlying store.

func (*Store) Close

func (s *Store) Close(ctx context.Context) (err error)

Close cleans up the store and stops it.

func (s *Store) CreateLink(ctx context.Context, link *cs.Link) (lh *types.Bytes32, err error)

CreateLink forwards the request to the underlying store.

func (*Store) FindSegments

func (s *Store) FindSegments(ctx context.Context, filter *store.SegmentFilter) (cs.SegmentSlice, error)

FindSegments forwards the request to the underlying store.

func (*Store) GetEvidences

func (s *Store) GetEvidences(ctx context.Context, linkHash *types.Bytes32) (*cs.Evidences, error)

GetEvidences forwards the request to the underlying store.

func (*Store) GetInfo

func (s *Store) GetInfo(ctx context.Context) (interface{}, error)

GetInfo returns information about the underlying store.

func (*Store) GetMapIDs

func (s *Store) GetMapIDs(ctx context.Context, filter *store.MapFilter) ([]string, error)

GetMapIDs forwards the request to the underlying store.

func (*Store) GetSegment

func (s *Store) GetSegment(ctx context.Context, linkHash *types.Bytes32) (*cs.Segment, error)

GetSegment forwards the request to the underlying store.

func (*Store) NewBatch

func (s *Store) NewBatch(ctx context.Context) (store.Batch, error)

NewBatch forwards the request to the underlying store.

Directories

Path Synopsis
dummyauditstore
Package dummyauditstore implements the audit.Store interface.
Package dummyauditstore implements the audit.Store interface.
mockaudit
Package mockaudit is a generated GoMock package.
Package mockaudit is a generated GoMock package.
postgresauditstore
Package postgresauditstore implements the audit.Store interface.
Package postgresauditstore implements the audit.Store interface.
storetestcases
Package storetestcases defines test cases to test audit stores.
Package storetestcases defines test cases to test audit stores.
Package mocknetworkmanager is a generated GoMock package.
Package mocknetworkmanager is a generated GoMock package.
Package mockstore is a generated GoMock package.
Package mockstore is a generated GoMock package.
Package mockvalidator is a generated GoMock package.
Package mockvalidator is a generated GoMock package.
mocksync
Package mocksync is a generated GoMock package.
Package mocksync is a generated GoMock package.

Jump to

Keyboard shortcuts

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