orchestration

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSet = errors.New("orchestration client not set")

Functions

func Deref added in v0.35.0

func Deref[T any](p *T) T

Deref returns the value pointed to by p, or the zero value of T when p is nil. It is used for Beekeeper's own orchestration decisions on optional Config fields; it never substitutes any of Bee's defaults and is never written into the node's .bee.yaml.

Types

type BeeClientOption added in v0.15.9

type BeeClientOption func(*bee.ClientOptions) error

BeeClientOption represents bee client option

func WithNoOptions added in v0.15.9

func WithNoOptions() BeeClientOption

WithNoOptions represents no BeeClientOption

func WithURL added in v0.16.0

func WithURL(apiURL string) BeeClientOption

WithURL returns BeeClientOption with given api url

type ClientList added in v0.31.0

type ClientList []*bee.Client

func (ClientList) FilterByNodeGroups added in v0.31.0

func (c ClientList) FilterByNodeGroups(nodeGroups []string) ClientList

type ClientMap added in v0.31.0

type ClientMap map[string]*bee.Client

func (ClientMap) FilterByNodeGroups added in v0.31.0

func (c ClientMap) FilterByNodeGroups(nodeGroups []string) ClientList

type Cluster

type Cluster interface {
	Accounting(ctx context.Context) (accounting ClusterAccounting, err error)
	AddNodeGroup(name string, o NodeGroupOptions)
	Addresses(ctx context.Context) (addrs map[string]NodeGroupAddresses, err error)
	Balances(ctx context.Context) (balances ClusterBalances, err error)
	FlattenAccounting(ctx context.Context) (accounting NodeGroupAccounting, err error)
	FlattenBalances(ctx context.Context) (balances NodeGroupBalances, err error)
	FlattenOverlays(ctx context.Context, exclude ...string) (map[string]swarm.Address, error)
	FlattenSettlements(ctx context.Context) (settlements NodeGroupSettlements, err error)
	FlattenTopologies(ctx context.Context) (topologies map[string]bee.Topology, err error)
	FullNodeNames() (names []string)
	GlobalReplicationFactor(ctx context.Context, a swarm.Address) (grf int, err error)
	LightNodeNames() (names []string)
	Name() string
	Namespace() string
	NodeGroup(name string) (ng NodeGroup, err error)
	NodeGroups() (l map[string]NodeGroup)
	NodeNames() (names []string)
	Nodes() map[string]Node
	NodesClients(ctx context.Context) (map[string]*bee.Client, error)
	Overlays(ctx context.Context, exclude ...string) (overlays ClusterOverlays, err error)
	Peers(ctx context.Context, exclude ...string) (peers ClusterPeers, err error)
	RandomNode(ctx context.Context, r *rand.Rand) (node Node, err error)
	Settlements(ctx context.Context) (settlements ClusterSettlements, err error)
	ShuffledFullNodeClients(ctx context.Context, r *rand.Rand) (ClientList, error)
	Size() (size int)
	Topologies(ctx context.Context) (topologies ClusterTopologies, err error)
	ClosestFullNodeClient(ctx context.Context, s *bee.Client) (*bee.Client, error)
}

type ClusterAccounting added in v0.11.4

type ClusterAccounting map[string]NodeGroupAccounting

ClusterAccounting represents accounting of all nodes in the cluster

type ClusterAddresses

type ClusterAddresses map[string]NodeGroupAddresses

ClusterAddresses represents addresses of all nodes in the cluster

type ClusterBalances

type ClusterBalances map[string]NodeGroupBalances

ClusterBalances represents balances of all nodes in the cluster

type ClusterOptions

type ClusterOptions struct {
	Annotations       map[string]string
	APIDomain         string
	APIDomainInternal string
	APIInsecureTLS    bool
	APIScheme         string
	DisableNamespace  bool
	Labels            map[string]string
	Namespace         string
}

ClusterOptions represents Bee cluster options

func (ClusterOptions) ApiURL added in v0.15.9

func (c ClusterOptions) ApiURL(name string, inCluster bool) (u *url.URL, err error)

ApiURL generates URL for node's API

func (ClusterOptions) IngressHost added in v0.15.9

func (c ClusterOptions) IngressHost(name string) string

IngressHost generates host for node's API ingress

type ClusterOverlays

type ClusterOverlays map[string]NodeGroupOverlays

ClusterOverlays represents overlay addresses of all nodes in the cluster

func (ClusterOverlays) Random

func (c ClusterOverlays) Random(r *rand.Rand) (nodeGroup string, nodeName string, overlay swarm.Address)

RandomOverlay returns a random overlay from a random NodeGroup

type ClusterPeers

type ClusterPeers map[string]NodeGroupPeers

ClusterPeers represents peers of all nodes in the cluster

type ClusterSettlements

type ClusterSettlements map[string]NodeGroupSettlements

ClusterSettlements represents settlements of all nodes in the cluster

type ClusterTopologies

type ClusterTopologies map[string]NodeGroupTopologies

ClusterTopologies represents Kademlia topology of all nodes in the cluster

type Config

type Config struct {
	AllowPrivateCIDRs           *bool          `yaml:"allow-private-cidrs,omitempty"`            // allow to advertise private CIDRs to the public network
	APIAddr                     *string        `yaml:"api-addr,omitempty"`                       // HTTP API listen address
	AutoTLSCAEndpoint           *string        `yaml:"autotls-ca-endpoint,omitempty"`            // autotls certificate authority endpoint
	AutoTLSDomain               *string        `yaml:"autotls-domain,omitempty"`                 // autotls domain
	AutoTLSRegistrationEndpoint *string        `yaml:"autotls-registration-endpoint,omitempty"`  // autotls registration endpoint
	BlockchainRPCDialTimeout    *time.Duration `yaml:"blockchain-rpc-dial-timeout,omitempty"`    // blockchain rpc TCP dial timeout
	BlockchainRPCEndpoint       *string        `yaml:"blockchain-rpc-endpoint,omitempty"`        // rpc blockchain endpoint
	BlockchainRPCIdleTimeout    *time.Duration `yaml:"blockchain-rpc-idle-timeout,omitempty"`    // blockchain rpc idle connection timeout
	BlockchainRPCKeepalive      *time.Duration `yaml:"blockchain-rpc-keepalive,omitempty"`       // blockchain rpc TCP keepalive interval
	BlockchainRPCTLSTimeout     *time.Duration `yaml:"blockchain-rpc-tls-timeout,omitempty"`     // blockchain rpc TLS handshake timeout
	BlockSyncInterval           *uint64        `yaml:"block-sync-interval,omitempty"`            // block number cache sync interval in blocks
	BlockTime                   *uint64        `yaml:"block-time,omitempty"`                     // chain block time
	BootnodeMode                *bool          `yaml:"bootnode-mode,omitempty"`                  // cause the node to always accept incoming connections
	Bootnodes                   *[]string      `yaml:"bootnode,omitempty"`                       // initial nodes to connect to
	BzzTokenAddress             *string        `yaml:"bzz-token-address,omitempty"`              // bzz token contract address
	CacheCapacity               *uint64        `yaml:"cache-capacity,omitempty"`                 // cache capacity in chunks, multiply by 4096 to get approximate capacity in bytes
	CacheRetrieval              *bool          `yaml:"cache-retrieval,omitempty"`                // enable forwarded content caching
	ChequebookEnable            *bool          `yaml:"chequebook-enable,omitempty"`              // enable chequebook
	ChequebookMinBalance        *string        `yaml:"chequebook-min-balance,omitempty"`         // minimum chequebook token balance required for verification, in token small units
	ChequebookVerification      *bool          `yaml:"chequebook-verification,omitempty"`        // reject full-node hive/handshake records that carry no chequebook address
	CORSAllowedOrigins          *[]string      `yaml:"cors-allowed-origins,omitempty"`           // origins with CORS headers enabled
	DataDir                     *string        `yaml:"data-dir,omitempty"`                       // data directory
	DbBlockCacheCapacity        *uint64        `yaml:"db-block-cache-capacity,omitempty"`        // size of block cache of the database in bytes
	DbDisableSeeksCompaction    *bool          `yaml:"db-disable-seeks-compaction,omitempty"`    // disables db compactions triggered by seeks
	DbOpenFilesLimit            *uint64        `yaml:"db-open-files-limit,omitempty"`            // number of open files allowed by database
	DbWriteBufferSize           *uint64        `yaml:"db-write-buffer-size,omitempty"`           // size of the database write buffer in bytes
	FullNode                    *bool          `yaml:"full-node,omitempty"`                      // cause the node to start in full mode
	GasLimitFallback            *uint64        `yaml:"gas-limit-fallback,omitempty"`             // gas limit fallback when estimation fails for contract transactions
	Mainnet                     *bool          `yaml:"mainnet,omitempty"`                        // triggers connect to main net bootnodes
	MinimumGasTipCap            *uint64        `yaml:"minimum-gas-tip-cap,omitempty"`            // minimum gas tip cap in wei for transactions, 0 means use suggested gas tip cap
	MinimumStorageRadius        *uint          `yaml:"minimum-storage-radius,omitempty"`         // minimum radius storage threshold
	NATAddr                     *string        `yaml:"nat-addr,omitempty"`                       // NAT exposed address
	NATWSSAddr                  *string        `yaml:"nat-wss-addr,omitempty"`                   // WSS NAT exposed address
	NeighborhoodSuggester       *string        `yaml:"neighborhood-suggester,omitempty"`         // suggester for target neighborhood
	NetworkID                   *uint64        `yaml:"network-id,omitempty"`                     // ID of the Swarm network
	P2PAddr                     *string        `yaml:"p2p-addr,omitempty"`                       // P2P listen address
	P2PWSEnable                 *bool          `yaml:"p2p-ws-enable,omitempty"`                  // enable P2P WebSocket transport
	P2PWSSAddr                  *string        `yaml:"p2p-wss-addr,omitempty"`                   // p2p wss address
	P2PWSSEnable                *bool          `yaml:"p2p-wss-enable,omitempty"`                 // enable Secure WebSocket P2P connections
	Password                    *string        `yaml:"password,omitempty"`                       // password for decrypting keys
	PasswordFile                *string        `yaml:"password-file,omitempty"`                  // path to a file that contains password for decrypting keys
	PaymentEarly                *int64         `yaml:"payment-early-percent,omitempty"`          // percentage below the peers payment threshold when we initiate settlement
	PaymentThreshold            *string        `yaml:"payment-threshold,omitempty"`              // threshold in BZZ where you expect to get paid from your peers
	PaymentTolerance            *int64         `yaml:"payment-tolerance-percent,omitempty"`      // excess debt above payment threshold in percentages where you disconnect from your peer
	PostageContractStartBlock   *uint64        `yaml:"postage-stamp-start-block,omitempty"`      // postage stamp contract start block number
	PostageStampAddress         *string        `yaml:"postage-stamp-address,omitempty"`          // postage stamp contract address
	PprofMutex                  *bool          `yaml:"pprof-mutex,omitempty"`                    // enable pprof mutex profile
	PprofProfile                *bool          `yaml:"pprof-profile,omitempty"`                  // enable pprof block profile
	PriceOracleAddress          *string        `yaml:"price-oracle-address,omitempty"`           // price oracle contract address
	RedistributionAddress       *string        `yaml:"redistribution-address,omitempty"`         // redistribution contract address
	ReserveCapacityDoubling     *int           `yaml:"reserve-capacity-doubling,omitempty"`      // reserve capacity doubling
	ResolverOptions             *[]string      `yaml:"resolver-options,omitempty"`               // ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url
	Resync                      *bool          `yaml:"resync,omitempty"`                         // forces the node to resync postage contract data
	SkipPostageSnapshot         *bool          `yaml:"skip-postage-snapshot,omitempty"`          // skip postage snapshot
	StakingAddress              *string        `yaml:"staking-address,omitempty"`                // staking contract address
	StatestoreCacheCapacity     *uint64        `yaml:"statestore-cache-capacity,omitempty"`      // lru memory caching capacity in number of statestore entries
	StaticNodes                 *[]string      `yaml:"static-nodes,omitempty"`                   // protect nodes from getting kicked out on bootnode
	StorageIncentivesEnable     *bool          `yaml:"storage-incentives-enable,omitempty"`      // enable storage incentives feature
	SwapEnable                  *bool          `yaml:"swap-enable,omitempty"`                    // enable swap
	SwapFactoryAddress          *string        `yaml:"swap-factory-address,omitempty"`           // swap factory addresses
	SwapInitialDeposit          *string        `yaml:"swap-initial-deposit,omitempty"`           // initial deposit if deploying a new chequebook
	TargetNeighborhood          *string        `yaml:"target-neighborhood,omitempty"`            // neighborhood to target in binary format (ex: 111111001) for mining the initial overlay
	TracingEnabled              *bool          `yaml:"tracing-enable,omitempty"`                 // enable tracing
	TracingEndpoint             *string        `yaml:"tracing-endpoint,omitempty"`               // endpoint to send tracing data
	TracingHost                 *string        `yaml:"tracing-host,omitempty"`                   // host to send tracing data
	TracingPort                 *string        `yaml:"tracing-port,omitempty"`                   // port to send tracing data
	TracingServiceName          *string        `yaml:"tracing-service-name,omitempty"`           // service name identifier for tracing
	TransactionDebugMode        *bool          `yaml:"transaction-debug-mode,omitempty"`         // skips the gas estimate step for contract transactions
	UseSIMD                     *bool          `yaml:"use-simd,omitempty"`                       // use SIMD BMT hasher (available only on linux amd64 platforms)
	Verbosity                   *string        `yaml:"verbosity,omitempty"`                      // log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace
	WarmupTime                  *time.Duration `yaml:"warmup-time,omitempty"`                    // maximum node warmup duration; proceeds when stable or after this time
	WelcomeMessage              *string        `yaml:"welcome-message,omitempty"`                // send a welcome message string during handshakes
	WithdrawAddress             *[]string      `yaml:"withdrawal-addresses-whitelist,omitempty"` // withdrawal target addresses
}

Config represents Bee configuration.

Every field is a pointer so that a nil value means "not set in Beekeeper's YAML config". Such fields are omitted from the rendered .bee.yaml (see the yaml tags below), which lets the Bee node fall back to its own built-in default. A non-nil pointer is always rendered, even when it points to a zero value (e.g. full-node: false, warmup-time: 0s), so explicitly configured zero values still reach Bee. Beekeeper never hardcodes any of Bee's defaults.

The yaml tags are the Bee flag names and are only used when marshalling this struct into the node's .bee.yaml. A few flag names differ from Beekeeper's config keys (e.g. bootnode, tracing-enable); those input keys live on config.BeeConfig and are unaffected.

type CreateOptions

type CreateOptions struct {
	// Bee configuration
	Config Config
	// Kubernetes configuration
	Name                      string
	Namespace                 string
	Annotations               map[string]string
	Labels                    map[string]string
	Image                     string
	ImagePullPolicy           string
	ImagePullSecrets          []string
	IngressAnnotations        map[string]string
	IngressClass              string
	IngressHost               string
	LibP2PKey                 string
	NodeSelector              map[string]string
	P2PWSSNodePort            int32
	PersistenceEnabled        bool
	PersistenceStorageClass   string
	PersistenceStorageRequest string
	PodManagementPolicy       string
	RestartPolicy             string
	ResourcesLimitCPU         string
	ResourcesLimitMemory      string
	ResourcesRequestCPU       string
	ResourcesRequestMemory    string
	Selector                  map[string]string
	SwarmKey                  *EncryptedKey
	UpdateStrategy            string
}

CreateOptions represents available options for creating node

type EncryptedKey added in v0.12.0

type EncryptedKey struct {
	Address string    `json:"address"`
	Crypto  keyCripto `json:"crypto"`
	Version int       `json:"version"`
	ID      string    `json:"id"`
}

This format is compatible with Ethereum JSON v3 key file format.

func NewEncryptedKey added in v0.27.0

func NewEncryptedKey(password string) (*EncryptedKey, error)

func (*EncryptedKey) StringJSON added in v0.27.0

func (k *EncryptedKey) StringJSON() (string, error)

func (*EncryptedKey) UnmarshalYAML added in v0.27.0

func (k *EncryptedKey) UnmarshalYAML(value *yaml.Node) error

type FundingOptions

type FundingOptions struct {
	Eth  float64
	Bzz  float64
	GBzz float64
}

type Node

type Node interface {
	Client() *bee.Client
	Config() *Config
	LibP2PKey() string
	Name() string
	SetSwarmKey(key *EncryptedKey) Node
	SwarmKey() *EncryptedKey
	Create(ctx context.Context, o CreateOptions) (err error)
	Delete(ctx context.Context, namespace string) (err error)
	Ready(ctx context.Context, namespace string) (ready bool, err error)
	Start(ctx context.Context, namespace string) (err error)
	Stop(ctx context.Context, namespace string) (err error)
}

type NodeGroup

type NodeGroup interface {
	Accounting(ctx context.Context) (infos NodeGroupAccounting, err error)
	AddNode(ctx context.Context, name string, inCluster bool, o NodeOptions, opts ...BeeClientOption) (err error)
	Addresses(ctx context.Context) (addrs NodeGroupAddresses, err error)
	Balances(ctx context.Context) (balances NodeGroupBalances, err error)
	DeleteNode(ctx context.Context, name string) (err error)
	DeployNode(ctx context.Context, name string, inCluster bool, o NodeOptions) (ethAddress string, err error)
	GroupReplicationFactor(ctx context.Context, a swarm.Address) (grf int, err error)
	NodeClient(name string) (*bee.Client, error)
	Nodes() map[string]Node
	NodesClients(ctx context.Context) (map[string]*bee.Client, error)
	NodesSorted() (l []string)
	Overlays(ctx context.Context) (overlays NodeGroupOverlays, err error)
	Peers(ctx context.Context) (peers NodeGroupPeers, err error)
	RunningNodes(ctx context.Context) (running []string, err error)
	Settlements(ctx context.Context) (settlements NodeGroupSettlements, err error)
	Size() int
	StoppedNodes(ctx context.Context) (stopped []string, err error)
	Topologies(ctx context.Context) (topologies NodeGroupTopologies, err error)
}

type NodeGroupAccounting added in v0.11.4

type NodeGroupAccounting map[string]map[string]bee.Account

NodeGroupAccounting represents accounting of all nodes in the node group

type NodeGroupAddresses

type NodeGroupAddresses map[string]bee.Addresses

NodeGroupAddresses represents addresses of all nodes in the node group

type NodeGroupBalances

type NodeGroupBalances map[string]map[string]int64

NodeGroupBalances represents balances of all nodes in the node group

type NodeGroupOptions

type NodeGroupOptions struct {
	Annotations               map[string]string
	BeeConfig                 *Config
	Image                     string
	ImagePullPolicy           string
	ImagePullSecrets          []string
	IngressAnnotations        map[string]string
	IngressClass              string
	Labels                    map[string]string
	NodeSelector              map[string]string
	P2PWSSNodePort            int32
	PersistenceEnabled        bool
	PersistenceStorageClass   string
	PersistenceStorageRequest string
	PodManagementPolicy       string
	RestartPolicy             string
	ResourcesLimitCPU         string
	ResourcesLimitMemory      string
	ResourcesRequestCPU       string
	ResourcesRequestMemory    string
	UpdateStrategy            string
}

NodeGroupOptions represents node group options

type NodeGroupOverlays

type NodeGroupOverlays map[string]swarm.Address

NodeGroupOverlays represents overlay addresses of all nodes in the node group

type NodeGroupPeers

type NodeGroupPeers map[string][]swarm.Address

NodeGroupPeers represents peers of all nodes in the node group

type NodeGroupSettlements

type NodeGroupSettlements map[string]map[string]SentReceived

NodeGroupSettlements represents settlements of all nodes in the node group

type NodeGroupTopologies

type NodeGroupTopologies map[string]bee.Topology

NodeGroupTopologies represents Kademlia topology of all nodes in the node group

type NodeOptions

type NodeOptions struct {
	Config    *Config
	LibP2PKey string
	SwarmKey  *EncryptedKey
}

NodeOptions holds optional parameters for the Node.

type NodeOrchestrator added in v0.15.9

type NodeOrchestrator interface {
	Create(ctx context.Context, o CreateOptions) (err error)
	Delete(ctx context.Context, name string, namespace string) (err error)
	Ready(ctx context.Context, name string, namespace string) (ready bool, err error)
	Start(ctx context.Context, name string, namespace string) (err error)
	Stop(ctx context.Context, name string, namespace string) (err error)
	RunningNodes(ctx context.Context, namespace string) (running []string, err error)
	StoppedNodes(ctx context.Context, namespace string) (stopped []string, err error)
}

type SentReceived

type SentReceived struct {
	Received int64
	Sent     int64
}

SentReceived object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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