etcd_examples

package module
v0.0.0-...-dc14e8d Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 4 Imported by: 0

README

ETCD examples

Code examples about interaction with ETCD.

Usage

# Launch a local ETCD server
podman run \
	--name etcd \
	--publish 2379:2379 \
	--env ALLOW_NONE_AUTHENTICATION=yes \
	--env ETCD_ADVERTISE_CLIENT_URLS=http://localhost:2379 \
	-d \
	bitnami/etcd:3.5.1

# Shutdown
podman rm -f etcd

# Purge all key-values
podman run --rm --net=host bitnami/etcd etcdctl del '' --prefix
lock_get_put lock, read, then modify the value of key
# Watch all key-values revisions
podman run --rm --net=host bitnami/etcd etcdctl watch /bar --prefix

# Run
ETCD_CLUSTER=http://localhost:2379 go run ./lock_get_put 
lock_get_put_v2/collections modify ETCD value with lock
# Watch all key-values revisions
podman run --rm --net=host bitnami/etcd etcdctl watch / --prefix

# Run
ETCD_CLUSTER=http://localhost:2379 go test ./lock_get_put_v2/... -v
value_history Get all historical modifications of value
# Run
ETCD_CLUSTER=http://localhost:2379 go run ./value_history

Documentation

Index

Constants

View Source
const (
	ENV_ETCD_ENDPOINT = "ETCD_CLUSTER"
	ENV_ETCD_PASSWORD = "ETCD_PASSWORD"
	ENV_ETCD_USERNAME = "ETCD_USERNAME"
)

Variables

This section is empty.

Functions

func EtcdCfgFromEnv

func EtcdCfgFromEnv() clientv3.Config

Types

This section is empty.

Jump to

Keyboard shortcuts

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