nodeconf

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PartitionCount    = 3000
	ReplicationFactor = 3
)
View Source
const CName = "common.nodeconf"
View Source
const CNameSource = "common.nodeconf.source"
View Source
const CNameStore = "common.nodeconf.store"

Variables

View Source
var (
	ErrConfigurationNotChanged = errors.New("configuration not changed")
)
View Source
var (
	ErrConfigurationNotFound = errors.New("node nodeConf not found")
)

Functions

func ReplKey

func ReplKey(spaceId string) (replKey string)

Types

type ConfigGetter

type ConfigGetter interface {
	GetNodeConf() Configuration
}

type ConfigUpdateGetter

type ConfigUpdateGetter interface {
	GetNodeConfUpdateInterval() int
}

type Configuration

type Configuration struct {
	Id           string    `yaml:"id"`
	NetworkId    string    `yaml:"networkId"`
	Nodes        []Node    `yaml:"nodes"`
	CreationTime time.Time `yaml:"creationTime"`
}

type NetworkCompatibilityStatus

type NetworkCompatibilityStatus int
const (
	NetworkCompatibilityStatusUnknown NetworkCompatibilityStatus = iota
	NetworkCompatibilityStatusOk
	NetworkCompatibilityStatusError
	NetworkCompatibilityStatusIncompatible
)

type Node

type Node struct {
	PeerId    string     `yaml:"peerId" bson:"peerId"`
	Addresses []string   `yaml:"addresses" bson:"addresses"`
	Types     []NodeType `yaml:"types,omitempty" bson:"types"`
}

func (Node) Capacity

func (n Node) Capacity() float64

func (Node) HasType

func (n Node) HasType(t NodeType) bool

func (Node) Id

func (n Node) Id() string

type NodeConf

type NodeConf interface {
	// Id returns current nodeconf id
	Id() string
	// Configuration returns configuration struct
	Configuration() Configuration
	// NodeIds returns list of peerId for given spaceId
	NodeIds(spaceId string) []string
	// IsResponsible checks if current account responsible for given spaceId
	IsResponsible(spaceId string) bool
	// FilePeers returns list of filenodes
	FilePeers() []string
	// ConsensusPeers returns list of consensusnodes
	ConsensusPeers() []string
	// CoordinatorPeers returns list of coordinator nodes
	CoordinatorPeers() []string
	// PeerAddresses returns peer addresses by peer id
	PeerAddresses(peerId string) (addrs []string, ok bool)
	// CHash returns nodes consistent table
	CHash() chash.CHash
	// Partition returns partition number by spaceId
	Partition(spaceId string) (part int)
	// NodeTypes returns list of known nodeTypes by nodeId, if node not registered in configuration will return empty list
	NodeTypes(nodeId string) []NodeType
}

type NodeType

type NodeType string
const (
	NodeTypeTree      NodeType = "tree"
	NodeTypeConsensus NodeType = "consensus"
	NodeTypeFile      NodeType = "file"

	NodeTypeCoordinator NodeType = "coordinator"
)

type Service

type Service interface {
	NodeConf
	NetworkCompatibilityStatus() NetworkCompatibilityStatus
	app.ComponentRunnable
}

func New

func New() Service

type Source

type Source interface {
	GetLast(ctx context.Context, currentId string) (c Configuration, err error)
}

type Store

type Store interface {
	GetLast(ctx context.Context, netId string) (c Configuration, err error)
	SaveLast(ctx context.Context, c Configuration) (err error)
}

Directories

Path Synopsis
Package mock_nodeconf is a generated GoMock package.
Package mock_nodeconf is a generated GoMock package.

Jump to

Keyboard shortcuts

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