ebt

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: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeedRequester

type FeedRequester interface {
	Request(ctx context.Context, ref refs.Feed, seq *message.Sequence)
	Cancel(ref refs.Feed)
}

type IncomingMessage

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

func NewIncomingMessageWithErr

func NewIncomingMessageWithErr(err error) IncomingMessage

func NewIncomingMessageWithMessage

func NewIncomingMessageWithMessage(msg message.RawMessage) IncomingMessage

func NewIncomingMessageWithNotes

func NewIncomingMessageWithNotes(notes messages.EbtReplicateNotes) IncomingMessage

func (IncomingMessage) Err

func (i IncomingMessage) Err() error

func (IncomingMessage) Msg

func (IncomingMessage) Notes

type IncomingStreamAdapter

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

func NewIncomingStreamAdapter

func NewIncomingStreamAdapter(remoteIdentity identity.Public, stream mux.Stream) IncomingStreamAdapter

func (IncomingStreamAdapter) IncomingMessages

func (s IncomingStreamAdapter) IncomingMessages(ctx context.Context) <-chan IncomingMessage

func (IncomingStreamAdapter) RemoteIdentity

func (s IncomingStreamAdapter) RemoteIdentity() identity.Public

func (IncomingStreamAdapter) SendMessage

func (s IncomingStreamAdapter) SendMessage(msg *message.Message) error

func (IncomingStreamAdapter) SendNotes

type MessageStreamer

type MessageStreamer interface {
	Handle(ctx context.Context, id refs.Feed, seq *message.Sequence, messageWriter MessageWriter)
}

type MessageWriter

type MessageWriter interface {
	WriteMessage(msg message.Message) error
}

type OutgoingStreamAdapter

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

func NewOutgoingStreamAdapter

func NewOutgoingStreamAdapter(remoteIdentity identity.Public, stream rpc.ResponseStream) *OutgoingStreamAdapter

func (*OutgoingStreamAdapter) IncomingMessages

func (r *OutgoingStreamAdapter) IncomingMessages(ctx context.Context) <-chan IncomingMessage

func (*OutgoingStreamAdapter) RemoteIdentity

func (r *OutgoingStreamAdapter) RemoteIdentity() identity.Public

func (*OutgoingStreamAdapter) SendMessage

func (r *OutgoingStreamAdapter) SendMessage(msg *message.Message) error

func (*OutgoingStreamAdapter) SendNotes

type Replicator

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

func NewReplicator

func NewReplicator(
	tracker Tracker,
	runner Runner,
	selfCreateHistoryStreamReplicator SelfCreateHistoryStreamReplicator,
	logger logging.Logger,
) Replicator

func (Replicator) HandleIncoming

func (r Replicator) HandleIncoming(ctx context.Context, version int, format messages.EbtReplicateFormat, stream Stream) error

func (Replicator) Replicate

func (r Replicator) Replicate(ctx context.Context, peer transport.Peer) error

type RequestedFeeds

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

func NewRequestedFeeds

func NewRequestedFeeds(messageStreamer MessageStreamer, stream Stream) *RequestedFeeds

func (*RequestedFeeds) Cancel

func (r *RequestedFeeds) Cancel(ref refs.Feed)

func (*RequestedFeeds) Request

func (r *RequestedFeeds) Request(ctx context.Context, ref refs.Feed, seq *message.Sequence)

type Runner

type Runner interface {
	HandleStream(ctx context.Context, stream Stream) error
}

type SelfCreateHistoryStreamReplicator

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

type SentNotes

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

func NewSentNotes

func NewSentNotes() *SentNotes

func (*SentNotes) Update

func (w *SentNotes) Update(contacts []replication.Contact) (messages.EbtReplicateNotes, error)

type Session

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

func NewSession

func NewSession(
	ctx context.Context,
	stream Stream,
	logger logging.Logger,
	rawMessageHandler replication.RawMessageHandler,
	contactsStorage replication.ContactsStorage,
	feedRequester FeedRequester,
) *Session

func (*Session) HandleIncomingMessagesLoop

func (s *Session) HandleIncomingMessagesLoop() error

func (*Session) SendNotes

func (s *Session) SendNotes() error

func (*Session) SendNotesLoop

func (s *Session) SendNotesLoop()

type SessionEndedFn

type SessionEndedFn func()

type SessionRunner

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

func NewSessionRunner

func NewSessionRunner(
	logger logging.Logger,
	rawMessageHandler replication.RawMessageHandler,
	contactsStorage replication.ContactsStorage,
	streamer MessageStreamer,
) *SessionRunner

func (*SessionRunner) HandleStream

func (s *SessionRunner) HandleStream(ctx context.Context, stream Stream) error

type SessionTracker

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

func NewSessionTracker

func NewSessionTracker() *SessionTracker

func (*SessionTracker) OpenSession

func (t *SessionTracker) OpenSession(id rpc.ConnectionId) (SessionEndedFn, error)

func (*SessionTracker) SomeoneIsWaiting

func (t *SessionTracker) SomeoneIsWaiting(id rpc.ConnectionId) bool

func (*SessionTracker) WaitForSession

func (t *SessionTracker) WaitForSession(ctx context.Context, id rpc.ConnectionId, waitTime time.Duration) (bool, error)

type Stream

type Stream interface {
	RemoteIdentity() identity.Public
	IncomingMessages(ctx context.Context) <-chan IncomingMessage
	SendNotes(notes messages.EbtReplicateNotes) error
	SendMessage(msg *message.Message) error
}

type StreamMessageWriter

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

func NewStreamMessageWriter

func NewStreamMessageWriter(stream Stream) *StreamMessageWriter

func (StreamMessageWriter) WriteMessage

func (s StreamMessageWriter) WriteMessage(msg message.Message) error

type Tracker

type Tracker interface {
	OpenSession(id rpc.ConnectionId) (SessionEndedFn, error)

	// WaitForSession waits for the session to be started for the provided
	// amount of time. If the session starts within the provided time window
	// then WaitForSession blocks for as long as the session is running.
	// Returning true signifies that the session existed at any point after
	// calling this function. Error is returned if the context is cancelled.
	WaitForSession(ctx context.Context, id rpc.ConnectionId, waitTime time.Duration) (bool, error)
}

Jump to

Keyboard shortcuts

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