replication

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPeerDoesNotSupportEBT = errors.New("peer does not support ebt")

Functions

This section is empty.

Types

type Contact

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

func MustNewContact

func MustNewContact(who refs.Feed, hops graph.Hops, feedState FeedState) Contact

func NewContact

func NewContact(who refs.Feed, hops graph.Hops, feedState FeedState) (Contact, error)

func (Contact) FeedState

func (c Contact) FeedState() FeedState

func (Contact) Hops

func (c Contact) Hops() graph.Hops

func (Contact) IsZero

func (c Contact) IsZero() bool

func (Contact) Who

func (c Contact) Who() refs.Feed

type ContactsStorage

type ContactsStorage interface {
	// GetContacts returns a list of contacts. Contacts are sorted by hops,
	// ascending. Contacts include the local feed.
	GetContacts(peer identity.Public) ([]Contact, error)
}

type CreateHistoryStreamReplicator

type CreateHistoryStreamReplicator interface {
	// Replicate should keep attempting to perform replication as long as the
	// context isn't closed. Returning an error implies that replication should
	// not restart.
	Replicate(ctx context.Context, peer transport.Peer) error
}

type EpidemicBroadcastTreesReplicator

type EpidemicBroadcastTreesReplicator interface {
	// Replicate should keep attempting to perform replication as long as the
	// context isn't closed. Returning an error implies that replication should
	// not restart. Returns ErrPeerDoesNotSupportEBT if the peer doesn't support
	// EBT replication.
	Replicate(ctx context.Context, peer transport.Peer) error
}

type FeedState

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

FeedState wraps the sequence number so that both the state of feeds which have some messages in them and empty feeds can be represented.

func MustNewFeedState

func MustNewFeedState(sequence message.Sequence) FeedState

func NewEmptyFeedState

func NewEmptyFeedState() FeedState

NewEmptyFeedState creates a new feed state which represents an empty feed. This is equivalent to the zero value of this type but using this constructor improves readability.

func NewFeedState

func NewFeedState(sequence message.Sequence) (FeedState, error)

NewFeedState creates a new feed state which represents a feed for which at least one message is known.

func (FeedState) Sequence

func (s FeedState) Sequence() (message.Sequence, bool)

Sequence returns the sequence of the last message in the feed. If the feed is empty then the sequence is not returned.

func (FeedState) String

func (s FeedState) String() string

String is useful for printing this value when logging or debugging. Do not use it for other purposes.

type Negotiator

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

func NewNegotiator

func NewNegotiator(
	logger logging.Logger,
	ebtReplicator EpidemicBroadcastTreesReplicator,
	chsReplicator CreateHistoryStreamReplicator,
) *Negotiator

func (Negotiator) Replicate

func (n Negotiator) Replicate(ctx context.Context, peer transport.Peer) error

type RawMessageHandler

type RawMessageHandler interface {
	Handle(replicatedFrom identity.Public, msg message.RawMessage) error
}

type WantedFeed

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

func MustNewWantedFeed

func MustNewWantedFeed(who refs.Feed, feedState FeedState) WantedFeed

func NewWantedFeed

func NewWantedFeed(who refs.Feed, feedState FeedState) (WantedFeed, error)

func (WantedFeed) FeedState

func (w WantedFeed) FeedState() FeedState

func (WantedFeed) IsZero

func (w WantedFeed) IsZero() bool

func (WantedFeed) Who

func (w WantedFeed) Who() refs.Feed

type WantedFeeds

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

WantedFeeds contains contacts and other wanted feeds. Contacts are sorted by hops, ascending. Contacts include the local feed. Other feeds include other feeds which should be replicated. Other feeds may include the same feeds.

func MustNewWantedFeeds

func MustNewWantedFeeds(contacts []Contact, otherFeeds []WantedFeed) WantedFeeds

func NewWantedFeeds

func NewWantedFeeds(contacts []Contact, otherFeeds []WantedFeed) (WantedFeeds, error)

func (WantedFeeds) Contacts

func (w WantedFeeds) Contacts() []Contact

func (WantedFeeds) OtherFeeds

func (w WantedFeeds) OtherFeeds() []WantedFeed

type WantedFeedsCache

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

func NewWantedFeedsCache

func NewWantedFeedsCache(provider WantedFeedsProvider) *WantedFeedsCache

func (*WantedFeedsCache) AddForkedFeed

func (c *WantedFeedsCache) AddForkedFeed(replicatedFrom identity.Public, feed refs.Feed)

func (*WantedFeedsCache) GetContacts

func (c *WantedFeedsCache) GetContacts(peer identity.Public) ([]Contact, error)

type WantedFeedsProvider

type WantedFeedsProvider interface {
	GetWantedFeeds() (WantedFeeds, error)
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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