tinder

package
v2.428.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0, MIT Imports: 34 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 (
	DefaultFindPeerInterval     = time.Minute * 30
	DefaultAdvertiseInterval    = time.Minute
	DefaultAdvertiseGracePeriod = time.Second * 10
)
View Source
const LocalDiscoveryName = "localdiscovery"

LocalDiscoveryName is the name of the localdiscovery driver

View Source
const TinderPeer = "Berty/TinderPeer"

Variables

View Source
var (
	ErrInvalidLengthRecords        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRecords          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupRecords = fmt.Errorf("proto: unexpected end of group")
)
View Source
var NoopDiscovery p2p_discovery.Discovery = &noopDiscovery{}

Functions

func FilterAll added in v2.277.0

func FilterAll(ms []ma.Multiaddr) []ma.Multiaddr

filter all addrs

func FilterDriverNameOption added in v2.362.0

func FilterDriverNameOption(driversName ...string) p2p_discovery.Option

FilterDriverNameOption filter driver by prefix name

func NewFilterDriverDiscovery added in v2.362.0

func NewFilterDriverDiscovery(disc p2p_discovery.Discovery, filters ...string) p2p_discovery.Discovery

func NewRotationDiscovery added in v2.367.0

func NewRotationDiscovery(logger *zap.Logger, disc discovery.Discovery, rp *rendezvous.RotationInterval) discovery.Discovery

func NoFilter added in v2.277.0

func NoFilter(ms []ma.Multiaddr) []ma.Multiaddr

no filters

func NoopAddrsFactory added in v2.277.0

func NoopAddrsFactory(addrs []ma.Multiaddr) []ma.Multiaddr

func PrivateAddrOnly added in v2.318.2

func PrivateAddrOnly(ms []ma.Multiaddr) []ma.Multiaddr

return anything but public addrs

func PublicAddrsOnly added in v2.318.2

func PublicAddrsOnly(ms []ma.Multiaddr) []ma.Multiaddr

return only public addrs

func RendezvousUseDiscoverAsyncOption added in v2.408.0

func RendezvousUseDiscoverAsyncOption(opts *p2p_discovery.Options) error

func WatchdogDiscoverForceOption added in v2.410.0

func WatchdogDiscoverForceOption(opts *p2p_discovery.Options) error

func WatchdogDiscoverKeepContextOption added in v2.362.0

func WatchdogDiscoverKeepContextOption(opts *p2p_discovery.Options) error

Types

type BackoffOpts added in v2.277.0

type BackoffOpts struct {
	StratFactory     discovery.BackoffFactory
	DiscoveryOptions []discovery.BackoffDiscoveryOption
}

type Driver

type Driver struct {
	Name         string
	AddrsFactory bhost.AddrsFactory

	Unregisterer
	p2p_discovery.Discovery
}

func NewDriverFromDiscovery added in v2.277.0

func NewDriverFromDiscovery(name string, disc p2p_discovery.Discovery, factory bhost.AddrsFactory) *Driver

func NewDriverFromRouting added in v2.277.0

func NewDriverFromRouting(name string, routing routing.ContentRouting, factory bhost.AddrsFactory) *Driver

func NewDriverFromUnregisterDiscovery added in v2.277.0

func NewDriverFromUnregisterDiscovery(name string, udisc UnregisterDiscovery, factory bhost.AddrsFactory) *Driver

func NewMockedDriverClient

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

type DriverDiscovery added in v2.277.0

type DriverDiscovery struct {
	p2p_discovery.Discoverer
	p2p_discovery.Advertiser
}

type EventMonitor added in v2.210.1

type EventMonitor int
const (
	TypeEventMonitorUnknown EventMonitor = iota
	TypeEventMonitorDriverAdvertise
	TypeEventMonitorDriverFoundPeer
	TypeEventMonitorAdvertise
	TypeEventMonitorFoundPeer
)

type EvtDriverMonitor added in v2.210.1

type EvtDriverMonitor struct {
	EventType  EventMonitor
	Topic      string
	AddrInfo   p2p_peer.AddrInfo
	DriverName string
}

type LocalDiscovery added in v2.365.0

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

func NewLocalDiscovery added in v2.94.0

func NewLocalDiscovery(logger *zap.Logger, host host.Host, rng *rand.Rand) (*LocalDiscovery, error)

func (*LocalDiscovery) Advertise added in v2.365.0

func (ld *LocalDiscovery) Advertise(ctx context.Context, cid string, opts ...discovery.Option) (time.Duration, error)

func (*LocalDiscovery) Close added in v2.365.0

func (ld *LocalDiscovery) Close() error

func (*LocalDiscovery) FindPeers added in v2.365.0

func (ld *LocalDiscovery) FindPeers(ctx context.Context, cid string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)

func (*LocalDiscovery) Unregister added in v2.365.0

func (ld *LocalDiscovery) Unregister(ctx context.Context, cid string) error

type MockDriverClient added in v2.277.0

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

func (*MockDriverClient) Advertise added in v2.277.0

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

func (*MockDriverClient) FindPeers added in v2.277.0

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

func (*MockDriverClient) Name added in v2.277.0

func (d *MockDriverClient) Name() string

func (*MockDriverClient) Unregister added in v2.277.0

func (d *MockDriverClient) Unregister(ctx context.Context, ns string) error

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)

func (*MockDriverServer) WaitForAdvertise added in v2.277.0

func (s *MockDriverServer) WaitForAdvertise(ns string, pid p2p_peer.ID) chan struct{}

type NetworkUpdate added in v2.277.0

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

func NewNetworkUpdate added in v2.277.0

func NewNetworkUpdate(logger *zap.Logger, h host.Host) (*NetworkUpdate, error)

func (*NetworkUpdate) Close added in v2.277.0

func (n *NetworkUpdate) Close() (err error)

func (*NetworkUpdate) GetLastUpdatedAddrs added in v2.277.0

func (n *NetworkUpdate) GetLastUpdatedAddrs(ctx context.Context) (addrs []ma.Multiaddr)

func (*NetworkUpdate) WaitForUpdate added in v2.277.0

func (n *NetworkUpdate) WaitForUpdate(ctx context.Context, currentAddrs []ma.Multiaddr, factory bhost.AddrsFactory) bool

type Opts added in v2.277.0

type Opts struct {
	Logger *zap.Logger

	EnableDiscoveryMonitor bool

	AdvertiseResetInterval time.Duration
	AdvertiseGracePeriod   time.Duration
	FindPeerResetInterval  time.Duration

	// BackoffStrategy describes how backoff will be implemented on the
	// FindPeer method. If none are provided, it will be disable alongside
	// cache.
	BackoffStrategy *BackoffOpts
}

type Record added in v2.94.0

type Record struct {
	Cid                  string   `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"`
	Expire               int64    `protobuf:"varint,2,opt,name=expire,proto3" json:"expire,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Record) Descriptor added in v2.94.0

func (*Record) Descriptor() ([]byte, []int)

func (*Record) GetCid added in v2.94.0

func (m *Record) GetCid() string

func (*Record) GetExpire added in v2.94.0

func (m *Record) GetExpire() int64

func (*Record) Marshal added in v2.94.0

func (m *Record) Marshal() (dAtA []byte, err error)

func (*Record) MarshalTo added in v2.94.0

func (m *Record) MarshalTo(dAtA []byte) (int, error)

func (*Record) MarshalToSizedBuffer added in v2.94.0

func (m *Record) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Record) ProtoMessage added in v2.94.0

func (*Record) ProtoMessage()

func (*Record) Reset added in v2.94.0

func (m *Record) Reset()

func (*Record) Size added in v2.94.0

func (m *Record) Size() (n int)

func (*Record) String added in v2.94.0

func (m *Record) String() string

func (*Record) Unmarshal added in v2.94.0

func (m *Record) Unmarshal(dAtA []byte) error

func (*Record) XXX_DiscardUnknown added in v2.94.0

func (m *Record) XXX_DiscardUnknown()

func (*Record) XXX_Marshal added in v2.94.0

func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Record) XXX_Merge added in v2.94.0

func (m *Record) XXX_Merge(src proto.Message)

func (*Record) XXX_Size added in v2.94.0

func (m *Record) XXX_Size() int

func (*Record) XXX_Unmarshal added in v2.94.0

func (m *Record) XXX_Unmarshal(b []byte) error

type Records added in v2.94.0

type Records struct {
	Records              []*Record `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*Records) Descriptor added in v2.94.0

func (*Records) Descriptor() ([]byte, []int)

func (*Records) GetRecords added in v2.94.0

func (m *Records) GetRecords() []*Record

func (*Records) Marshal added in v2.94.0

func (m *Records) Marshal() (dAtA []byte, err error)

func (*Records) MarshalTo added in v2.94.0

func (m *Records) MarshalTo(dAtA []byte) (int, error)

func (*Records) MarshalToSizedBuffer added in v2.94.0

func (m *Records) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Records) ProtoMessage added in v2.94.0

func (*Records) ProtoMessage()

func (*Records) Reset added in v2.94.0

func (m *Records) Reset()

func (*Records) Size added in v2.94.0

func (m *Records) Size() (n int)

func (*Records) String added in v2.94.0

func (m *Records) String() string

func (*Records) Unmarshal added in v2.94.0

func (m *Records) Unmarshal(dAtA []byte) error

func (*Records) XXX_DiscardUnknown added in v2.94.0

func (m *Records) XXX_DiscardUnknown()

func (*Records) XXX_Marshal added in v2.94.0

func (m *Records) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Records) XXX_Merge added in v2.94.0

func (m *Records) XXX_Merge(src proto.Message)

func (*Records) XXX_Size added in v2.94.0

func (m *Records) XXX_Size() int

func (*Records) XXX_Unmarshal added in v2.94.0

func (m *Records) XXX_Unmarshal(b []byte) error

type Service

type Service interface {
	UnregisterDiscovery
	io.Closer
}

func NewService

func NewService(opts *Opts, h host.Host, drivers ...*Driver) (Service, error)

type UnregisterDiscovery added in v2.277.0

type UnregisterDiscovery interface {
	p2p_discovery.Discovery
	Unregisterer
}

Driver is a Discovery with a unregister method

func NewRendezvousDiscovery

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

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