cockroach

package
v0.0.0-...-26bf35e Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Code generated by github.com/ecordell/optgen. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster []*Node

Cluster represents a set of Node nodes configured to talk to each other.

func NewCluster

func NewCluster(n int) Cluster

NewCluster returns a pre-configured cluster of the given size.

func (Cluster) Init

func (cs Cluster) Init(ctx context.Context, out, errOut io.Writer)

Init runs the cockroach init command against the cluster

func (Cluster) NetworkDelay

func (cs Cluster) NetworkDelay(ctx context.Context, out io.Writer, node int, duration time.Duration) error

NetworkDelay simulates network delay against the selected node

func (Cluster) SQL

func (cs Cluster) SQL(ctx context.Context, out, errOut io.Writer, sql ...string) error

SQL runs the set of SQL commands against the cluster

func (Cluster) Started

func (cs Cluster) Started() bool

Started returns true if all instances have been started

func (Cluster) Stop

func (cs Cluster) Stop(out io.Writer) error

Stop stops the entire cluster of spicedb instances

func (Cluster) TimeDelay

func (cs Cluster) TimeDelay(ctx context.Context, out io.Writer, node int, duration time.Duration) error

TimeDelay adds a skew to the clock of the given node

type CockroachOption

type CockroachOption func(c *Node)

func SetPeers

func SetPeers(peers []string) CockroachOption

SetPeers returns an option that can set Peers on a Node

func WithAddr

func WithAddr(addr string) CockroachOption

WithAddr returns an option that can set Addr on a Node

func WithHttpaddr

func WithHttpaddr(httpaddr string) CockroachOption

WithHttpaddr returns an option that can set Httpaddr on a Node

func WithId

func WithId(id string) CockroachOption

WithId returns an option that can set ID on a Node

func WithPeers

func WithPeers(peers string) CockroachOption

WithPeers returns an option that can append Peerss to Node.Peers

type Node

type Node struct {
	Peers     []string
	Addr      string
	Httpaddr  string
	ID        string
	MaxOffset time.Duration
	Cancel    context.CancelFunc
	// contains filtered or unexported fields
}

Node represents a single cockroachdb instance

func CockroachWithOptions

func CockroachWithOptions(c *Node, opts ...CockroachOption) *Node

CockroachWithOptions configures an existing Node with the passed in options set

func NewCockroachWithOptions

func NewCockroachWithOptions(opts ...CockroachOption) *Node

NewCockroachWithOptions creates a new Node with the passed in options set

func (*Node) Conn

func (c *Node) Conn() *pgx.Conn

Conn returns the current connection. Must only be called after Connect().

func (*Node) Connect

func (c *Node) Connect(ctx context.Context, _ io.Writer, dbName string) error

Connect connects directly to the cockroach instance and caches the connection

func (*Node) ConnectionString

func (c *Node) ConnectionString(dbName string) string

ConnectionString returns the postgres db URI for this cluster

func (*Node) NodeID

func (c *Node) NodeID(ctx context.Context) (int, error)

NodeID returns the cockroach-internal node id for this connection. This is the value that is referenced by other crdb metadata to identify range leader, follower nodes, etc.

func (*Node) Start

func (c *Node) Start(ctx context.Context) error

Start starts the cockroach instance with exec

func (*Node) Stop

func (c *Node) Stop() error

Jump to

Keyboard shortcuts

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