raftnode

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package raftnode provides an optional HashiCorp Raft cluster adapter for Vale.

Index

Constants

View Source
const (
	CommandTypeSnapshotUpdate = "snapshot_update"
	CommandTypeRouteSync      = "route_sync"
)

Variables

View Source
var ErrDisabled = errors.New("raft disabled")

Functions

func WithCluster

func WithCluster(config Config) gateway.Option

Types

type Command

type Command struct {
	Type     string                            `json:"type"`
	Snapshot *SnapshotUpdate                   `json:"snapshot,omitempty"`
	Routes   *collectionlist.List[RouteRecord] `json:"routes,omitempty"`
	Raw      json.RawMessage                   `json:"raw,omitempty"`
}

type Config

type Config struct {
	Enabled   bool
	NodeID    string
	BindAddr  string
	DataDir   string
	Bootstrap bool
}

func DefaultConfig

func DefaultConfig() Config

type Node

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

func New

func New(config Config, logger *slog.Logger) (*Node, error)

func (*Node) AddVoter

func (n *Node) AddVoter(id, address string, timeout time.Duration) error

func (*Node) AppliedState

func (n *Node) AppliedState() State

func (*Node) Apply

func (n *Node) Apply(data []byte, timeout time.Duration) error

func (*Node) IsEnabled

func (n *Node) IsEnabled() bool

func (*Node) IsLeader

func (n *Node) IsLeader() bool

func (*Node) Peers

func (n *Node) Peers() (*collectionlist.List[gateway.ClusterPeer], error)

func (*Node) RemoveServer

func (n *Node) RemoveServer(id string, timeout time.Duration) error

func (*Node) Shutdown

func (n *Node) Shutdown() error

func (*Node) Status

func (n *Node) Status() *mapping.Map[string, any]

type Peer

type Peer struct {
	ID       string `json:"id"`
	Address  string `json:"address"`
	Suffrage string `json:"suffrage"`
}

type RouteRecord

type RouteRecord struct {
	Name       string `json:"name"`
	Entrypoint string `json:"entrypoint"`
	Host       string `json:"host,omitempty"`
	PathPrefix string `json:"path_prefix,omitempty"`
	Method     string `json:"method,omitempty"`
	Service    string `json:"service"`
}

type SnapshotUpdate

type SnapshotUpdate struct {
	BuiltAt     string `json:"built_at"`
	Services    int    `json:"services"`
	Routes      int    `json:"routes"`
	ProxyEngine string `json:"proxy_engine"`
}

type State

type State struct {
	Version   uint64                            `json:"version"`
	AppliedAt time.Time                         `json:"applied_at"`
	Snapshot  *SnapshotUpdate                   `json:"snapshot,omitempty"`
	Routes    *collectionlist.List[RouteRecord] `json:"routes,omitempty"`
	Raw       json.RawMessage                   `json:"raw,omitempty"`
}

Jump to

Keyboard shortcuts

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