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 Schedule(t time.Time) p2p_discovery.Option
- type AsyncMultiDriver
- type AsyncableDriver
- type DHTDriver
- type Driver
- type DriverRouting
- 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) FindPeersAsync(ctx context.Context, outChan chan<- p2p_peer.AddrInfo, ns string, limit int)
- 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)
- type MultiDriver
- func (md *MultiDriver) Advertise(ctx context.Context, ns string, opts ...p2p_discovery.Option) (time.Duration, error)
- func (md *MultiDriver) FindPeers(ctx context.Context, ns string, opts ...p2p_discovery.Option) (<-chan p2p_peer.AddrInfo, error)
- func (md *MultiDriver) FindPeersAsync(ctx context.Context, outPeers chan<- p2p_peer.AddrInfo, ns string, ...) error
- func (*MultiDriver) Name() string
- func (md *MultiDriver) Unregister(ctx context.Context, ns string) error
- 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 StreamWrapper
- type Unregisterer
Constants ¶
const ScheduleKey = "Schedule"
Variables ¶
Functions ¶
Types ¶
type AsyncMultiDriver ¶ added in v2.149.0
type AsyncMultiDriver struct{ MultiDriver }
type AsyncableDriver ¶ added in v2.149.0
type AsyncableDriver interface { // AsyncableDriver implements Driver to simplify the creation pipeline. // Creator returns AsyncableDriver so that fit both cases. Driver // FindPeersAsync works differently than FindPeers. // FindPeersAsync is not expected to close the chan. // Also it's expected to start a goroutine to run the expensive part of the search. // And it's only when the caller have received enough valid peers he shutdown the search canceling the context. FindPeersAsync(context.Context, chan<- peer.AddrInfo, string, ...discovery.Option) error }
AsyncableDriver allows MultiDriver to reuse the same chan for multiple drivers.
func NewAsyncMultiDriver ¶ added in v2.149.0
func NewAsyncMultiDriver(logger *zap.Logger, drivers ...AsyncableDriver) AsyncableDriver
func NewMockedDriverClient ¶
func NewMockedDriverClient(host p2p_host.Host, server *MockDriverServer) AsyncableDriver
type DHTDriver ¶ added in v2.50.0
type DHTDriver struct { p2p_discovery.Discovery Unregisterer }
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 NewLocalDiscovery ¶ added in v2.94.0
type DriverRouting ¶ added in v2.109.0
type DriverRouting interface { p2p_routing.Routing Driver }
func NewDriverRouting ¶ added in v2.109.0
func NewDriverRouting(logger *zap.Logger, name string, r p2p_routing.Routing) DriverRouting
type MockDriverServer ¶
type MockDriverServer struct {
// contains filtered or unexported fields
}
func NewMockedDriverServer ¶
func NewMockedDriverServer() *MockDriverServer
func (*MockDriverServer) FindPeersAsync ¶ added in v2.149.0
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)
func (*MultiDriver) FindPeersAsync ¶ added in v2.149.0
func (md *MultiDriver) FindPeersAsync(ctx context.Context, outPeers chan<- p2p_peer.AddrInfo, ns string, opts ...p2p_discovery.Option) error
FindPeersAsync expect the caller to use it asynchronously and cancel the context with enough peers or found (or deadline exceeded). If the context is not canceled the search will go indefinitely.
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 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 { Driver }
Tinder service is a simple driver backed by a cache,
func NewService ¶
func NewService(logger *zap.Logger, driver Driver, stratFactory p2p_discovery.BackoffFactory, opts ...p2p_discovery.BackoffDiscoveryOption) (Service, error)
type StreamWrapper ¶ added in v2.94.0
type StreamWrapper struct { network.Stream io.ReadWriter }
type Unregisterer ¶
var NoopUnregisterer Unregisterer = &noopUnregisterer{}