events

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0, MIT Imports: 11 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 EventWithQueryResponse

type EventWithQueryResponse interface {
	types.RetrievalEvent
	QueryResponse() retrievalmarket.QueryResponse
}

type RetrievalEventAccepted

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

func Accepted

func Accepted(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(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(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(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
}

func Failed

func Failed(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 RetrievalEventFirstByte

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

func FirstByte

func FirstByte(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
}

func Proposed

func Proposed(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 RetrievalEventQueryAsked

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

func QueryAsked

func QueryAsked(retrievalId types.RetrievalID, phaseStartTime time.Time, candidate types.RetrievalCandidate, queryResponse retrievalmarket.QueryResponse) RetrievalEventQueryAsked

func (RetrievalEventQueryAsked) Code

func (RetrievalEventQueryAsked) Phase

func (RetrievalEventQueryAsked) QueryResponse

func (RetrievalEventQueryAsked) StorageProviderId

func (r RetrievalEventQueryAsked) StorageProviderId() peer.ID

func (RetrievalEventQueryAsked) String

func (r RetrievalEventQueryAsked) String() string

type RetrievalEventQueryAskedFiltered

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

func QueryAskedFiltered

func QueryAskedFiltered(retrievalId types.RetrievalID, phaseStartTime time.Time, candidate types.RetrievalCandidate, queryResponse retrievalmarket.QueryResponse) RetrievalEventQueryAskedFiltered

func (RetrievalEventQueryAskedFiltered) Code

func (RetrievalEventQueryAskedFiltered) Phase

func (RetrievalEventQueryAskedFiltered) QueryResponse

func (RetrievalEventQueryAskedFiltered) StorageProviderId

func (r RetrievalEventQueryAskedFiltered) StorageProviderId() peer.ID

func (RetrievalEventQueryAskedFiltered) String

type RetrievalEventStarted

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

func Started

func Started(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
}

func Success

func Success(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