setcd

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

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

Go to latest
Published: May 25, 2017 License: GPL-3.0 Imports: 12 Imported by: 0

README

#+TITLE: Setcd -- Structed Etcd

*Setcd* is abbreviation of *Structed etcd*.
Its core function is that to store/manage structured data to/form etcd, simply.
At the beginning, it was created for build a configuration management platforms, quickly.

*Note*: ~Beta version~

* Features
  
  + Sotre/Manage structured data
  + Revision with a tag
  + Txn operations
  + Dir reference as value (indirect access)
  + Custom function for format ~dir reference~
  + Custom function for check ~indirect access~

* Supported Data Type

  + bool, int, uint, float, string
  + slice, array
  + map
  + struct

Documentation

Index

Constants

View Source
const (
	SInvalid SKind = "invalid"
	SNil           = "nil"
	SScale         = "scale"
	SSlice         = "slice"
	SMap           = "map"
)

Variables

View Source
var (
	ErrInvalidArgument     = fmt.Errorf("invalid argument")
	ErrInvalidOperation    = fmt.Errorf("invalid operation")
	ErrUnsupportedOperaton = fmt.Errorf("unsupported operation")
	ErrUnknownType         = fmt.Errorf("unknown type")
	ErrUnsupportedType     = fmt.Errorf("unsupported type")

	ErrNotAbsoluteDir      = fmt.Errorf("%s: required an absolute directory", ErrInvalidArgument)
	ErrNotAllowedDir       = fmt.Errorf("%s: not allowed directory", ErrInvalidArgument)
	ErrEmptyDir            = fmt.Errorf("%s: empty dir", ErrInvalidOperation)
	ErrUnsupportedDeletion = fmt.Errorf("%s: 'Delete' dir on type", ErrUnsupportedOperaton)
	ErrUnsupportedDo       = fmt.Errorf("%s: 'Do' dir on type", ErrUnsupportedOperaton)
	ErrIndexOutOfRange     = fmt.Errorf("slice index out of range")
)
View Source
var Config config

Functions

This section is empty.

Types

type Client

type Client struct {
	*clientv3.Client // etcd clientv3
	// contains filtered or unexported fields
}

Client provides and manages an mapetcd client session.

func New

func New(cfg clientv3.Config, ctx context.Context, directory string) (*Client, error)

New creates a new mapetcd client

func (*Client) Close

func (c *Client) Close() error

Close shuts down the client's etcd connections.

func (*Client) Delete

func (c *Client) Delete(oos ...OpOption) error

Delete ...

func (*Client) Do

func (c *Client) Do(fn func(string, interface{}) bool, oos ...OpOption) error

Do calls function fn on each element of the map/slice.

func (*Client) DoMap

func (c *Client) DoMap(fn func(string, interface{}) bool, oos ...OpOption) error

DoMap ...

func (*Client) DoSlice

func (c *Client) DoSlice(fn func(int, interface{}) bool, oos ...OpOption) error

DoSlice calls function fn on each element of the slice.

func (*Client) Get

func (c *Client) Get(oos ...OpOption) (interface{}, error)

Get ... TODO withKeysOnly:

  • [x] map
  • [] array

withTagsOnly

func (*Client) GetBool

func (c *Client) GetBool() (bool, error)

GetBool ...

func (*Client) GetBoolVar

func (c *Client) GetBoolVar(bp *bool) error

GetBoolVar ...

func (*Client) GetFloat32

func (c *Client) GetFloat32() (float32, error)

GetFloat32 ...

func (*Client) GetFloat32Var

func (c *Client) GetFloat32Var(fp *float32) (err error)

GetFloat32Var ...

func (*Client) GetFloat64

func (c *Client) GetFloat64() (float64, error)

GetFloat64 ...

func (*Client) GetFloat64Var

func (c *Client) GetFloat64Var(fp *float64) (err error)

GetFloat64Var ...

func (*Client) GetInt

func (c *Client) GetInt() (int, error)

GetInt ...

func (*Client) GetInt16

func (c *Client) GetInt16() (int16, error)

GetInt16 ...

func (*Client) GetInt16Var

func (c *Client) GetInt16Var(ip *int16) (err error)

(c *Client) GetInt16Var ...

func (*Client) GetInt32

func (c *Client) GetInt32() (int32, error)

GetInt32 ...

func (*Client) GetInt32Var

func (c *Client) GetInt32Var(ip *int32) (err error)

(c *Client) GetInt32Var ...

func (*Client) GetInt64

func (c *Client) GetInt64() (int64, error)

GetInt64 ...

func (*Client) GetInt64Var

func (c *Client) GetInt64Var(ip *int64) (err error)

(c *Client) GetInt64Var ...

func (*Client) GetInt8

func (c *Client) GetInt8() (int8, error)

GetInt8 ...

func (*Client) GetInt8Var

func (c *Client) GetInt8Var(ip *int8) (err error)

(c *Client) GetInt8Var ...

func (*Client) GetIntVar

func (c *Client) GetIntVar(ip *int) (err error)

(c *Client) GetIntVar ...

func (*Client) GetMap

func (c *Client) GetMap(oos ...OpOption) (map[string]interface{}, error)

(c *Client) GetMap ...

func (*Client) GetSlice

func (c *Client) GetSlice(oos ...OpOption) ([]interface{}, error)

GetSlice ...

func (*Client) GetString

func (c *Client) GetString() (string, error)

GetString ...

func (*Client) GetStringVar

func (c *Client) GetStringVar(sp *string) (err error)

GetStringVar ...

func (*Client) GetStructVar

func (c *Client) GetStructVar(out interface{}, oos ...OpOption) error

func (*Client) GetUint

func (c *Client) GetUint() (uint, error)

GetUint ...

func (*Client) GetUint16

func (c *Client) GetUint16() (uint16, error)

GetUint16 ...

func (*Client) GetUint16Var

func (c *Client) GetUint16Var(ip *uint16) (err error)

(c *Client) GetUint16Var ...

func (*Client) GetUint32

func (c *Client) GetUint32() (uint32, error)

GetUint32 ...

func (*Client) GetUint32Var

func (c *Client) GetUint32Var(ip *uint32) (err error)

(c *Client) GetUint32Var ...

func (*Client) GetUint64

func (c *Client) GetUint64() (uint64, error)

GetUint64 ...

func (*Client) GetUint64Var

func (c *Client) GetUint64Var(ip *uint64) (err error)

(c *Client) GetUint64Var ...

func (*Client) GetUint8

func (c *Client) GetUint8() (uint8, error)

GetUint8 ...

func (*Client) GetUint8Var

func (c *Client) GetUint8Var(ip *uint8) (err error)

(c *Client) GetUint8Var ...

func (*Client) GetUintVar

func (c *Client) GetUintVar(ip *uint) (err error)

GetUintVar ...

func (*Client) Put

func (c *Client) Put(in interface{}, oos ...OpOption) error

Put ...

func (*Client) PutMap

func (c *Client) PutMap(in map[string]interface{}) error

func (*Client) PutSlice

func (c *Client) PutSlice(in []interface{}, oos ...OpOption) error

func (*Client) ShadowClone

func (c *Client) ShadowClone(directory string) (*Client, error)

ShadowClone "The Shadow Clone Jutsu" TODO: assert the client is New

type Kind

type Kind int
const (
	Invalid Kind = iota
	Nil
	Scale
	Slice
	Map
)

func (Kind) ConvSKind

func (k Kind) ConvSKind() SKind

func (Kind) String

func (k Kind) String() string

type OpOption

type OpOption func(*Option)

func WithEval

func WithEval() OpOption

func WithEvalTags

func WithEvalTags(etags map[string]string) OpOption

func WithEvalVarCheck

func WithEvalVarCheck(f func(string) error) OpOption

func WithEvalVarFmt

func WithEvalVarFmt(f func(string) string) OpOption

func WithKeysOnly

func WithKeysOnly() OpOption

func WithLock

func WithLock() OpOption

func WithTag

func WithTag(tag string) OpOption

func WithTagsOnly

func WithTagsOnly() OpOption

type Option

type Option struct {
	// contains filtered or unexported fields
}

type SKind

type SKind string

func (SKind) ConvKind

func (s SKind) ConvKind() Kind

type STM

type STM struct {
	// contains filtered or unexported fields
}

STM ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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