peer

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectOption added in v0.2.1

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

ConnectOption is an option for connecting to a peer

func WithDialOption added in v0.2.1

func WithDialOption(option grpc.DialOption) ConnectOption

WithDialOption creates a dial option for the gRPC connection

func WithDialOptions added in v0.2.1

func WithDialOptions(options ...grpc.DialOption) ConnectOption

WithDialOptions creates a dial option for the gRPC connection

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 NewGroupWithContext added in v0.3.1

func NewGroupWithContext(ctx context.Context, address string, opts ...Option) (*Group, error)

NewGroupWithContext 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 peer option

func WithHost added in v0.2.1

func WithHost(host string) Option

WithHost configures the peer's host

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 peer's member ID

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace configures the client's partition group namespace

func WithPort added in v0.2.1

func WithPort(port int) Option

WithPort configures the peer's port

func WithScope

func WithScope(scope string) Option

WithScope configures the application scope for the client

func WithServerOption added in v0.2.1

func WithServerOption(option grpc.ServerOption) Option

WithServerOption configures a server option

func WithServerOptions added in v0.2.1

func WithServerOptions(options ...grpc.ServerOption) Option

WithServerOptions configures server options

func WithService

func WithService(service Service) Option

WithService configures a peer-to-peer service

func WithServices added in v0.2.1

func WithServices(services ...Service) Option

WithServices configures peer-to-peer services

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(ctx context.Context, opts ...ConnectOption) (*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