Documentation
¶
Overview ¶
Package hive is Bee's native host: it prepares, before the runtime boots, the cluster configuration that joins every Bee node of this machine into the machine's hive once `bee hive init` created it. Everything after boot is Lua.
SPDX-License-Identifier: MIT
Index ¶
- Constants
- func Dir() (string, error)
- func Help(out io.Writer)
- func Init(dir string) error
- func Invite(ctx context.Context, dir string, out, notes io.Writer) error
- func Join(ctx context.Context, dir, token string, out io.Writer) error
- func Prepare(dir, state string, hive *Hive, members *Members) (boot.Config, string, error)
- func PrepareClient(dir string, hive Hive, members *Members) (boot.Config, string, error)
- func WriteHive(dir string, hive Hive) error
- type Hive
- type Host
- type Members
- type Node
Constants ¶
const ( RoleVariable = "BEE_ROLE" ClientRole = "client" )
RoleVariable tells the application what this process is. An in-memory client sets it to ClientRole: it displays another node and serves no node of its own.
const InviteLifetime = 10 * time.Minute
InviteLifetime is how long an invite stays redeemable.
Variables ¶
This section is empty.
Functions ¶
func Invite ¶
Invite creates the hive when this machine has none, prints an invite for another machine and serves it until it is redeemed, expires or ctx ends. The invite line goes to out; guidance goes to notes.
func Join ¶
Join redeems the invite token for this machine. The hive is created when the machine has none, and its secret is replaced by the hive's, so the machine's nodes join the hive the invite names when they start.
func Prepare ¶
Prepare returns the boot configuration that runs this folder's node under its identity, joined into the hive when there is one, and the node's name.
func PrepareClient ¶
PrepareClient returns the boot configuration of an in-memory client node: a fresh identity that is never written to disk, joined into the hive.
Types ¶
type Hive ¶
type Hive struct {
Secret string `json:"secret"`
// Machine names this machine in invites.
Machine string `json:"machine,omitempty"`
// Port is the gossip port the first node of this machine binds, so other
// machines know where to dial.
Port int `json:"port,omitempty"`
// Advertise is the address other machines reach this machine at. It is
// set once the machine joined another, or another joined it; until then
// nodes listen on loopback only.
Advertise string `json:"advertise,omitempty"`
// Seeds are gossip addresses of nodes on other machines.
Seeds []string `json:"seeds,omitempty"`
}
Hive is the machine-wide hive configuration created by `bee hive init`.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host plans Bee launches and publishes the node's address once it runs.
func (*Host) DependsOn ¶
DependsOn implements boot.Component: the address exists once the cluster runs.
func (*Host) Load ¶
Load implements boot.Component: the cluster created its membership, which resolves the keys of nodes on other machines.
type Members ¶
type Members struct {
// contains filtered or unexported fields
}
Members resolves the identity keys of nodes on other machines from the membership the hive's gossip carries. The hive secret is the trust root across machines: a node of another machine is trusted under the key it advertises, while a node whose key this machine published locally is only trusted under that key.