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
- Variables
- func FilterAll(ms []ma.Multiaddr) []ma.Multiaddr
- func FilterDriverNameOption(driversName ...string) p2p_discovery.Option
- func NewFilterDriverDiscovery(disc p2p_discovery.Discovery, filters ...string) p2p_discovery.Discovery
- func NoFilter(ms []ma.Multiaddr) []ma.Multiaddr
- func NoopAddrsFactory(addrs []ma.Multiaddr) []ma.Multiaddr
- func PrivateAddrOnly(ms []ma.Multiaddr) []ma.Multiaddr
- func PublicAddrsOnly(ms []ma.Multiaddr) []ma.Multiaddr
- func WatchdogDiscoverKeepContextOption(opts *p2p_discovery.Options) error
- type BackoffOpts
- type Driver
- func NewDriverFromDiscovery(name string, disc p2p_discovery.Discovery, factory bhost.AddrsFactory) *Driver
- func NewDriverFromRouting(name string, routing routing.ContentRouting, factory bhost.AddrsFactory) *Driver
- func NewDriverFromUnregisterDiscovery(name string, udisc UnregisterDiscovery, factory bhost.AddrsFactory) *Driver
- func NewMockedDriverClient(name string, host p2p_host.Host, server *MockDriverServer) *Driver
- type DriverDiscovery
- type EventMonitor
- type EvtDriverMonitor
- type LocalDiscovery
- func (ld *LocalDiscovery) Advertise(ctx context.Context, cid string, opts ...discovery.Option) (time.Duration, error)
- func (ld *LocalDiscovery) Close() error
- func (ld *LocalDiscovery) Connected(net network.Network, c network.Conn)
- func (ld *LocalDiscovery) FindPeers(ctx context.Context, cid string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)
- func (ld *LocalDiscovery) Unregister(ctx context.Context, cid string) error
- type MockDriverClient
- func (d *MockDriverClient) Advertise(ctx context.Context, ns string, opts ...p2p_discovery.Option) (time.Duration, error)
- func (d *MockDriverClient) FindPeers(ctx context.Context, ns string, opts ...p2p_discovery.Option) (<-chan p2p_peer.AddrInfo, error)
- func (d *MockDriverClient) Name() string
- func (d *MockDriverClient) Unregister(ctx context.Context, ns string) error
- type MockDriverServer
- func (s *MockDriverServer) Advertise(ns string, info p2p_peer.AddrInfo, ttl time.Duration) (time.Duration, error)
- func (s *MockDriverServer) FindPeers(ns string, limit int) (<-chan p2p_peer.AddrInfo, error)
- func (s *MockDriverServer) HasPeerRecord(ns string, pid p2p_peer.ID) bool
- func (s *MockDriverServer) Reset()
- func (s *MockDriverServer) Unregister(ns string, pid p2p_peer.ID)
- func (s *MockDriverServer) WaitForAdvertise(ns string, pid p2p_peer.ID) chan struct{}
- type NetworkUpdate
- type Opts
- type Record
- func (*Record) Descriptor() ([]byte, []int)
- func (m *Record) GetCid() string
- func (m *Record) GetExpire() int64
- func (m *Record) Marshal() (dAtA []byte, err error)
- func (m *Record) MarshalTo(dAtA []byte) (int, error)
- func (m *Record) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Record) ProtoMessage()
- func (m *Record) Reset()
- func (m *Record) Size() (n int)
- func (m *Record) String() string
- func (m *Record) Unmarshal(dAtA []byte) error
- func (m *Record) XXX_DiscardUnknown()
- func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Record) XXX_Merge(src proto.Message)
- func (m *Record) XXX_Size() int
- func (m *Record) XXX_Unmarshal(b []byte) error
- type Records
- func (*Records) Descriptor() ([]byte, []int)
- func (m *Records) GetRecords() []*Record
- func (m *Records) Marshal() (dAtA []byte, err error)
- func (m *Records) MarshalTo(dAtA []byte) (int, error)
- func (m *Records) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Records) ProtoMessage()
- func (m *Records) Reset()
- func (m *Records) Size() (n int)
- func (m *Records) String() string
- func (m *Records) Unmarshal(dAtA []byte) error
- func (m *Records) XXX_DiscardUnknown()
- func (m *Records) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Records) XXX_Merge(src proto.Message)
- func (m *Records) XXX_Size() int
- func (m *Records) XXX_Unmarshal(b []byte) error
- type Service
- type UnregisterDiscovery
- type Unregisterer
Constants ¶
const ( DefaultFindPeerInterval = time.Minute * 30 DefaultAdvertiseInterval = time.Minute DefaultAdvertiseGracePeriod = time.Second * 10 )
const LocalDiscoveryName = "localdiscovery"
LocalDiscoveryName is the name of the localdiscovery driver
const TinderPeer = "Berty/TinderPeer"
Variables ¶
var ( ErrInvalidLengthRecords = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowRecords = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupRecords = fmt.Errorf("proto: unexpected end of group") )
var NoopDiscovery p2p_discovery.Discovery = &noopDiscovery{}
Functions ¶
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 NoopAddrsFactory ¶ added in v2.277.0
func PrivateAddrOnly ¶ added in v2.318.2
return anything but public addrs
func PublicAddrsOnly ¶ added in v2.318.2
return only public addrs
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 (*LocalDiscovery) Close ¶ added in v2.365.0
func (ld *LocalDiscovery) Close() error
func (*LocalDiscovery) Connected ¶ added in v2.365.0
func (ld *LocalDiscovery) Connected(net network.Network, c network.Conn)
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) 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 (*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) MarshalToSizedBuffer ¶ added in v2.94.0
func (*Record) ProtoMessage ¶ added in v2.94.0
func (*Record) ProtoMessage()
func (*Record) XXX_DiscardUnknown ¶ added in v2.94.0
func (m *Record) XXX_DiscardUnknown()
func (*Record) XXX_Marshal ¶ added in v2.94.0
func (*Record) XXX_Unmarshal ¶ added in v2.94.0
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) GetRecords ¶ added in v2.94.0
func (*Records) MarshalToSizedBuffer ¶ added in v2.94.0
func (*Records) ProtoMessage ¶ added in v2.94.0
func (*Records) ProtoMessage()
func (*Records) XXX_DiscardUnknown ¶ added in v2.94.0
func (m *Records) XXX_DiscardUnknown()
func (*Records) XXX_Marshal ¶ added in v2.94.0
func (*Records) XXX_Unmarshal ¶ added in v2.94.0
type Service ¶
type Service interface { UnregisterDiscovery io.Closer }
type UnregisterDiscovery ¶ added in v2.277.0
type UnregisterDiscovery interface { p2p_discovery.Discovery Unregisterer }
Driver is a Discovery with a unregister method
type Unregisterer ¶
var NoopUnregisterer Unregisterer = &noopUnregisterer{}