Documentation
¶
Overview ¶
Package embed starts and supervises NATS JetStream servers in-process.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
Nodes []*Node
// contains filtered or unexported fields
}
func StartCluster ¶
func StartCluster(cfg ClusterConfig) (*Cluster, error)
StartCluster spins up an in-process cluster of Size nodes on loopback with random free ports. All nodes share cfg.Name. Returns once all nodes accept connections; call WaitMetaLeader via the stream package before creating streams.
func (*Cluster) ClientURLs ¶
ClientURLs returns a comma-separated URL list suitable for nats.Connect.
func (*Cluster) Shutdown ¶
func (c *Cluster) Shutdown()
Shutdown stops all nodes. Does not wait between shutdowns — callers doing graceful rolling shutdowns should call Node.Shutdown() individually with appropriate gaps.
func (*Cluster) ShutdownNode ¶
ShutdownNode stops a single node; useful for failover testing.
type ClusterConfig ¶
type ClusterConfig struct {
// Size is the number of nodes (must be >= 1; 3 for HA quorum).
Size int
// Name is the cluster name shared by all nodes.
Name string
// BaseDir is the parent dir for per-node StoreDir. If empty, uses os.MkdirTemp.
BaseDir string
// ReadyWait is the per-node timeout waiting for connections.
ReadyWait time.Duration
}
Click to show internal directories.
Click to hide internal directories.