events

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identifier added in v0.14.0

func Identifier(evt types.RetrievalEvent) string

Identifier returns the peer ID of the storage provider if this retrieval was requested via peer ID, or the string "Bitswap" if this retrieval was requested via the Bitswap protocol

Types

type BlockReceivedEvent added in v0.19.0

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

BlockReceivedEvent records new data received from a provider. It is used to track how much is downloaded from each peer in a retrieval

func BlockReceived added in v0.19.0

func BlockReceived(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, protocol multicodec.Code, byteCount uint64) BlockReceivedEvent

func (BlockReceivedEvent) ByteCount added in v0.19.0

func (e BlockReceivedEvent) ByteCount() uint64

func (BlockReceivedEvent) Code added in v0.19.0

func (BlockReceivedEvent) Protocol added in v0.19.0

func (e BlockReceivedEvent) Protocol() multicodec.Code

func (BlockReceivedEvent) ProviderId added in v0.19.0

func (e BlockReceivedEvent) ProviderId() peer.ID

func (BlockReceivedEvent) String added in v0.19.0

func (e BlockReceivedEvent) String() string

type CandidatesFilteredEvent added in v0.14.0

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

func CandidatesFiltered

func CandidatesFiltered(at time.Time, retrievalId types.RetrievalID, rootCid cid.Cid, candidates []types.RetrievalCandidate) CandidatesFilteredEvent

func (CandidatesFilteredEvent) Candidates added in v0.14.0

func (CandidatesFilteredEvent) Code added in v0.14.0

func (CandidatesFilteredEvent) Protocols added in v0.14.0

func (e CandidatesFilteredEvent) Protocols() []multicodec.Code

func (CandidatesFilteredEvent) RetrievalId added in v0.14.0

func (r CandidatesFilteredEvent) RetrievalId() types.RetrievalID

func (CandidatesFilteredEvent) RootCid added in v0.20.0

func (r CandidatesFilteredEvent) RootCid() cid.Cid

func (CandidatesFilteredEvent) String added in v0.14.0

func (e CandidatesFilteredEvent) String() string

func (CandidatesFilteredEvent) Time added in v0.14.0

func (r CandidatesFilteredEvent) Time() time.Time

type CandidatesFoundEvent added in v0.14.0

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

func CandidatesFound

func CandidatesFound(at time.Time, retrievalId types.RetrievalID, rootCid cid.Cid, candidates []types.RetrievalCandidate) CandidatesFoundEvent

func (CandidatesFoundEvent) Candidates added in v0.14.0

func (CandidatesFoundEvent) Code added in v0.14.0

func (CandidatesFoundEvent) RetrievalId added in v0.14.0

func (r CandidatesFoundEvent) RetrievalId() types.RetrievalID

func (CandidatesFoundEvent) RootCid added in v0.20.0

func (r CandidatesFoundEvent) RootCid() cid.Cid

func (CandidatesFoundEvent) String added in v0.14.0

func (e CandidatesFoundEvent) String() string

func (CandidatesFoundEvent) Time added in v0.14.0

func (r CandidatesFoundEvent) Time() time.Time

type ConnectedToProviderEvent added in v0.14.0

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

func ConnectedToProvider added in v0.14.0

func ConnectedToProvider(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, protocol multicodec.Code) ConnectedToProviderEvent

func (ConnectedToProviderEvent) Code added in v0.14.0

func (ConnectedToProviderEvent) Protocol added in v0.15.0

func (e ConnectedToProviderEvent) Protocol() multicodec.Code

func (ConnectedToProviderEvent) ProviderId added in v0.14.0

func (e ConnectedToProviderEvent) ProviderId() peer.ID

func (ConnectedToProviderEvent) String added in v0.14.0

func (e ConnectedToProviderEvent) String() string

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 EventWithErrorMessage added in v0.14.0

type EventWithErrorMessage interface {
	types.RetrievalEvent
	ErrorMessage() string
}

type EventWithProtocol added in v0.14.0

type EventWithProtocol interface {
	types.RetrievalEvent
	Protocol() multicodec.Code
}

type EventWithProtocols added in v0.14.0

type EventWithProtocols interface {
	types.RetrievalEvent
	Protocols() []multicodec.Code
}

type EventWithProviderID added in v0.14.0

type EventWithProviderID interface {
	types.RetrievalEvent
	ProviderId() peer.ID
}

type FailedEvent added in v0.14.0

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

func Failed

func Failed(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, errorMessage string) FailedEvent

func (FailedEvent) Code added in v0.14.0

func (e FailedEvent) Code() types.EventCode

func (FailedEvent) ErrorMessage added in v0.14.0

func (e FailedEvent) ErrorMessage() string

func (FailedEvent) RetrievalId added in v0.14.0

func (r FailedEvent) RetrievalId() types.RetrievalID

func (FailedEvent) RootCid added in v0.20.0

func (r FailedEvent) RootCid() cid.Cid

func (FailedEvent) String added in v0.14.0

func (e FailedEvent) String() string

func (FailedEvent) Time added in v0.14.0

func (r FailedEvent) Time() time.Time

type FailedRetrievalEvent added in v0.14.0

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

func FailedRetrieval added in v0.14.0

func FailedRetrieval(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, protocol multicodec.Code, errorMessage string) FailedRetrievalEvent

func (FailedRetrievalEvent) Code added in v0.14.0

func (FailedRetrievalEvent) ErrorMessage added in v0.14.0

func (e FailedRetrievalEvent) ErrorMessage() string

func (FailedRetrievalEvent) Protocol added in v0.15.0

func (e FailedRetrievalEvent) Protocol() multicodec.Code

func (FailedRetrievalEvent) ProviderId added in v0.14.0

func (e FailedRetrievalEvent) ProviderId() peer.ID

func (FailedRetrievalEvent) String added in v0.14.0

func (e FailedRetrievalEvent) String() string

type FinishedEvent added in v0.14.0

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

func Finished added in v0.6.6

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

func (FinishedEvent) Code added in v0.14.0

func (e FinishedEvent) Code() types.EventCode

func (FinishedEvent) ProviderId added in v0.14.0

func (e FinishedEvent) ProviderId() peer.ID

func (FinishedEvent) String added in v0.14.0

func (e FinishedEvent) String() string

type FirstByteEvent added in v0.14.0

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

func FirstByte

func FirstByte(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, duration time.Duration, protocol multicodec.Code) FirstByteEvent

func (FirstByteEvent) Code added in v0.14.0

func (e FirstByteEvent) Code() types.EventCode

func (FirstByteEvent) Duration added in v0.14.0

func (e FirstByteEvent) Duration() time.Duration

func (FirstByteEvent) Protocol added in v0.14.0

func (e FirstByteEvent) Protocol() multicodec.Code

func (FirstByteEvent) ProviderId added in v0.14.0

func (e FirstByteEvent) ProviderId() peer.ID

func (FirstByteEvent) String added in v0.14.0

func (e FirstByteEvent) String() string

type GraphsyncAcceptedEvent added in v0.14.0

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

func Accepted

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

func (GraphsyncAcceptedEvent) Code added in v0.14.0

func (GraphsyncAcceptedEvent) Protocol added in v0.15.0

func (e GraphsyncAcceptedEvent) Protocol() multicodec.Code

func (GraphsyncAcceptedEvent) ProviderId added in v0.14.0

func (e GraphsyncAcceptedEvent) ProviderId() peer.ID

func (GraphsyncAcceptedEvent) String added in v0.14.0

func (e GraphsyncAcceptedEvent) String() string

type GraphsyncProposedEvent added in v0.14.0

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

func Proposed

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

func (GraphsyncProposedEvent) Code added in v0.14.0

func (GraphsyncProposedEvent) Protocol added in v0.15.0

func (e GraphsyncProposedEvent) Protocol() multicodec.Code

func (GraphsyncProposedEvent) ProviderId added in v0.14.0

func (e GraphsyncProposedEvent) ProviderId() peer.ID

func (GraphsyncProposedEvent) String added in v0.14.0

func (e GraphsyncProposedEvent) String() string

type StartedFetchEvent added in v0.14.0

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

StartedFetchEvent signals the start of a Lassie fetch. It is emitted when a fetch is started.

func StartedFetch added in v0.12.0

func StartedFetch(at time.Time, retrievalId types.RetrievalID, rootCid cid.Cid, urlPath string, supportedProtocols ...multicodec.Code) StartedFetchEvent

func (StartedFetchEvent) Code added in v0.14.0

func (StartedFetchEvent) Protocols added in v0.14.0

func (e StartedFetchEvent) Protocols() []multicodec.Code

func (StartedFetchEvent) RetrievalId added in v0.14.0

func (r StartedFetchEvent) RetrievalId() types.RetrievalID

func (StartedFetchEvent) RootCid added in v0.20.0

func (r StartedFetchEvent) RootCid() cid.Cid

func (StartedFetchEvent) String added in v0.14.0

func (e StartedFetchEvent) String() string

func (StartedFetchEvent) Time added in v0.14.0

func (r StartedFetchEvent) Time() time.Time

func (StartedFetchEvent) UrlPath added in v0.14.0

func (e StartedFetchEvent) UrlPath() string

type StartedFindingCandidatesEvent added in v0.14.0

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

StartedFindingCandidatesEvent signals the start of finding candidates for a fetch.

func StartedFindingCandidates added in v0.14.0

func StartedFindingCandidates(at time.Time, retrievalId types.RetrievalID, rootCid cid.Cid) StartedFindingCandidatesEvent

func (StartedFindingCandidatesEvent) Code added in v0.14.0

func (StartedFindingCandidatesEvent) RetrievalId added in v0.14.0

func (r StartedFindingCandidatesEvent) RetrievalId() types.RetrievalID

func (StartedFindingCandidatesEvent) RootCid added in v0.20.0

func (r StartedFindingCandidatesEvent) RootCid() cid.Cid

func (StartedFindingCandidatesEvent) String added in v0.14.0

func (StartedFindingCandidatesEvent) Time added in v0.14.0

func (r StartedFindingCandidatesEvent) Time() time.Time

type StartedRetrievalEvent added in v0.14.0

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

StartedRetrievalEvent signals the start of a retrieval from a storage provider. It is emitted when the retrieval is started.

func StartedRetrieval added in v0.14.0

func StartedRetrieval(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, protocol multicodec.Code) StartedRetrievalEvent

func (StartedRetrievalEvent) Code added in v0.14.0

func (StartedRetrievalEvent) Protocol added in v0.14.0

func (e StartedRetrievalEvent) Protocol() multicodec.Code

func (StartedRetrievalEvent) ProviderId added in v0.14.0

func (e StartedRetrievalEvent) ProviderId() peer.ID

func (StartedRetrievalEvent) String added in v0.14.0

func (e StartedRetrievalEvent) String() string

type SucceededEvent added in v0.14.0

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

func Success

func Success(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, receivedBytesSize uint64, receivedCidsCount uint64, duration time.Duration, protocol multicodec.Code) SucceededEvent

func (SucceededEvent) Code added in v0.14.0

func (e SucceededEvent) Code() types.EventCode

func (SucceededEvent) Duration added in v0.14.0

func (e SucceededEvent) Duration() time.Duration

func (SucceededEvent) Protocol added in v0.14.0

func (e SucceededEvent) Protocol() multicodec.Code

func (SucceededEvent) ProviderId added in v0.14.0

func (e SucceededEvent) ProviderId() peer.ID

func (SucceededEvent) ReceivedBytesSize added in v0.14.0

func (e SucceededEvent) ReceivedBytesSize() uint64

func (SucceededEvent) ReceivedCidsCount added in v0.14.0

func (e SucceededEvent) ReceivedCidsCount() uint64

func (SucceededEvent) String added in v0.14.0

func (e SucceededEvent) String() string

Jump to

Keyboard shortcuts

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