quasar

package
v1.52.8 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FrameKey added in v1.52.1

func FrameKey(f replication.Frame) []byte

FrameKey is exported for /v1/tasks/cluster diagnostics. A free function, not a method: replication.Frame is a non-local type (moved to its own package), so a method on it won't compile — same shape as frameID above.

Types

type MemoryHub

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

MemoryHub coordinates a set of MemoryTransport peers.

func NewMemoryHub

func NewMemoryHub() *MemoryHub

NewMemoryHub returns a hub for in-process replicator tests.

func (*MemoryHub) Connect

func (h *MemoryHub) Connect(id string) *MemoryTransport

Connect attaches a node to the hub; the returned Transport participates in broadcasts originating from any other peer.

type MemoryTransport

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

MemoryTransport is a deterministic in-process Transport used by tests and by single-node embedded mode. It implements broadcast as a fan-out across peers registered against the same hub.

func (*MemoryTransport) Broadcast

func (t *MemoryTransport) Broadcast(_ context.Context, kind string, payload []byte) error

Broadcast delivers payload to every peer except this one.

func (*MemoryTransport) LocalID

func (t *MemoryTransport) LocalID() string

LocalID returns this node's id.

func (*MemoryTransport) OnReceive

func (t *MemoryTransport) OnReceive(kind string, h func([]byte) error)

OnReceive registers handlers per kind.

func (*MemoryTransport) Validators

func (t *MemoryTransport) Validators() []string

Validators returns every registered peer ID, this node first.

type QuasarConfig

type QuasarConfig struct {
	NodeID       string
	Validators   []string // host:port strings; LocalID must appear here
	Transport    Transport
	ProposeWait  time.Duration // default 2s
	WitnessAfter time.Duration // default 100ms — when to escalate to commit vote
}

QuasarConfig pins the post-quantum engine to a validator set.

type QuasarReplicator

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

QuasarReplicator drives consensus.NewPQ with WAL frames as block payloads. On a single-node validator set the engine accepts every frame after a self-vote; multi-node operation requires Transport to fan votes between peers — the engine treats them as native PQ votes.

func NewQuasar

func NewQuasar(ctx context.Context, cfg QuasarConfig) (*QuasarReplicator, error)

NewQuasar wires consensus.NewPQ to the supplied transport and starts the engine. Returns once the genesis block is in place.

func (*QuasarReplicator) Close

func (r *QuasarReplicator) Close() error

Close stops the engine.

func (*QuasarReplicator) Kind

func (r *QuasarReplicator) Kind() string

Stats returns counters used by /v1/tasks/cluster. Kind identifies the consensus-backed driver.

func (*QuasarReplicator) Propose

Propose builds a Block whose payload is the JSON-encoded frame, adds it to the engine, broadcasts it to peers, and waits for the engine to mark it accepted. Self-vote happens immediately so single-node configurations terminate without external traffic.

func (*QuasarReplicator) Stats

func (r *QuasarReplicator) Stats() (accepted, rejected, timeouts uint64)

func (*QuasarReplicator) Subscribe

func (r *QuasarReplicator) Subscribe(h replication.Handler)

Subscribe registers an applier; called both for self-proposed frames (after engine accept) and for frames received from peers.

type Transport

type Transport interface {
	// Broadcast sends payload to every other validator. Implementations
	// SHOULD return promptly; durability is the consensus engine's job.
	Broadcast(ctx context.Context, kind string, payload []byte) error
	// OnReceive registers a handler for inbound traffic; returns nil if
	// the transport is local-only (single node).
	OnReceive(kind string, h func(payload []byte) error)
	// Validators returns the current validator set, leader-first.
	Validators() []string
	// LocalID returns this node's stable id.
	LocalID() string
}

Transport abstracts the cluster wire so tests can swap a memory bus for ZAP without dragging the network layer into unit tests. The quasar driver uses it to broadcast Block payloads and votes; in production Embedded wires this to the per-process zap.Node.

Jump to

Keyboard shortcuts

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