quicmemberlist

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: GPL-3.0 Imports: 24 Imported by: 18

Documentation

Overview

Package quicmemberlist is transport layer of memberlist, based on quic stream.

Index

Constants

This section is empty.

Variables

View Source
var NodeHint = hint.MustNewHint("memberlist-node-v0.0.1")

Functions

func BasicMemberlistConfig

func BasicMemberlistConfig(name string, bind, advertise *net.UDPAddr) *memberlist.Config

Types

type AliveDelegate

type AliveDelegate struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewAliveDelegate

func NewAliveDelegate(
	enc *jsonenc.Encoder,
	laddr *net.UDPAddr,
	challengef DelegateNodeFunc,
	allowf DelegateNodeFunc,
) *AliveDelegate

func (*AliveDelegate) NotifyAlive

func (d *AliveDelegate) NotifyAlive(peer *memberlist.Node) error

type BaseNode

type BaseNode struct {
	hint.BaseHinter
	// contains filtered or unexported fields
}

func NewNode

func NewNode(
	name string,
	addr *net.UDPAddr,
	address base.Address,
	publickey base.Publickey,
	publish string,
	tlsinsecure bool,
) (BaseNode, error)

func (BaseNode) Address

func (n BaseNode) Address() base.Address

func (*BaseNode) DecodeJSON

func (n *BaseNode) DecodeJSON(b []byte, enc *jsonenc.Encoder) error

func (BaseNode) HashBytes

func (n BaseNode) HashBytes() []byte

func (BaseNode) IsValid

func (n BaseNode) IsValid([]byte) error

func (BaseNode) JoinedAt

func (n BaseNode) JoinedAt() time.Time

func (BaseNode) MarshalJSON

func (n BaseNode) MarshalJSON() ([]byte, error)

func (BaseNode) MarshalZerologObject

func (n BaseNode) MarshalZerologObject(e *zerolog.Event)

func (BaseNode) MetaBytes

func (n BaseNode) MetaBytes() []byte

func (BaseNode) Name

func (n BaseNode) Name() string

func (BaseNode) Publickey

func (n BaseNode) Publickey() base.Publickey

func (BaseNode) Publish

func (n BaseNode) Publish() NamedConnInfo

func (BaseNode) String

func (n BaseNode) String() string

func (BaseNode) TLSInsecure

func (n BaseNode) TLSInsecure() bool

func (BaseNode) UDPAddr

func (n BaseNode) UDPAddr() *net.UDPAddr

func (BaseNode) UDPConnInfo

func (n BaseNode) UDPConnInfo() quicstream.UDPConnInfo

type Broadcast

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

func NewBroadcast

func NewBroadcast(b []byte, id string, notifych chan struct{}) *Broadcast

func (*Broadcast) Finished

func (b *Broadcast) Finished()

func (*Broadcast) Invalidates

func (b *Broadcast) Invalidates(o memberlist.Broadcast) bool

func (*Broadcast) MarshalZerologObject

func (b *Broadcast) MarshalZerologObject(e *zerolog.Event)

func (*Broadcast) Message

func (b *Broadcast) Message() []byte

func (*Broadcast) UniqueBroadcast

func (*Broadcast) UniqueBroadcast()

type Delegate

type Delegate struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewDelegate

func NewDelegate(
	local Node,
	numNodes func() int,
	notifyMsgFunc func(b []byte),
) *Delegate

func (*Delegate) GetBroadcasts

func (d *Delegate) GetBroadcasts(overhead, limit int) [][]byte

func (*Delegate) LocalState

func (*Delegate) LocalState(bool) []byte

func (*Delegate) MergeRemoteState

func (*Delegate) MergeRemoteState([]byte, bool)

func (*Delegate) NodeMeta

func (d *Delegate) NodeMeta(int) []byte

func (*Delegate) NotifyMsg

func (d *Delegate) NotifyMsg(b []byte)

func (*Delegate) QueueBroadcast

func (d *Delegate) QueueBroadcast(b memberlist.Broadcast)

type DelegateJoinedFunc

type DelegateJoinedFunc func(Node)

type DelegateLeftFunc

type DelegateLeftFunc func(Node)

type DelegateNodeFunc

type DelegateNodeFunc func(Node) error

type DelegateStoreConnInfo

type DelegateStoreConnInfo func(quicstream.UDPConnInfo)

type EventsDelegate

type EventsDelegate struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewEventsDelegate

func NewEventsDelegate(
	enc *jsonenc.Encoder,
	joinedf DelegateJoinedFunc,
	leftf DelegateLeftFunc,
) *EventsDelegate

func (*EventsDelegate) NotifyJoin

func (d *EventsDelegate) NotifyJoin(peer *memberlist.Node)

func (*EventsDelegate) NotifyLeave

func (d *EventsDelegate) NotifyLeave(peer *memberlist.Node)

func (*EventsDelegate) NotifyUpdate

func (d *EventsDelegate) NotifyUpdate(peer *memberlist.Node)

type Memberlist

type Memberlist struct {
	*logging.Logging
	*util.ContextDaemon
	// contains filtered or unexported fields
}

func NewMemberlist

func NewMemberlist(
	local Node,
	enc *jsonenc.Encoder,
	config *memberlist.Config,
	sameMemberLimit uint64,
) (*Memberlist, error)

func (*Memberlist) Broadcast

func (srv *Memberlist) Broadcast(b memberlist.Broadcast)

func (*Memberlist) IsJoined

func (srv *Memberlist) IsJoined() bool

IsJoined indicates whether local is joined in remote network. If no other remote nodes, IsJoined will be false.

func (*Memberlist) Join

func (srv *Memberlist) Join(cis []quicstream.UDPConnInfo) error

func (*Memberlist) Leave

func (srv *Memberlist) Leave(timeout time.Duration) error

func (*Memberlist) Members

func (srv *Memberlist) Members(f func(node Node) bool)

func (*Memberlist) MembersLen

func (srv *Memberlist) MembersLen() int

func (*Memberlist) Remotes

func (srv *Memberlist) Remotes(f func(node Node) bool)

func (*Memberlist) SetLogging

func (srv *Memberlist) SetLogging(l *logging.Logging) *logging.Logging

func (*Memberlist) SetNotifyMsg

func (srv *Memberlist) SetNotifyMsg(f func([]byte))

func (*Memberlist) SetWhenLeftFunc

func (srv *Memberlist) SetWhenLeftFunc(f func(Node))

func (*Memberlist) Start

func (srv *Memberlist) Start(ctx context.Context) error

type NamedAddr

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

func (NamedAddr) Network

func (NamedAddr) Network() string

func (NamedAddr) String

func (a NamedAddr) String() string

type NamedConnInfo

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

func NewNamedConnInfo

func NewNamedConnInfo(addr string, tlsinsecure bool) NamedConnInfo

func (NamedConnInfo) Addr

func (c NamedConnInfo) Addr() net.Addr

func (NamedConnInfo) IsValid

func (c NamedConnInfo) IsValid([]byte) error

func (NamedConnInfo) MarshalText

func (c NamedConnInfo) MarshalText() ([]byte, error)

func (NamedConnInfo) String

func (c NamedConnInfo) String() string

func (NamedConnInfo) TLSInsecure

func (c NamedConnInfo) TLSInsecure() bool

func (NamedConnInfo) UDPConnInfo

func (c NamedConnInfo) UDPConnInfo() (ci quicstream.UDPConnInfo, _ error)

func (*NamedConnInfo) UnmarshalText

func (c *NamedConnInfo) UnmarshalText(b []byte) error

type Node

type Node interface {
	util.IsValider
	UDPAddr() *net.UDPAddr
	UDPConnInfo() quicstream.UDPConnInfo
	Name() string
	Address() base.Address
	Publickey() base.Publickey
	Publish() NamedConnInfo
	JoinedAt() time.Time
	MetaBytes() []byte
	HashBytes() []byte
}

type Transport

type Transport struct {
	*logging.Logging

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport(
	laddr *net.UDPAddr,
	dialf TransportDialFunc,
	writef TransportWriteFunc,
	notallowf func(string) bool,
) *Transport

func NewTransportWithQuicstream

func NewTransportWithQuicstream(
	laddr *net.UDPAddr,
	handlerPrefix string,
	poolclient *quicstream.PoolClient,
	newClient func(quicstream.UDPConnInfo) func(*net.UDPAddr) *quicstream.Client,
	notallowf func(string) bool,
) *Transport

func (*Transport) DialAddressTimeout

func (t *Transport) DialAddressTimeout(addr memberlist.Address, timeout time.Duration) (net.Conn, error)

func (*Transport) DialTimeout

func (t *Transport) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)

func (*Transport) FinalAdvertiseAddr

func (t *Transport) FinalAdvertiseAddr(ip string, port int) (net.IP, int, error)

func (*Transport) PacketCh

func (t *Transport) PacketCh() <-chan *memberlist.Packet

func (*Transport) ReceiveRaw

func (t *Transport) ReceiveRaw(b []byte, addr net.Addr) error

func (*Transport) Shutdown

func (t *Transport) Shutdown() error

func (*Transport) Start

func (t *Transport) Start(context.Context) error

func (*Transport) StreamCh

func (t *Transport) StreamCh() <-chan net.Conn

func (*Transport) WriteTo

func (t *Transport) WriteTo(b []byte, addr string) (time.Time, error)

func (*Transport) WriteToAddress

func (t *Transport) WriteToAddress(b []byte, addr memberlist.Address) (time.Time, error)

type TransportDialFunc

type TransportDialFunc func(context.Context, quicstream.UDPConnInfo) (quic.EarlyConnection, error)

type TransportGetConnInfo

type TransportGetConnInfo func(*net.UDPAddr) quicstream.UDPConnInfo

type TransportWriteFunc

type TransportWriteFunc func(context.Context, quicstream.UDPConnInfo, []byte) error

Jump to

Keyboard shortcuts

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