node

package
v0.0.0-...-e65b650 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

The node package contains data structures useful for representing information about nodes in a distributed system, as well as some utility functions for getting information about them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentNodeId

func GetCurrentNodeId(config NodesConfig) string

Determine which node ID we are

func HashId

func HashId(key string) uint32

Types

type Node

type Node struct {
	Id         string `json:"id"`
	Host       string `json:"host"`
	RestPort   int32  `json:"rest_port"`
	GrpcPort   int32  `json:"grpc_port"`
	HashId     uint32
	GrpcClient pb.CacheServiceClient
}

Node struct contains all info we need about a server node, as well as a gRPC client to interact with it

func GetRandomNode

func GetRandomNode(nodes []*Node) *Node

Get random node from a given list of nodes

func NewNode

func NewNode(id string, host string, rest_port int32, grpc_port int32) *Node

func (*Node) SetGrpcClient

func (n *Node) SetGrpcClient(c pb.CacheServiceClient)

type Nodes

type Nodes []*Node

func (Nodes) Len

func (n Nodes) Len() int

implementing methods required for sorting

func (Nodes) Less

func (n Nodes) Less(i, j int) bool

func (Nodes) Swap

func (n Nodes) Swap(i, j int)

type NodesConfig

type NodesConfig struct {
	Nodes            map[string]*Node `json:"nodes"`
	EnableClientAuth bool             `json:"enable_client_auth"`
	EnableHttps      bool             `json:"enable_https"`
	ServerLogfile    string           `json:"server_logfile"`
	ServerErrfile    string           `json:"server_errfile"`
	ClientLogfile    string           `json:"client_logfile"`
	ClientErrfile    string           `json:"client_errfile"`
}

NodesConfig struct holds info about all server nodes in the network

func LoadNodesConfig

func LoadNodesConfig(configFile string) NodesConfig

Load nodes config file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL