state

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package state for grid state

Package state for grid state

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound for state not found instances

Functions

This section is empty.

Types

type ContractIDs

type ContractIDs []uint64

ContractIDs represents a slice of contract IDs

type Network

type Network struct {
	Subnets map[uint32]string
}

Network struct includes Subnets and node IPs

func NewNetwork

func NewNetwork() Network

NewNetwork creates a new Network

func (*Network) GetNodeSubnet

func (n *Network) GetNodeSubnet(nodeID uint32) string

GetNodeSubnet gets a node subnet using its ID

func (*Network) SetNodeSubnet

func (n *Network) SetNodeSubnet(nodeID uint32, subnet string)

SetNodeSubnet sets a node subnet with its ID and subnet

type NetworkState

type NetworkState struct {
	State map[string]Network
	// contains filtered or unexported fields
}

NetworkState is a struct of networks names and their networks and mutex to protect the state

func (*NetworkState) DeleteNetwork

func (nm *NetworkState) DeleteNetwork(networkName string)

DeleteNetwork deletes a Network using its name

func (*NetworkState) GetNetwork

func (nm *NetworkState) GetNetwork(networkName string) Network

GetNetwork get a Network using its name

func (*NetworkState) UpdateNetworkSubnets

func (nm *NetworkState) UpdateNetworkSubnets(networkName string, ipRange map[uint32]gridtypes.IPNet)

UpdateNetworkSubnets updates a network subnets given its name

type State

type State struct {
	CurrentNodeDeployments map[uint32]ContractIDs

	Networks NetworkState

	NcPool    client.NodeClientGetter
	Substrate subi.SubstrateExt
}

State struct

func NewState

func NewState(ncPool client.NodeClientGetter, substrate subi.SubstrateExt) *State

NewState generates a new state

func (*State) AssignNodesIPRange

func (st *State) AssignNodesIPRange(k *workloads.K8sCluster) (err error)

AssignNodesIPRange to assign ip range of k8s cluster nodes

func (*State) GetWorkloadInDeployment

func (st *State) GetWorkloadInDeployment(ctx context.Context, nodeID uint32, name string, deploymentName string) (gridtypes.Workload, gridtypes.Deployment, error)

GetWorkloadInDeployment return a workload in a deployment using their names and node ID if name is empty it returns a deployment with name equal to deploymentName and empty workload

func (*State) LoadDeploymentFromGrid

func (st *State) LoadDeploymentFromGrid(ctx context.Context, nodeID uint32, name string) (workloads.Deployment, error)

LoadDeploymentFromGrid loads deployment from grid

func (*State) LoadDiskFromGrid

func (st *State) LoadDiskFromGrid(ctx context.Context, nodeID uint32, name string, deploymentName string) (workloads.Disk, error)

LoadDiskFromGrid loads a disk from grid

func (*State) LoadGatewayFQDNFromGrid

func (st *State) LoadGatewayFQDNFromGrid(ctx context.Context, nodeID uint32, name string, deploymentName string) (workloads.GatewayFQDNProxy, error)

LoadGatewayFQDNFromGrid loads a gateway FQDN proxy from grid

func (*State) LoadGatewayNameFromGrid

func (st *State) LoadGatewayNameFromGrid(ctx context.Context, nodeID uint32, name string, deploymentName string) (workloads.GatewayNameProxy, error)

LoadGatewayNameFromGrid loads a gateway name proxy from grid

func (*State) LoadK8sFromGrid

func (st *State) LoadK8sFromGrid(ctx context.Context, nodeIDs []uint32, deploymentName string) (workloads.K8sCluster, error)

LoadK8sFromGrid loads k8s from grid

func (*State) LoadNetworkFromGrid

func (st *State) LoadNetworkFromGrid(ctx context.Context, name string) (znet workloads.ZNet, err error)

LoadNetworkFromGrid loads a network from grid

func (*State) LoadQSFSFromGrid

func (st *State) LoadQSFSFromGrid(ctx context.Context, nodeID uint32, name string, deploymentName string) (workloads.QSFS, error)

LoadQSFSFromGrid loads a QSFS from grid

func (*State) LoadVMFromGrid

func (st *State) LoadVMFromGrid(ctx context.Context, nodeID uint32, name string, deploymentName string) (workloads.VM, error)

LoadVMFromGrid loads a vm from a grid

func (*State) LoadZdbFromGrid

func (st *State) LoadZdbFromGrid(ctx context.Context, nodeID uint32, name string, deploymentName string) (workloads.ZDB, error)

LoadZdbFromGrid loads a zdb from grid

func (*State) RemoveContractIDs added in v0.14.13

func (st *State) RemoveContractIDs(nodeID uint32, contractIDs ...uint64)

func (*State) StoreContractIDs added in v0.14.13

func (st *State) StoreContractIDs(nodeID uint32, contractIDs ...uint64)

Jump to

Keyboard shortcuts

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