Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HostIndex ¶
HostIndex is an optional interface for Index that designates the "id" index in the routing table. The Record type MAY also implement HostIndex to provide fast, allocation-free indexing of hostnames.
type ID ¶
type ID uint64
ID is an opaque identifier that identifies a unique host instance on the network. A fresh ID is generated for each cluster.Router instance, making it possible to distinguish between multiple runs of a libp2p host with a fixed peer identity.
IDs are not guaranteed to be globally unique.
func (ID) MarshalText ¶
func (*ID) UnmarshalText ¶
type Index ¶
type Index interface { // String returns the index name. String() string // Prefix returns true if the index is a prefix match Prefix() bool }
Index is a pointer to a 'column' in the routing table's schema. Indexes MUST implement index methods corresponding to the index name returned by String(). See schema.go for more information.
type Iterator ¶
type Iterator interface { // Next pops a record from the head of the stream and // returns it to the caller. Subsequent calls to Next // will return a different record. When the stream is // exhausted, Next returns nil. Next() Record }
Iterator is a stateful object that enumerates routing records. Iterator's methods are NOT guaranteed to be thread-safe, but implementations MUST permit multiple iterators to operate concurently.
Implementations MAY operate on immutable snapshots of routing-table state, so callers SHOULD consume record streams promptly.
type Meta ¶
type Meta capnp.TextList
Meta is an indexed set of key-value pairs describing arbitrary metadata.
func (Meta) Get ¶
Get returns the value associated with the supplied key. If the key is not found, Get returns ("", nil). Errors are reserved for failures in reading or parsing fields.
type MetaField ¶
type MetaField struct {
Key, Value string
}
MetaField is a key-value pair.
func ParseField ¶
type MetaIndex ¶
MetaIndex is an optional interface for Index that designates a single key-value pair. Note that Record does NOT support this interface, since the Meta type already provides its own indexing method.
type PeerIndex ¶
PeerIndex is an optional interface for Index that designates the "id" index in the routing table. The Record type MAY also implement PeerIndex to provide fast, allocation-free indexing of peer IDs.
type Record ¶
type Record interface { Server() ID Peer() peer.ID Seq() uint64 TTL() time.Duration Host() (string, error) Meta() (Meta, error) }
Record is an entry in the routing table.
type ServerIndex ¶
ServerIndex is an optional interface for Index that designates the "server" index in the routing table. The Record type MAY also implement ServerIndex to provide allocation-free indexing.
type Snapshot ¶
type Snapshot interface { Get(Index) (Iterator, error) GetReverse(Index) (Iterator, error) LowerBound(Index) (Iterator, error) ReverseLowerBound(Index) (Iterator, error) }
Snapshot provides iteration strategies over an isolated snapshot of the routing-table. Implementations MUST NOT mutate the state of the routing table, and MUST support concurrent iteration.