events

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0, MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventManager

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

EventManager is responsible for dispatching events to registered subscribers. Events are dispatched asynchronously, so subscribers should not assume that events are received within the window of a blocking retriever.Retrieve() call.

func NewEventManager

func NewEventManager(ctx context.Context) *EventManager

NewEventManager creates a new EventManager. Start() must be called to start the event loop.

func (*EventManager) DispatchEvent

func (em *EventManager) DispatchEvent(event types.RetrievalEvent)

DispatchEvent queues the event to be dispatched to all event subscribers. Calling the subscriber functions happens on a separate goroutine dedicated to this function.

func (*EventManager) IsStarted

func (em *EventManager) IsStarted() bool

IsStarted returns true if the event loop has been started.

func (*EventManager) RegisterSubscriber

func (em *EventManager) RegisterSubscriber(subscriber types.RetrievalEventSubscriber) func()

RegisterSubscriber registers a subscriber to receive events. The returned function can be called to unregister the subscriber.

func (*EventManager) Start

func (em *EventManager) Start()

Start starts the event loop. Start() must be called before any events can be dispatched.

func (*EventManager) Stop

func (em *EventManager) Stop() chan struct{}

Stop stops the event loop. A channel is returned that will receive a single value when the event loop has stopped.

type EventWithCandidates

type EventWithCandidates interface {
	types.RetrievalEvent
	Candidates() []types.RetrievalCandidate
}

type RetrievalEventAccepted

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

RetrievalEventFirstByte describes when the first byte of data was received during the RetrievalPhase

func Accepted

func Accepted(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, candidate types.RetrievalCandidate) RetrievalEventAccepted

func (RetrievalEventAccepted) Code

func (RetrievalEventAccepted) Phase

func (RetrievalEventAccepted) StorageProviderId

func (r RetrievalEventAccepted) StorageProviderId() peer.ID

func (RetrievalEventAccepted) String

func (r RetrievalEventAccepted) String() string

type RetrievalEventCandidatesFiltered

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

func CandidatesFiltered

func CandidatesFiltered(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, payloadCid cid.Cid, candidates []types.RetrievalCandidate) RetrievalEventCandidatesFiltered

func (RetrievalEventCandidatesFiltered) Candidates

func (r RetrievalEventCandidatesFiltered) Candidates() []types.RetrievalCandidate

func (RetrievalEventCandidatesFiltered) Code

func (RetrievalEventCandidatesFiltered) Phase

func (RetrievalEventCandidatesFiltered) StorageProviderId

func (r RetrievalEventCandidatesFiltered) StorageProviderId() peer.ID

func (RetrievalEventCandidatesFiltered) String

type RetrievalEventCandidatesFound

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

func CandidatesFound

func CandidatesFound(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, payloadCid cid.Cid, candidates []types.RetrievalCandidate) RetrievalEventCandidatesFound

func (RetrievalEventCandidatesFound) Candidates

func (r RetrievalEventCandidatesFound) Candidates() []types.RetrievalCandidate

func (RetrievalEventCandidatesFound) Code

func (RetrievalEventCandidatesFound) Phase

func (RetrievalEventCandidatesFound) StorageProviderId

func (r RetrievalEventCandidatesFound) StorageProviderId() peer.ID

func (RetrievalEventCandidatesFound) String

type RetrievalEventConnected

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

func Connected

func Connected(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, phase types.Phase, candidate types.RetrievalCandidate) RetrievalEventConnected

func (RetrievalEventConnected) Code

func (RetrievalEventConnected) Phase

func (RetrievalEventConnected) StorageProviderId

func (r RetrievalEventConnected) StorageProviderId() peer.ID

func (RetrievalEventConnected) String

func (r RetrievalEventConnected) String() string

type RetrievalEventFailed

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

RetrievalEventFailed describes a phase agnostic failure

func Failed

func Failed(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, phase types.Phase, candidate types.RetrievalCandidate, errorMessage string) RetrievalEventFailed

func (RetrievalEventFailed) Code

func (RetrievalEventFailed) ErrorMessage

func (r RetrievalEventFailed) ErrorMessage() string

ErrorMessage returns a string form of the error that caused the retrieval failure

func (RetrievalEventFailed) Phase

func (r RetrievalEventFailed) Phase() types.Phase

func (RetrievalEventFailed) StorageProviderId

func (r RetrievalEventFailed) StorageProviderId() peer.ID

func (RetrievalEventFailed) String

func (r RetrievalEventFailed) String() string

type RetrievalEventFinished added in v0.6.6

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

RetrievalEventFinished describes when an entire fetch finishes

func Finished added in v0.6.6

func Finished(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, candidate types.RetrievalCandidate) RetrievalEventFinished

func (RetrievalEventFinished) Code added in v0.6.6

func (RetrievalEventFinished) Phase added in v0.6.6

func (RetrievalEventFinished) StorageProviderId added in v0.6.6

func (r RetrievalEventFinished) StorageProviderId() peer.ID

func (RetrievalEventFinished) String added in v0.6.6

func (r RetrievalEventFinished) String() string

type RetrievalEventFirstByte

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

RetrievalEventFirstByte describes when the first byte of data was received during the RetrievalPhase

func FirstByte

func FirstByte(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, candidate types.RetrievalCandidate) RetrievalEventFirstByte

func (RetrievalEventFirstByte) Code

func (RetrievalEventFirstByte) Phase

func (RetrievalEventFirstByte) StorageProviderId

func (r RetrievalEventFirstByte) StorageProviderId() peer.ID

func (RetrievalEventFirstByte) String

func (r RetrievalEventFirstByte) String() string

type RetrievalEventProposed

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

RetrievalEventProposed describes when the proposal took place during the RetrievalPhase

func Proposed

func Proposed(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, candidate types.RetrievalCandidate) RetrievalEventProposed

func (RetrievalEventProposed) Code

func (RetrievalEventProposed) Phase

func (RetrievalEventProposed) StorageProviderId

func (r RetrievalEventProposed) StorageProviderId() peer.ID

func (RetrievalEventProposed) String

func (r RetrievalEventProposed) String() string

type RetrievalEventStarted

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

RetrievalEventStarted describes when a phase starts

func Started

func Started(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, phase types.Phase, candidate types.RetrievalCandidate) RetrievalEventStarted

func (RetrievalEventStarted) Code

func (RetrievalEventStarted) Phase

func (r RetrievalEventStarted) Phase() types.Phase

func (RetrievalEventStarted) StorageProviderId

func (r RetrievalEventStarted) StorageProviderId() peer.ID

func (RetrievalEventStarted) String

func (r RetrievalEventStarted) String() string

type RetrievalEventSuccess

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

RetrievalEventSuccess describes a successful retrieval of data during the RetrievalPhase

func Success

func Success(at time.Time, retrievalId types.RetrievalID, phaseStartTime time.Time, candidate types.RetrievalCandidate, receivedSize uint64, receivedCids uint64, duration time.Duration, totalPayment big.Int) RetrievalEventSuccess

func (RetrievalEventSuccess) Code

func (RetrievalEventSuccess) Duration

func (r RetrievalEventSuccess) Duration() time.Duration

func (RetrievalEventSuccess) Phase

func (r RetrievalEventSuccess) Phase() types.Phase

func (RetrievalEventSuccess) ReceivedCids

func (r RetrievalEventSuccess) ReceivedCids() uint64

ReceivedCids returns the number of (non-unique) CIDs received so far - note that a block can exist in more than one place in the DAG so this may not equal the total number of blocks transferred

func (RetrievalEventSuccess) ReceivedSize

func (r RetrievalEventSuccess) ReceivedSize() uint64

ReceivedSize returns the number of bytes received

func (RetrievalEventSuccess) StorageProviderId

func (r RetrievalEventSuccess) StorageProviderId() peer.ID

func (RetrievalEventSuccess) String

func (r RetrievalEventSuccess) String() string

func (RetrievalEventSuccess) TotalPayment

func (r RetrievalEventSuccess) TotalPayment() big.Int

Jump to

Keyboard shortcuts

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