tinder

package
v2.62.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package tinder is a multi-driver service backed by a cache.

┌───────────────────────────────────────────────────┐
│ Tinder                                            │        ┌───────────────────────┐

┌───────────────┐ │ │ ┌────▶│ Driver DHT Ipfs │ │ Advertise │▶┼───┐ ┌────────────────┐ │ │ └───────────────────────┘ └───────────────┘ │ │ │ Backoff Cache │ │ │ ┌───────────────────────┐ ┌───────────────┐ │ ├────▶│ Discover │──┐ ┌───────────────┐ │ ├────▶│ Driver DHT Berty │ │ FindPeers │▶┼───┘ └────────────────┘ │ │Driver Manager │ │ │ └───────────────────────┘ └───────────────┘ │ ┌──────────────┴──▶│ (MultiDriver) │─┼──┤ ┌───────────────────────┐ ┌───────────────┐ │ │ └───────────────┘ │ ├────▶│Driver RendezVousPoint │ │ Unregister │▶┼──────────────┘ │ │ └───────────────────────┘ └───────────────┘ │ │ │ ┌───────────────────────┐

│                                                   │  └────▶│Driver Local (ble/mdns)│
└───────────────────────────────────────────────────┘        └───────────────────────┘

Index

Constants

View Source
const ScheduleKey = "Schedule"

Variables

This section is empty.

Functions

func Schedule

func Schedule(t time.Time) p2p_discovery.Option

Schedule advertise at the given time

Types

type DHTDriver added in v2.50.0

type DHTDriver struct {
	p2p_discovery.Discovery
	Unregisterer
}

func (*DHTDriver) Name added in v2.50.0

func (d *DHTDriver) Name() string

type Driver

type Driver interface {
	p2p_discovery.Discovery
	Unregisterer

	Name() string
}

Driver is a Discovery with a unregister method

func ComposeDriver

func ComposeDriver(name string, advertiser p2p_discovery.Advertiser, discover p2p_discovery.Discoverer, unregister Unregisterer) Driver

func NewDHTDriver

func NewDHTDriver(d *dht.IpfsDHT) Driver

func NewMockedDriverClient

func NewMockedDriverClient(host p2p_host.Host, server *MockDriverServer) Driver

func NewMultiDriver

func NewMultiDriver(logger *zap.Logger, drivers ...Driver) Driver

func NewRendezvousDiscovery

func NewRendezvousDiscovery(logger *zap.Logger, host host.Host, rdvPeer peer.ID, rng *mrand.Rand) Driver

type MockDriverServer

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

func NewMockedDriverServer

func NewMockedDriverServer() *MockDriverServer

func (*MockDriverServer) Advertise

func (s *MockDriverServer) Advertise(ns string, info p2p_peer.AddrInfo, ttl time.Duration) (time.Duration, error)

func (*MockDriverServer) FindPeers

func (s *MockDriverServer) FindPeers(ns string, limit int) (<-chan p2p_peer.AddrInfo, error)

func (*MockDriverServer) HasPeerRecord

func (s *MockDriverServer) HasPeerRecord(ns string, pid p2p_peer.ID) bool

func (*MockDriverServer) Reset

func (s *MockDriverServer) Reset()

func (*MockDriverServer) Unregister

func (s *MockDriverServer) Unregister(ns string, pid p2p_peer.ID)

type MultiDriver

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

MultiDriver is a simple driver manager, that forward request across multiple driver

func (*MultiDriver) Advertise

func (md *MultiDriver) Advertise(ctx context.Context, ns string, opts ...p2p_discovery.Option) (time.Duration, error)

Advertise simply dispatch Advertise request across all the drivers

func (*MultiDriver) FindPeers

func (md *MultiDriver) FindPeers(ctx context.Context, ns string, opts ...p2p_discovery.Option) (<-chan p2p_peer.AddrInfo, error)

FindPeers for MultiDriver doesn't care about duplicate peers, his only job here is to dispatch FindPeers request across all the drivers.

func (*MultiDriver) Name added in v2.50.0

func (*MultiDriver) Name() string

func (*MultiDriver) Unregister

func (md *MultiDriver) Unregister(ctx context.Context, ns string) error

type Routing added in v2.50.0

type Routing interface {
	p2p_routing.Routing

	Driver
}

func NewRouting added in v2.50.0

func NewRouting(logger *zap.Logger, name string, r p2p_routing.Routing, drivers ...Driver) Routing

type Service

type Service interface {
	Driver
}

Tinder service is a simple driver backed by a cache,

func NewService

func NewService(logger *zap.Logger, drivers []Driver, stratFactory p2p_discovery.BackoffFactory, opts ...p2p_discovery.BackoffDiscoveryOption) (Service, error)

type Unregisterer

type Unregisterer interface {
	Unregister(ctx context.Context, ns string) error
}
var NoopUnregisterer Unregisterer = &noopUnregisterer{}

Jump to

Keyboard shortcuts

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