tinder

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: Apache-2.0, MIT Imports: 33 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// LocalDiscoveryName is the name of the localdiscovery driver
	LocalDiscoveryName = "localdisc"
)

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 ErrNotSupported = fmt.Errorf("not supported")

Functions

func AllAddrsFactory

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

func MockBufferSize

func MockBufferSize(size int) discovery.Option

func PrivateAddrsOnlyFactory

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

keep private addr only

func PublicAddrsOnlyFactory

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

keep public addr only

Types

type AddrsFilter

type AddrsFilter = bhost.AddrsFactory

type DiscoveryAdaptater

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

func NewDiscoveryAdaptater

func NewDiscoveryAdaptater(logger *zap.Logger, service *Service, defaultOpts ...Option) *DiscoveryAdaptater

func (*DiscoveryAdaptater) Advertise

func (a *DiscoveryAdaptater) Advertise(_ context.Context, topic string, opts ...discovery.Option) (time.Duration, error)

func (*DiscoveryAdaptater) Close

func (a *DiscoveryAdaptater) Close() error

func (*DiscoveryAdaptater) FindPeers

func (a *DiscoveryAdaptater) FindPeers(ctx context.Context, topic string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)

type DiscoveryDriver

type DiscoveryDriver struct {
	discovery.Discovery
	// contains filtered or unexported fields
}

func (*DiscoveryDriver) Advertise

func (d *DiscoveryDriver) Advertise(ctx context.Context, topic string, opts ...discovery.Option) (time.Duration, error)

discovery advertise

func (*DiscoveryDriver) FindPeers

func (d *DiscoveryDriver) FindPeers(ctx context.Context, topic string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)

discovery find peers

func (*DiscoveryDriver) Name

func (d *DiscoveryDriver) Name() string

func (*DiscoveryDriver) Subscribe

func (d *DiscoveryDriver) Subscribe(_ context.Context, _ string, _ ...discovery.Option) (<-chan peer.AddrInfo, error)

func (*DiscoveryDriver) Unregister

func (d *DiscoveryDriver) Unregister(_ context.Context, _ string, _ ...discovery.Option) error

type Filter

type Filter map[string]struct{}

func (Filter) ShouldFilter

func (f Filter) ShouldFilter(name string) (yes bool)

type IDriver

type IDriver interface {
	Name() string
	Subscribe(ctx context.Context, topic string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)
	Unregister(ctx context.Context, topic string, opts ...discovery.Option) error

	// discovery
	Advertise(ctx context.Context, ns string, opts ...discovery.Option) (time.Duration, error)
	FindPeers(ctx context.Context, ns string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)
}

func NewDiscoveryDriver

func NewDiscoveryDriver(name string, disc discovery.Discovery) IDriver

func NewRendezvousDiscovery

func NewRendezvousDiscovery(logger *zap.Logger, host host.Host, rdvPeer peer.ID, factory p2p_rp.AddrsFactory, rng *mrand.Rand, emitters ...p2p_rp.RendezvousSyncClient) IDriver

func NewRoutingDiscoveryDriver

func NewRoutingDiscoveryDriver(name string, routing routing.Routing) IDriver

type LocalDiscovery

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

func NewLocalDiscovery

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

func (*LocalDiscovery) Advertise

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

func (*LocalDiscovery) Close

func (ld *LocalDiscovery) Close() error

func (*LocalDiscovery) FindPeers

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

func (*LocalDiscovery) Name

func (ld *LocalDiscovery) Name() string

func (*LocalDiscovery) Subscribe

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

func (*LocalDiscovery) Unregister

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

type MockDriverServer

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

func NewMockDriverServer

func NewMockDriverServer() *MockDriverServer

func (*MockDriverServer) Advertise

func (s *MockDriverServer) Advertise(topic string, info peer.AddrInfo, ttl time.Duration)

func (*MockDriverServer) Client

func (s *MockDriverServer) Client(h host.Host) IDriver

func (*MockDriverServer) Exist

func (s *MockDriverServer) Exist(topic string, p peer.ID) (ok bool)

func (*MockDriverServer) FindPeers

func (s *MockDriverServer) FindPeers(topic string, limit int) <-chan peer.AddrInfo

func (*MockDriverServer) Subscribe

func (s *MockDriverServer) Subscribe(ctx context.Context, topic string, buffsize int) <-chan peer.AddrInfo

func (*MockDriverServer) Unregister

func (s *MockDriverServer) Unregister(ctx context.Context, topic string, p peer.ID)

func (*MockDriverServer) WaitForPeer

func (s *MockDriverServer) WaitForPeer(topic string, p peer.ID, timeout time.Duration) (err error)

type MockIDriverClient

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

func (*MockIDriverClient) Advertise

func (s *MockIDriverClient) Advertise(ctx context.Context, topic string, opts ...discovery.Option) (time.Duration, error)

func (*MockIDriverClient) FindPeers

func (s *MockIDriverClient) FindPeers(ctx context.Context, topic string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)

func (*MockIDriverClient) Name

func (s *MockIDriverClient) Name() string

func (*MockIDriverClient) Subscribe

func (s *MockIDriverClient) Subscribe(ctx context.Context, topic string, opts ...discovery.Option) (<-chan peer.AddrInfo, error)

func (*MockIDriverClient) Unregister

func (s *MockIDriverClient) Unregister(ctx context.Context, topic string, opts ...discovery.Option) error

type NetworkUpdate

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

func NewNetworkUpdate

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

func (*NetworkUpdate) Close

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

func (*NetworkUpdate) GetLastUpdatedAddrs

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

func (*NetworkUpdate) WaitForUpdate

func (n *NetworkUpdate) WaitForUpdate(ctx context.Context, currentAddrs []ma.Multiaddr) (diff []ma.Multiaddr, ok bool)

type Option

type Option func(opts *Options) error

func FilterOutDrivers

func FilterOutDrivers(drivers ...string) Option

type Options

type Options struct {
	DriverFilters Filter
}

type PeersUpdate

type PeersUpdate map[peer.ID]time.Time

func (PeersUpdate) HasUpdate

func (current PeersUpdate) HasUpdate(tu *topicUpdate) []peer.ID

type Record

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

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

func (*Record) GetCid

func (m *Record) GetCid() string

func (*Record) GetExpire

func (m *Record) GetExpire() int64

func (*Record) Marshal

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

func (*Record) MarshalTo

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

func (*Record) MarshalToSizedBuffer

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

func (*Record) ProtoMessage

func (*Record) ProtoMessage()

func (*Record) Reset

func (m *Record) Reset()

func (*Record) Size

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

func (*Record) String

func (m *Record) String() string

func (*Record) Unmarshal

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

func (*Record) XXX_DiscardUnknown

func (m *Record) XXX_DiscardUnknown()

func (*Record) XXX_Marshal

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

func (*Record) XXX_Merge

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

func (*Record) XXX_Size

func (m *Record) XXX_Size() int

func (*Record) XXX_Unmarshal

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

type Records

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

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

func (*Records) GetRecords

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

func (*Records) Marshal

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

func (*Records) MarshalTo

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

func (*Records) MarshalToSizedBuffer

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

func (*Records) ProtoMessage

func (*Records) ProtoMessage()

func (*Records) Reset

func (m *Records) Reset()

func (*Records) Size

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

func (*Records) String

func (m *Records) String() string

func (*Records) Unmarshal

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

func (*Records) XXX_DiscardUnknown

func (m *Records) XXX_DiscardUnknown()

func (*Records) XXX_Marshal

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

func (*Records) XXX_Merge

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

func (*Records) XXX_Size

func (m *Records) XXX_Size() int

func (*Records) XXX_Unmarshal

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

type Service

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

func NewService

func NewService(h host.Host, logger *zap.Logger, drivers ...IDriver) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) FindPeers

func (s *Service) FindPeers(ctx context.Context, topic string) <-chan peer.AddrInfo

func (*Service) GetProcess

func (s *Service) GetProcess() uint32

func (*Service) LookupPeers

func (s *Service) LookupPeers(ctx context.Context, topic string, opts ...Option) error

func (*Service) StartAdvertises

func (s *Service) StartAdvertises(ctx context.Context, topic string, opts ...Option) error

StartAdvertises topic on each of service drivers

func (*Service) Subscribe

func (s *Service) Subscribe(topic string, opts ...Option) *Subscription

func (*Service) Unregister

func (s *Service) Unregister(ctx context.Context, topic string) error

Unregister try to unregister topic on each of his driver

func (*Service) WatchPeers

func (s *Service) WatchPeers(ctx context.Context, topic string) <-chan peer.AddrInfo

func (*Service) WatchTopic

func (s *Service) WatchTopic(ctx context.Context, topic string, opts ...Option) (err error)

type Subscription

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

func (*Subscription) Close

func (s *Subscription) Close() error

func (*Subscription) Out

func (s *Subscription) Out() <-chan peer.AddrInfo

func (*Subscription) Pull

func (s *Subscription) Pull() error

Jump to

Keyboard shortcuts

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