cluster

package
v0.0.0-...-efb87f3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CorePrefix is the http prefix core should use.
	CorePrefix = "/core"
)

Variables

This section is empty.

Functions

func DefaultPort

func DefaultPort(hostport string) string

DefaultPort will return the hostname with the default internal Gansoi port. If hostport already contains a port, DefaultPort will simply return that.

Types

type Core

type Core struct {
	// contains filtered or unexported fields
}

Core describes a Gansoi core node.

func NewCore

func NewCore(info *Info) *Core

NewCore initializes a new core.

func (*Core) Bootstrap

func (c *Core) Bootstrap() error

Bootstrap a new cluster.

func (*Core) CA

func (c *Core) CA() *ca.CA

CA returns the CA.

func (*Core) Join

func (c *Core) Join(address string, hash string, token string, bindPrivate string) error

Join an existing cluster.

func (*Core) Router

func (c *Core) Router(router *gin.RouterGroup, raftHandler http.Handler, peerAdder PeerAdder)

Router can be used to assign a Gin routergroup.

func (*Core) Start

func (c *Core) Start() ([]tls.Certificate, error)

Start a Gansoi core node.

type Info

type Info struct {
	sync.RWMutex

	SelfName     string `json:"self"`
	CACert       []byte `json:"ca-cert"`
	CAKey        []byte `json:"ca-key"`
	NodeCert     []byte `json:"node-cert"`
	NodeKey      []byte `json:"node-key"`
	ClusterToken string `json:"cluster-token"`
	// contains filtered or unexported fields
}

Info stores the current list of peers.

func NewInfo

func NewInfo(path string) *Info

NewInfo will instanmtiate a new peer store that will save its state in path.

func (*Info) IP

func (c *Info) IP() net.IP

IP will return our presumed cluster IP. If we have no way of guessing it, IP() simply returns nil.

func (*Info) Load

func (c *Info) Load() error

Load loads the state from persistent disk storage.

func (*Info) Save

func (c *Info) Save() error

Save will trigger a save.

func (*Info) Self

func (c *Info) Self() string

Self will return our own name as set by SetSelf().

func (*Info) SetSelf

func (c *Info) SetSelf(self string) error

SetSelf will set our own node name.

type PeerAdder

type PeerAdder interface {
	AddPeer(name string) error
}

PeerAdder must be implemented by types that can add peers.

Jump to

Keyboard shortcuts

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