cluster

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 10 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
	// Network returns the cluster Network
	Network() Network
	// 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(network Network, 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

func WithDialScheme added in v0.9.1

func WithDialScheme(scheme string) ConnectOption

WithDialScheme sets the dial scheme 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(network Network, 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 Network added in v0.6.18

type Network interface {
	// Listen creates a new Listener
	Listen(address string) (net.Listener, error)
	// Connect creates a new Conn
	Connect(ctx context.Context, address string) (net.Conn, error)
}

Network is an interface for creating net Conns and Listeners.

func NewLocalNetwork added in v0.6.18

func NewLocalNetwork() Network

NewLocalNetwork creates a new process-local Network

func NewNetwork added in v0.6.18

func NewNetwork() Network

NewNetwork creates a new physical Network

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
	// Cluster returns the cluster to which the partition belongs
	Cluster() Cluster
	// 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() []*Replica
	// ReadReplica looks up a read replica in the partition
	ReadReplica(id ReplicaID) (*Replica, bool)
	// ReadReplicas returns the set of all read replicas in the partition
	ReadReplicas() []*Replica
	// Connect connects to the partition
	Connect(ctx context.Context, opts ...ConnectOption) (*grpc.ClientConn, error)
	// 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 []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(network Network, 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 []*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