ohetcd

package module
v0.0.0-...-8c16104 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2016 License: MIT Imports: 8 Imported by: 0

README

ohetcd

Object Tree Mapping(OTM) for etcd, just like ORM!

Why OTM?

Because etcd is watchable and distributed by its nature, OTM makes it simpler.

Scenario

Use this when you need a distributed and consistent variable across many copies of your application.

API

Set(dir, obj, deep)

set a object obj mapping to a etcd directory dir, if deep is set, save recursively, if not, save it in one node.

Update()

manually update a object from etcd.

Save()

save newest object onto etcd.

Watch()

use etcd built-in watch.

Unwatch()

stop watching.

Tips

ohetcd use JSON to marshal and unmarshal object, so set Tag for every field.

Documentation

Index

Constants

View Source
const (
	CH_CLOSE_SIG = 0
)

Variables

This section is empty.

Functions

func SetEtcd

func SetEtcd(cluster string)

Types

type Data

type Data struct {
	Directory string
	Object    interface{}
	Deep      bool
}

func NewData

func NewData() *Data

func (*Data) Save

func (d *Data) Save() error

changes made, save to etcd

func (*Data) Set

func (d *Data) Set(dir string, object interface{}, deep bool)

set etcd path for data

func (*Data) Unwatch

func (d *Data) Unwatch()

func (*Data) Update

func (d *Data) Update()

get up-to-date value from etcd

func (*Data) Watch

func (d *Data) Watch()

type Node

type Node interface {
	Set()
	Update()
	Save()
	Watch()
	Unwatch()
}

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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