event

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 1 Imported by: 110

Documentation

Overview

Deprecated: This package has moved into go-libp2p as a sub-package: github.com/libp2p/go-libp2p/core/event.

Package event contains the abstractions for a local event bus, along with the standard events that libp2p subsystems may emit.

Source code is arranged as follows:

  • doc.go: this file.
  • bus.go: abstractions for the event bus.
  • rest: event structs, sensibly categorised in files by entity, and following this naming convention: Evt[Entity (noun)][Event (verb past tense / gerund)] The past tense is used to convey that something happened, whereas the gerund form of the verb (-ing) expresses that a process is in progress. Examples: EvtConnEstablishing, EvtConnEstablished.

Index

Constants

View Source
const (
	// Unknown means that the event producer was unable to determine why the address
	// is in the current state.
	// Deprecated: use github.com/libp2p/go-libp2p/core/event.Unknown instead
	Unknown = event.Unknown

	// Added means that the address is new and was not present prior to the event.
	// Deprecated: use github.com/libp2p/go-libp2p/core/event.Added instead
	Added = event.Added

	// Maintained means that the address was not altered between the current and
	// previous states.
	// Deprecated: use github.com/libp2p/go-libp2p/core/event.Maintained instead
	Maintained = event.Maintained

	// Removed means that the address was removed from the Host.
	// Deprecated: use github.com/libp2p/go-libp2p/core/event.Removed instead
	Removed = event.Removed
)

Variables

View Source
var WildcardSubscription = event.WildcardSubscription

WildcardSubscription is the type to subscribe to to receive all events emitted in the eventbus. Deprecated: use github.com/libp2p/go-libp2p/core/event.WildcardSubscription instead

Functions

This section is empty.

Types

type AddrAction added in v0.4.0

type AddrAction = event.AddrAction

AddrAction represents an action taken on one of a Host's listen addresses. It is used to add context to address change events in EvtLocalAddressesUpdated. Deprecated: use github.com/libp2p/go-libp2p/core/event.AddrAction instead

type Bus

type Bus = event.Bus

Bus is an interface for a type-based event delivery system. Deprecated: use github.com/libp2p/go-libp2p/core/event.Bus instead

type CancelFunc

type CancelFunc = event.CancelFunc

CancelFunc closes a subscriber. Deprecated: use github.com/libp2p/go-libp2p/core/event.CancelFunc instead

type Emitter

type Emitter = event.Emitter

Emitter represents an actor that emits events onto the eventbus. Deprecated: use github.com/libp2p/go-libp2p/core/event.Emitter instead

type EmitterOpt

type EmitterOpt = event.EmitterOpt

EmitterOpt represents an emitter option. Use the options exposed by the implementation of choice. Deprecated: use github.com/libp2p/go-libp2p/core/event.EmitterOpt instead

type EvtLocalAddressesUpdated added in v0.4.0

type EvtLocalAddressesUpdated = event.EvtLocalAddressesUpdated

EvtLocalAddressesUpdated should be emitted when the set of listen addresses for the local host changes. This may happen for a number of reasons. For example, we may have opened a new relay connection, established a new NAT mapping via UPnP, or been informed of our observed address by another peer.

EvtLocalAddressesUpdated contains a snapshot of the current listen addresses, and may also contain a diff between the current state and the previous state. If the event producer is capable of creating a diff, the Diffs field will be true, and event consumers can inspect the Action field of each UpdatedAddress to see how each address was modified.

For example, the Action will tell you whether an address in the Current list was Added by the event producer, or was Maintained without changes. Addresses that were removed from the Host will have the AddrAction of Removed, and will be in the Removed list.

If the event producer is not capable or producing diffs, the Diffs field will be false, the Removed list will always be empty, and the Action for each UpdatedAddress in the Current list will be Unknown.

In addition to the above, EvtLocalAddressesUpdated also contains the updated peer.PeerRecord for the Current set of listen addresses, wrapped in a record.Envelope and signed by the Host's private key. This record can be shared with other peers to inform them of what we believe are our diallable addresses a secure and authenticated way. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtLocalAddressesUpdated instead

type EvtLocalProtocolsUpdated

type EvtLocalProtocolsUpdated = event.EvtLocalProtocolsUpdated

EvtLocalProtocolsUpdated should be emitted when stream handlers are attached or detached from the local host. For handlers attached with a matcher predicate (host.SetStreamHandlerMatch()), only the protocol ID will be included in this event. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtLocalProtocolsUpdated instead

type EvtLocalReachabilityChanged added in v0.4.0

type EvtLocalReachabilityChanged = event.EvtLocalReachabilityChanged

EvtLocalReachabilityChanged is an event struct to be emitted when the local's node reachability changes state.

This event is usually emitted by the AutoNAT subsystem. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtLocalReachabilityChanged instead

type EvtNATDeviceTypeChanged added in v0.8.4

type EvtNATDeviceTypeChanged = event.EvtNATDeviceTypeChanged

EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes for a Transport Protocol.

Note: This event is meaningful ONLY if the AutoNAT Reachability is Private. Consumers of this event should ALSO consume the `EvtLocalReachabilityChanged` event and interpret this event ONLY if the Reachability on the `EvtLocalReachabilityChanged` is Private. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtNATDeviceTypeChanged instead

type EvtPeerConnectednessChanged added in v0.5.0

type EvtPeerConnectednessChanged = event.EvtPeerConnectednessChanged

EvtPeerConnectednessChanged should be emitted every time the "connectedness" to a given peer changes. Specifically, this event is emitted in the following cases:

  • Connectedness = Connected: Every time we transition from having no connections to a peer to having at least one connection to the peer.
  • Connectedness = NotConnected: Every time we transition from having at least one connection to a peer to having no connections to the peer.

Additional connectedness states may be added in the future. This list should not be considered exhaustive.

Take note:

  • It's possible to have _multiple_ connections to a given peer.
  • Both libp2p and networks are asynchronous.

This means that all of the following situations are possible:

A connection is cut and is re-established:

  • Peer A observes a transition from Connected -> NotConnected -> Connected
  • Peer B observes a transition from Connected -> NotConnected -> Connected

Explanation: Both peers observe the connection die. This is the "nice" case.

A connection is cut and is re-established.

  • Peer A observes a transition from Connected -> NotConnected -> Connected.
  • Peer B observes no transition.

Explanation: Peer A re-establishes the dead connection. Peer B observes the new connection form before it observes the old connection die.

A connection is cut:

  • Peer A observes no transition.
  • Peer B observes no transition.

Explanation: There were two connections and one was cut. This connection might have been in active use but neither peer will observe a change in "connectedness". Peers should always make sure to re-try network requests. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtPeerConnectednessChanged instead

type EvtPeerIdentificationCompleted added in v0.3.1

type EvtPeerIdentificationCompleted = event.EvtPeerIdentificationCompleted

EvtPeerIdentificationCompleted is emitted when the initial identification round for a peer is completed. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtPeerIdentificationCompleted instead

type EvtPeerIdentificationFailed added in v0.3.1

type EvtPeerIdentificationFailed = event.EvtPeerIdentificationFailed

EvtPeerIdentificationFailed is emitted when the initial identification round for a peer failed. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtPeerIdentificationFailed instead

type EvtPeerProtocolsUpdated

type EvtPeerProtocolsUpdated = event.EvtPeerProtocolsUpdated

EvtPeerProtocolsUpdated should be emitted when a peer we're connected to adds or removes protocols from their stack. Deprecated: use github.com/libp2p/go-libp2p/core/event.EvtPeerProtocolsUpdated instead

type GenericDHTEvent added in v0.5.7

type GenericDHTEvent = event.GenericDHTEvent

GenericDHTEvent is a type that encapsulates an actual DHT event by carrying its raw JSON.

Context: the DHT event system is rather bespoke and a bit messy at the time, so until we unify/clean that up, this event bridges the gap. It should only be consumed for informational purposes.

EXPERIMENTAL: this will likely be removed if/when the DHT event types are hoisted to core, and the DHT event system is reconciled with the eventbus. Deprecated: use github.com/libp2p/go-libp2p/core/event.GenericDHTEvent instead

type RawJSON added in v0.5.7

type RawJSON = event.RawJSON

RawJSON is a type that contains a raw JSON string. Deprecated: use github.com/libp2p/go-libp2p/core/event.RawJSON instead

type Subscription

type Subscription = event.Subscription

Subscription represents a subscription to one or multiple event types. Deprecated: use github.com/libp2p/go-libp2p/core/event.Subscription instead

type SubscriptionOpt

type SubscriptionOpt = event.SubscriptionOpt

SubscriptionOpt represents a subscriber option. Use the options exposed by the implementation of choice. Deprecated: use github.com/libp2p/go-libp2p/core/event.SubscriptionOpt instead

type UpdatedAddress added in v0.4.0

type UpdatedAddress = event.UpdatedAddress

UpdatedAddress is used in the EvtLocalAddressesUpdated event to convey address change information. Deprecated: use github.com/libp2p/go-libp2p/core/event.UpdatedAddress instead

Jump to

Keyboard shortcuts

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