Delete store, this is not a core requirement of microservices, will be included in go-platform

This commit is contained in:
Asim
2015-05-25 17:19:13 +01:00
parent 54ad8f253f
commit 23264dded0
8 changed files with 0 additions and 275 deletions

View File

@@ -1,50 +0,0 @@
package etcd
import (
"errors"
"github.com/coreos/go-etcd/etcd"
"github.com/myodc/go-micro/store"
)
type estore struct {
Client *etcd.Client
}
func (e *estore) Get(key string) (*store.Item, error) {
kv, err := e.Client.Get(key, false, false)
if err != nil {
return nil, err
}
if kv == nil {
return nil, errors.New("key not found")
}
return &store.Item{
Key: kv.Node.Key,
Value: []byte(kv.Node.Value),
}, nil
}
func (e *estore) Del(key string) error {
_, err := e.Client.Delete(key, false)
return err
}
func (e *estore) Put(item *store.Item) error {
_, err := e.Client.Set(item.Key, string(item.Value), 0)
return err
}
func NewStore(addrs []string, opts ...store.Option) store.Store {
if len(addrs) == 0 {
addrs = []string{"127.0.0.1:2379"}
}
client := etcd.NewClient(addrs)
return &estore{
Client: client,
}
}