Documentation ¶
Index ¶
- Variables
- func Dial(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func GetHashID(key string) []byte
- func NewInode(id string, addr string) *models.Node
- type Config
- type GrpcTransport
- func (g *GrpcTransport) CheckPredecessor(node *models.Node) error
- func (g *GrpcTransport) DeleteKey(node *models.Node, key string) error
- func (g *GrpcTransport) DeleteKeys(node *models.Node, keys []string) error
- func (g *GrpcTransport) FindSuccessor(node *models.Node, id []byte) (*models.Node, error)
- func (g *GrpcTransport) GetKey(node *models.Node, key string) (*models.GetResponse, error)
- func (g *GrpcTransport) GetPredecessor(node *models.Node) (*models.Node, error)
- func (g *GrpcTransport) GetServer() *grpc.Server
- func (g *GrpcTransport) GetSuccessor(node *models.Node) (*models.Node, error)
- func (g *GrpcTransport) Notify(node, pred *models.Node) error
- func (g *GrpcTransport) RequestKeys(node *models.Node, from, to []byte) ([]*models.KV, error)
- func (g *GrpcTransport) SetKey(node *models.Node, key, value string) error
- func (g *GrpcTransport) SetPredecessor(node *models.Node, pred *models.Node) error
- func (g *GrpcTransport) SetSuccessor(node *models.Node, succ *models.Node) error
- func (g *GrpcTransport) Start() error
- func (g *GrpcTransport) Stop() error
- type Node
- func (n *Node) CheckPredecessor(ctx context.Context, id *models.ID) (*models.ER, error)
- func (n *Node) Delete(key string) error
- func (n *Node) Find(key string) (*models.Node, error)
- func (n *Node) FindSuccessor(ctx context.Context, id *models.ID) (*models.Node, error)
- func (n *Node) Get(key string) ([]byte, error)
- func (n *Node) GetPredecessor(ctx context.Context, r *models.ER) (*models.Node, error)
- func (n *Node) GetSuccessor(ctx context.Context, r *models.ER) (*models.Node, error)
- func (n *Node) Notify(ctx context.Context, node *models.Node) (*models.ER, error)
- func (n *Node) Set(key, value string) error
- func (n *Node) SetPredecessor(ctx context.Context, pred *models.Node) (*models.ER, error)
- func (n *Node) SetSuccessor(ctx context.Context, succ *models.Node) (*models.ER, error)
- func (n *Node) Stop()
- func (n *Node) XDelete(ctx context.Context, req *models.DeleteRequest) (*models.DeleteResponse, error)
- func (n *Node) XGet(ctx context.Context, req *models.GetRequest) (*models.GetResponse, error)
- func (n *Node) XMultiDelete(ctx context.Context, req *models.MultiDeleteRequest) (*models.DeleteResponse, error)
- func (n *Node) XRequestKeys(ctx context.Context, req *models.RequestKeysRequest) (*models.RequestKeysResponse, error)
- func (n *Node) XSet(ctx context.Context, req *models.SetRequest) (*models.SetResponse, error)
- type Storage
- type Transport
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Dial ¶
func Dial(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
Types ¶
type Config ¶
type Config struct { Id string Addr string ServerOpts []grpc.ServerOption DialOpts []grpc.DialOption Hash func() hash.Hash // Hash function to use HashSize int StabilizeMin time.Duration // Minimum stabilization time StabilizeMax time.Duration // Maximum stabilization time Timeout time.Duration MaxIdle time.Duration }
func DefaultConfig ¶
func DefaultConfig() *Config
type GrpcTransport ¶
type GrpcTransport struct {
// contains filtered or unexported fields
}
func NewGrpcTransport ¶
func NewGrpcTransport(config *Config) (*GrpcTransport, error)
func NewGrpcTransport(config *Config) (models.ChordClient, error) {
func (*GrpcTransport) CheckPredecessor ¶
func (g *GrpcTransport) CheckPredecessor(node *models.Node) error
func (*GrpcTransport) DeleteKey ¶
func (g *GrpcTransport) DeleteKey(node *models.Node, key string) error
func (*GrpcTransport) DeleteKeys ¶
func (g *GrpcTransport) DeleteKeys(node *models.Node, keys []string) error
func (*GrpcTransport) FindSuccessor ¶
FindSuccessor the successor ID of a remote node.
func (*GrpcTransport) GetKey ¶
func (g *GrpcTransport) GetKey(node *models.Node, key string) (*models.GetResponse, error)
func (*GrpcTransport) GetPredecessor ¶
GetPredecessor the successor ID of a remote node.
func (*GrpcTransport) GetServer ¶
func (g *GrpcTransport) GetServer() *grpc.Server
func (*GrpcTransport) GetSuccessor ¶
GetSuccessor the successor ID of a remote node.
func (*GrpcTransport) RequestKeys ¶
func (*GrpcTransport) SetKey ¶
func (g *GrpcTransport) SetKey(node *models.Node, key, value string) error
func (*GrpcTransport) SetPredecessor ¶
func (*GrpcTransport) SetSuccessor ¶
func (*GrpcTransport) Start ¶
func (g *GrpcTransport) Start() error
type Node ¶
func NewNode ¶
NewNode creates a new Chord node. Returns error if node already exists in the chord ring
func (*Node) CheckPredecessor ¶
func (*Node) FindSuccessor ¶
func (*Node) GetPredecessor ¶
func (*Node) GetSuccessor ¶
GetSuccessor gets the successor on the node..
func (*Node) SetPredecessor ¶
SetPredecessor sets the predecessor on the node..
func (*Node) SetSuccessor ¶
SetSuccessor sets the successor on the node..
func (*Node) XDelete ¶
func (n *Node) XDelete(ctx context.Context, req *models.DeleteRequest) (*models.DeleteResponse, error)
func (*Node) XGet ¶
func (n *Node) XGet(ctx context.Context, req *models.GetRequest) (*models.GetResponse, error)
func (*Node) XMultiDelete ¶
func (n *Node) XMultiDelete(ctx context.Context, req *models.MultiDeleteRequest) (*models.DeleteResponse, error)
func (*Node) XRequestKeys ¶
func (n *Node) XRequestKeys(ctx context.Context, req *models.RequestKeysRequest) (*models.RequestKeysResponse, error)
func (*Node) XSet ¶
func (n *Node) XSet(ctx context.Context, req *models.SetRequest) (*models.SetResponse, error)
type Storage ¶
type Storage interface { Get(string) ([]byte, error) Set(string, string) error Delete(string) error Between([]byte, []byte) ([]*models.KV, error) MDelete(...string) error }
func NewMapStore ¶
type Transport ¶
type Transport interface { Start() error Stop() error //RPC GetSuccessor(*models.Node) (*models.Node, error) FindSuccessor(*models.Node, []byte) (*models.Node, error) GetPredecessor(*models.Node) (*models.Node, error) Notify(*models.Node, *models.Node) error CheckPredecessor(*models.Node) error SetPredecessor(*models.Node, *models.Node) error SetSuccessor(*models.Node, *models.Node) error //Storage GetKey(*models.Node, string) (*models.GetResponse, error) SetKey(*models.Node, string, string) error DeleteKey(*models.Node, string) error RequestKeys(*models.Node, []byte, []byte) ([]*models.KV, error) DeleteKeys(*models.Node, []string) error }
Transport enables a node to talk to the other nodes in the ring
Click to show internal directories.
Click to hide internal directories.