kv

package
v0.0.0-...-9ff1fe7 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PetNameDefaultPrefix    = ""
	PetNameDefaultSegments  = 3
	PetNameDefaultSeparator = "-"
)
View Source
const (
	RandomB64DefaultMinSize = 64
	RandomB64DefaultMaxSize = 1024
)
View Source
const (
	DefaultNumEntries = 1024
)

Variables

View Source
var (
	DefaultKeyGenerator   = generators.PetNameGenerator("", 3, "-")
	DefaultValueGenerator = generators.RandomB64Generator(64, 1024)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	NumEntries int
	KeyGen     generators.StringGenerator
	ValueGen   generators.StringGenerator
}

Config is all the configuration necessary for creating KV data

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a config with all the defaults filled in.

type KV

type KV map[string]Value

KV is the output format of the generated KV data before serializing to JSON. This will result in a JSON object that looks like the following:

{
   "<key 1>": {
      "Value": "<data>",
      "Namespace": "<optional>",
      "Datacenter": "<optional>",
      "Token": "<optional>",
      "Flags": <optional - uint>,
   },
   ...
}

All fields of each object may be omitted if they are empty except for the `Value` field

func Generate

func Generate(conf Config) (KV, error)

Generate will generate the desired number of KV entries giving the supplied config

type KeyType

type KeyType string
const (
	KeyTypePetName KeyType = "pet-name"

	DefaultKeyType = KeyTypePetName
)

type PetNameUserConfig

type PetNameUserConfig struct {
	Prefix    string
	Segments  int
	Separator string
}

func DefaultPetNameUserConfig

func DefaultPetNameUserConfig() PetNameUserConfig

func (*PetNameUserConfig) Generator

func (*PetNameUserConfig) Normalize

func (c *PetNameUserConfig) Normalize()

type RandomB64UserConfig

type RandomB64UserConfig struct {
	MinSize int
	MaxSize int
}

func DefaultRandomB64UserConfig

func DefaultRandomB64UserConfig() RandomB64UserConfig

func (*RandomB64UserConfig) Generator

func (*RandomB64UserConfig) Normalize

func (c *RandomB64UserConfig) Normalize()

type UserConfig

type UserConfig struct {
	NumEntries int
	KeyType    KeyType
	ValueType  ValueType

	PetName   PetNameUserConfig
	RandomB64 RandomB64UserConfig
}

func DefaultUserConfig

func DefaultUserConfig() UserConfig

func (*UserConfig) Normalize

func (c *UserConfig) Normalize()

func (*UserConfig) ToGeneratorConfig

func (c *UserConfig) ToGeneratorConfig() (Config, error)

type Value

type Value struct {
	Datacenter string `json:",omitempty"`
	Token      string `json:",omitempty"`
	Value      string
	Namespace  string `json:",omitempty"`
	Flags      uint   `json:",omitempty"`
}

Value is the value type of the KV mapping

type ValueType

type ValueType string
const (
	ValueTypeRandomB64 ValueType = "random-b64"

	DefaultValueType = ValueTypeRandomB64
)

Jump to

Keyboard shortcuts

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