cluster

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: Apache-2.0 Imports: 8 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster interface {
	io.Closer
	// Member returns the local cluster member
	Member() (*Member, bool)
	// Replica looks up a replica by ID
	Replica(id ReplicaID) (*Replica, bool)
	// Replicas returns the set of all replicas in the cluster
	Replicas() ReplicaSet
	// Partition looks up a partition by ID
	Partition(id PartitionID) (Partition, bool)
	// Partitions returns the set of all partitions in the cluster
	Partitions() PartitionSet
}

Cluster manages the peer group for a client

func NewCluster

func NewCluster(config protocolapi.ProtocolConfig, opts ...Option) Cluster

NewCluster creates a new cluster

type ConfigurableCluster

type ConfigurableCluster interface {
	Update(config protocolapi.ProtocolConfig) error
}

ConfigurableCluster is an interface for configurable clusters

type ConfigurablePartition

type ConfigurablePartition interface {
	Update(protocolapi.ProtocolPartition) error
}

ConfigurablePartition is an interface for configurable Partitions

type ConnectOption

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

ConnectOption is an option for connecting to a peer

func WithDialOption

func WithDialOption(option grpc.DialOption) ConnectOption

WithDialOption creates a dial option for the gRPC connection

func WithDialOptions

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

WithDialOptions creates a dial option for the gRPC connection

type Member

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

Member is a local group member

func NewMember

func NewMember(config protocolapi.ProtocolReplica) *Member

NewMember returns a new local group member

func (*Member) Serve

func (m *Member) Serve(opts ...ServeOption) error

Serve begins serving the local member

func (*Member) Stop

func (m *Member) Stop() error

Stop stops the local member serving

type NodeID

type NodeID string

NodeID is a host node identifier

type Option

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

Option provides a peer option

func WithHost

func WithHost(host string) Option

WithHost configures the peer's host

func WithMemberID

func WithMemberID(memberID string) Option

WithMemberID configures the peer's member ID

func WithNodeID

func WithNodeID(nodeID string) Option

WithNodeID configures the peer's node ID

func WithPort

func WithPort(port int) Option

WithPort configures the peer's port

type Partition

type Partition interface {
	// ID returns the partition identifier
	ID() PartitionID
	// Member returns the local partition member
	Member() (*Member, bool)
	// Replica looks up a replica in the partition
	Replica(id ReplicaID) (*Replica, bool)
	// Replicas returns the set of all replicas in the partition
	Replicas() ReplicaSet
	// Watch watches the partition for changes
	Watch(ctx context.Context, ch chan<- ReplicaSet) error
}

Partition is a cluster partition

func NewPartition

func NewPartition(config protocolapi.ProtocolPartition, cluster Cluster) Partition

NewPartition returns a new replica

type PartitionID

type PartitionID uint32

PartitionID is a partition identifier

type PartitionSet

type PartitionSet map[PartitionID]Partition

PartitionSet is a set of partitions

type Replica

type Replica struct {
	ID     ReplicaID
	NodeID NodeID
	Host   string
	Port   int
	// contains filtered or unexported fields
}

Replica is a replicas group peer

func NewReplica

func NewReplica(config protocolapi.ProtocolReplica) *Replica

NewReplica returns a new replica

func (*Replica) Connect

func (m *Replica) Connect(ctx context.Context, opts ...ConnectOption) (*grpc.ClientConn, error)

Connect connects to the replica

func (*Replica) GetPort

func (m *Replica) GetPort(name string) int

GetPort gets a named port

type ReplicaID

type ReplicaID string

ReplicaID is a peer identifier

type ReplicaSet

type ReplicaSet map[ReplicaID]*Replica

ReplicaSet is a set of replicas

type ServeOption

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

ServeOption provides a member serve option

func WithServerOption

func WithServerOption(option grpc.ServerOption) ServeOption

WithServerOption configures a server option

func WithServerOptions

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

WithServerOptions configures server options

func WithService

func WithService(service Service) ServeOption

WithService configures a peer-to-peer service

func WithServices

func WithServices(services ...Service) ServeOption

WithServices configures peer-to-peer services

type Service

type Service func(*grpc.Server)

Service is a peer-to-peer primitive service

Jump to

Keyboard shortcuts

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