Documentation
¶
Index ¶
- func GetRandomCoordinates(dims uint) []float32
- func LoadTLSCredentials(ipAddress string) (credentials.TransportCredentials, error)
- func LoggingUnaryClientInterceptor(logger *logrus.Logger) grpc.UnaryClientInterceptor
- func LoggingUnaryServerInterceptor(logger *logrus.Logger) grpc.UnaryServerInterceptor
- func NodeInfoToProto(nodeInfo topology.NodeInfo) *pb.Node
- func SetupNodeTLS(bootstrapClient pb.BootstrapServiceClient, ip string, port int) error
- type Cache
- type Node
- func (node *Node) AddNeighbor(ctx context.Context, req *pb.AddNeighborRequest) (*pb.AddNeighborResponse, error)
- func (node *Node) CleanupStaleConnections()
- func (node *Node) Delete(ctx context.Context, req *pb.DeleteRequest) (*pb.DeleteResponse, error)
- func (node *Node) DeleteImplementation(key string, hashToUse int) error
- func (node *Node) DetectNodeFailure()
- func (node *Node) ElectTakeoverCoordinator(ctx context.Context, req *pb.CoordinatorElectionRequest) (*pb.CoordinatorElectionResponse, error)
- func (node *Node) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error)
- func (node *Node) GetHelper(helperCtx context.Context, key string, hashIdx int) ([]byte, error)
- func (node *Node) GetImplementation(key string, hashToUse int) ([]byte, error)
- func (node *Node) GetInfo() (string, []float32, []float32)
- func (node *Node) GetNeighbors(ctx context.Context, req *pb.GetNeighborsRequest) (*pb.GetNeighborsResponse, error)
- func (node *Node) GetNewCache(size int, ttl time.Duration) *Cache
- func (node *Node) HandleCrashDetection(crashedNodeId string, crashedNodeAddress string)
- func (node *Node) Heartbeat(ctx context.Context, req *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error)
- func (node *Node) HeartbeatRoutine()
- func (node *Node) InitiateLeave(ctx context.Context, req *pb.LeaveRequest) (*pb.LeaveResponse, error)
- func (node *Node) Join(ctx context.Context, req *pb.JoinRequest) (*pb.JoinResponse, error)
- func (node *Node) JoinImplementation(bootstrapAddr string) error
- func (node *Node) LeaveImplementation() error
- func (node *Node) NotifyAllNeighboursOfTwoHopInfo()
- func (node *Node) NotifyNeighbors() error
- func (node *Node) NotifyZoneMerge(ctx context.Context, notification *pb.ZoneMergeNotification) (*pb.ZoneMergeResponse, error)
- func (node *Node) PerformDFS(ctx context.Context, req *pb.DFSRequest) (*pb.DFSResponse, error)
- func (node *Node) Put(ctx context.Context, req *pb.PutRequest) (*pb.PutResponse, error)
- func (node *Node) PutImplementation(key string, value []byte, hashToUse int) error
- func (node *Node) SendNeighbourInfo(ctx context.Context, req *pb.NeighbourInfoRequest) (*pb.NeighbourInfoResponse, error)
- func (node *Node) StartCrashDetection()
- func (node *Node) StartGRPCServer(ip string, port int, bootstrapAddr string) error
- func (node *Node) TakeoverZone(ctx context.Context, req *pb.TakeoverRequest) (*pb.TakeoverResponse, error)
- func (node *Node) TransferData(ctx context.Context, req *pb.TransferDataRequest) (*pb.TransferDataResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRandomCoordinates ¶
func LoadTLSCredentials ¶
func LoadTLSCredentials(ipAddress string) (credentials.TransportCredentials, error)
Get the TLS config
func LoggingUnaryClientInterceptor ¶
func LoggingUnaryClientInterceptor(logger *logrus.Logger) grpc.UnaryClientInterceptor
LoggingUnaryClientInterceptor returns a gRPC client interceptor for logging
func LoggingUnaryServerInterceptor ¶
func LoggingUnaryServerInterceptor(logger *logrus.Logger) grpc.UnaryServerInterceptor
LoggingUnaryServerInterceptor returns a gRPC server interceptor for logging
func NodeInfoToProto ¶
Helper function to convert NodeInfo to proto message
func SetupNodeTLS ¶
func SetupNodeTLS(bootstrapClient pb.BootstrapServiceClient, ip string, port int) error
Types ¶
type Node ¶
type Node struct {
pb.UnimplementedCANNodeServer
IPAddress string
Info *topology.NodeInfo
RoutingTable *routing.RoutingTable
NeighInfo []topology.NodeInfo
KVStore *store.MemoryStore
QueryCache *Cache
// contains filtered or unexported fields
}
func (*Node) AddNeighbor ¶
func (node *Node) AddNeighbor(ctx context.Context, req *pb.AddNeighborRequest) (*pb.AddNeighborResponse, error)
AddNeighbor handles requests to add a node as a neighbor
func (*Node) CleanupStaleConnections ¶
func (node *Node) CleanupStaleConnections()
func (*Node) Delete ¶
func (node *Node) Delete(ctx context.Context, req *pb.DeleteRequest) (*pb.DeleteResponse, error)
func (*Node) DeleteImplementation ¶
DeleteImplementation This function is used to delete a key in the DHT.
func (*Node) DetectNodeFailure ¶
func (node *Node) DetectNodeFailure()
DetectNodeFailure is called periodically to check for failed nodes
func (*Node) ElectTakeoverCoordinator ¶
func (node *Node) ElectTakeoverCoordinator(ctx context.Context, req *pb.CoordinatorElectionRequest) (*pb.CoordinatorElectionResponse, error)
ElectTakeoverCoordinator handles election requests for takeover coordinator
func (*Node) Get ¶
func (node *Node) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error)
func (*Node) GetImplementation ¶
GetImplementation This function is used to retrieve a value from the DHT. Error if the key does not exist or unable to retrieve the value.
func (*Node) GetNeighbors ¶
func (node *Node) GetNeighbors(ctx context.Context, req *pb.GetNeighborsRequest) (*pb.GetNeighborsResponse, error)
GetNeighbors handles a request to get all neighbors
func (*Node) HandleCrashDetection ¶
HandleCrashDetection is called when a neighbor's heartbeat fails
func (*Node) Heartbeat ¶
func (node *Node) Heartbeat(ctx context.Context, req *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error)
func (*Node) HeartbeatRoutine ¶
func (node *Node) HeartbeatRoutine()
func (*Node) InitiateLeave ¶
func (node *Node) InitiateLeave(ctx context.Context, req *pb.LeaveRequest) (*pb.LeaveResponse, error)
InitiateLeave handles a request from a node that wants to leave
func (*Node) Join ¶
func (node *Node) Join(ctx context.Context, req *pb.JoinRequest) (*pb.JoinResponse, error)
func (*Node) JoinImplementation ¶
JoinImplementation queries bootstrap node and sends a join query
func (*Node) LeaveImplementation ¶
LeaveImplementation handles the graceful leaving of a node from the CAN network
func (*Node) NotifyAllNeighboursOfTwoHopInfo ¶
func (node *Node) NotifyAllNeighboursOfTwoHopInfo()
NotifyAllNeighboursOfTwoHopInfo notifies all neighbours about the 2-hop information
func (*Node) NotifyNeighbors ¶
NotifyNeighbors notifies all neighbors about this node
func (*Node) NotifyZoneMerge ¶
func (node *Node) NotifyZoneMerge(ctx context.Context, notification *pb.ZoneMergeNotification) (*pb.ZoneMergeResponse, error)
NotifyZoneMerge handles a notification about a zone merge
func (*Node) PerformDFS ¶
func (node *Node) PerformDFS(ctx context.Context, req *pb.DFSRequest) (*pb.DFSResponse, error)
PerformDFS handles a DFS request from another node
func (*Node) Put ¶
func (node *Node) Put(ctx context.Context, req *pb.PutRequest) (*pb.PutResponse, error)
func (*Node) PutImplementation ¶
PutImplementation This function is used to store a value in the DHT. Overwrites the value if the key already exists.
func (*Node) SendNeighbourInfo ¶
func (node *Node) SendNeighbourInfo(ctx context.Context, req *pb.NeighbourInfoRequest) (*pb.NeighbourInfoResponse, error)
func (*Node) StartCrashDetection ¶
func (node *Node) StartCrashDetection()
StartCrashDetection starts a goroutine for detecting node failures
func (*Node) StartGRPCServer ¶
func (*Node) TakeoverZone ¶
func (node *Node) TakeoverZone(ctx context.Context, req *pb.TakeoverRequest) (*pb.TakeoverResponse, error)
TakeoverZone handles a request to take over another node's zone
func (*Node) TransferData ¶
func (node *Node) TransferData(ctx context.Context, req *pb.TransferDataRequest) (*pb.TransferDataResponse, error)
TransferData handles a request to transfer all data to another node