peer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	Namespace string
	Name      string
	// contains filtered or unexported fields
}

Group manages the peer group for a client

func NewGroup

func NewGroup(address string, opts ...Option) (*Group, error)

NewGroup creates a new peer group

func (*Group) Close

func (c *Group) Close() error

Close closes the group

func (*Group) Member

func (c *Group) Member() *Peer

Member returns the local group member

func (*Group) Peer

func (c *Group) Peer(id ID) *Peer

Peer returns a peer by ID

func (*Group) Peers

func (c *Group) Peers() Set

Peers returns the current group peers

func (*Group) Watch

func (c *Group) Watch(ctx context.Context, ch chan<- Set) error

Watch watches the peers for changes

type ID

type ID string

ID is a peer identifier

type Member

type Member struct {
	*Peer
	// contains filtered or unexported fields
}

Member is a local group member

func NewMember

func NewMember(id ID, host string, port int, services ...Service) *Member

NewMember returns a new local group member

func (*Member) Stop

func (m *Member) Stop()

Stop stops the local member serving

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option provides a client option

func WithApplication

func WithApplication(application string) Option

WithApplication configures the application name for the client Deprecated: Use WithScope instead

func WithJoinTimeout

func WithJoinTimeout(timeout time.Duration) Option

WithJoinTimeout configures the client's join timeout

func WithMemberID

func WithMemberID(memberID string) Option

WithMemberID configures the client's member ID

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace configures the client's partition group namespace

func WithPeerHost

func WithPeerHost(host string) Option

WithPeerHost configures the client's peer host

func WithPeerPort

func WithPeerPort(port int) Option

WithPeerPort configures the client's peer port

func WithScope

func WithScope(scope string) Option

WithScope configures the application scope for the client

func WithService

func WithService(service Service) Option

WithService configures a peer-to-peer service

type Peer

type Peer struct {
	ID   ID
	Host string
	Port int
	// contains filtered or unexported fields
}

Peer is a peers group peer

func NewPeer

func NewPeer(id ID, host string, port int) *Peer

NewPeer returns a new group peer

func (*Peer) Connect

func (m *Peer) Connect() (*grpc.ClientConn, error)

Connect connects to the member

type Service

type Service func(ID, *grpc.Server)

Service is a peer-to-peer primitive service

type Set

type Set map[ID]*Peer

Set is a set of peers

Jump to

Keyboard shortcuts

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