Documentation
¶
Index ¶
- func HashFromAddr(id, host string, port uint32) string
- func Init(conf *Config)
- type CommandServer
- func (s *CommandServer) Del(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CommandResponse, error)
- func (s *CommandServer) Get(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CommandResponse, error)
- func (s *CommandServer) Set(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CommandResponse, error)
- func (s *CommandServer) Start()
- type Config
- type Coordinator
- type CoordinatorServer
- func (cs *CoordinatorServer) Del(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CoordinatorResponse, error)
- func (cs *CoordinatorServer) Get(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CoordinatorResponse, error)
- func (cs *CoordinatorServer) Set(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CoordinatorResponse, error)
- func (cs *CoordinatorServer) Start()
- type GossipConfig
- type Node
- type NodeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashFromAddr ¶
Types ¶
type CommandServer ¶
type CommandServer struct { nodegrpc.UnimplementedCommandApiServer // contains filtered or unexported fields }
func (*CommandServer) Del ¶
func (s *CommandServer) Del(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CommandResponse, error)
func (*CommandServer) Get ¶
func (s *CommandServer) Get(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CommandResponse, error)
func (*CommandServer) Set ¶
func (s *CommandServer) Set(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CommandResponse, error)
func (*CommandServer) Start ¶
func (s *CommandServer) Start()
type Config ¶
type Config struct { Node NodeConfig Gossip GossipConfig // Dev or Production mode DevMode bool }
func (*Config) GetCoordinatorAddr ¶
func (*Config) GetGossipAddr ¶
func (*Config) GetNodeAddr ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator acts as a proxy to the clients to store or receive key/values from the cluster. The coordinator handles replication and consistency. In a write-scenario, coordinator locates the right nodes for a KEY in the ring, then sends N concurrent write-requests to corresponding nodes and waits to receive W successful responses (Quorum Consensus with N replica).
func NewCoordinator ¶
func NewCoordinator(conf *Config, nodeSrv *nodeService, storageSrv *storageService, ring *ring.Ring[*Node]) *Coordinator
type CoordinatorServer ¶
type CoordinatorServer struct { nodegrpc.UnimplementedCoordinatorApiServer // contains filtered or unexported fields }
CoordinatorServer handles the communication between client and cluster. It receives GET/PUT/... requests from clients and coordinates the request to the cluster. TODO: implement REST server/controller
func (*CoordinatorServer) Del ¶
func (cs *CoordinatorServer) Del(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CoordinatorResponse, error)
func (*CoordinatorServer) Get ¶
func (cs *CoordinatorServer) Get(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CoordinatorResponse, error)
func (*CoordinatorServer) Set ¶
func (cs *CoordinatorServer) Set(ctx context.Context, command *nodegrpc.Command) (*nodegrpc.CoordinatorResponse, error)
func (*CoordinatorServer) Start ¶
func (cs *CoordinatorServer) Start()
type Node ¶
type Node struct { Id string Name string Host string Port uint32 RamSize uint32 Conn *grpc.ClientConn Client nodegrpc.CommandApiClient }
Node Implements ring.Comparable in order to be saved on the ring
func (*Node) MarshalLogObject ¶
func (n *Node) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject helps the `zap` to create a structural log of cacheNode object