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
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 Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option provides a peer option
func WithMemberID ¶
WithMemberID configures the peer's member ID
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 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
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