etcdhelper

package
v0.0.0-...-a6f28c4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package etcdhelper implements marshaling whole etcd prefixes from and to go values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(source any, prefix string) []clientv3.Op

Marshals a go value to a slice of etcd PUT operations with a given prefix.

Currently only go structs are supported.

Use the etcd tag to map a given struct field to a different name in etcd or use "-" to don't map the key. E.g. `etcd:"foo"` maps a struct field to the etcd key named "foo".

func UnmarshalGet

func UnmarshalGet(ctx context.Context, kv clientv3.KV, prefix string, dest any) (uint, error)

Makes an etcd prefix query and unmarshals the result into the given `dest` value. It returns the number of query results that were mapped to the `dest` value. The unmarshal currently can only handle maps with string keys and structs. Structs are mapped with their element names by default. To override this use the `etcd` tag. A `-` as key name indicates that the given struct element is not mapped to etcd. E.g. to map the etcd field named foo use `etcd:"foo"` for the corresponding struct field

Types

This section is empty.

Jump to

Keyboard shortcuts

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