2015-01-13 23:31:27 +00:00
|
|
|
package store
|
|
|
|
|
|
|
|
type Store interface {
|
2015-05-23 21:25:55 +01:00
|
|
|
Get(string) (*Item, error)
|
2015-01-13 23:31:27 +00:00
|
|
|
Del(string) error
|
2015-05-23 21:25:55 +01:00
|
|
|
Put(*Item) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type Item struct {
|
|
|
|
Key string
|
|
|
|
Value []byte
|
2015-01-13 23:31:27 +00:00
|
|
|
}
|
|
|
|
|
2015-05-16 00:34:02 +01:00
|
|
|
type options struct{}
|
|
|
|
|
2015-05-23 20:04:16 +01:00
|
|
|
type Option func(*options)
|
2015-05-16 00:34:02 +01:00
|
|
|
|
2015-01-13 23:31:27 +00:00
|
|
|
var (
|
2015-05-23 20:04:16 +01:00
|
|
|
DefaultStore = newConsulStore([]string{})
|
2015-01-13 23:31:27 +00:00
|
|
|
)
|
|
|
|
|
2015-05-23 20:04:16 +01:00
|
|
|
func NewStore(addrs []string, opt ...Option) Store {
|
|
|
|
return newConsulStore(addrs, opt...)
|
|
|
|
}
|
|
|
|
|
2015-05-23 21:25:55 +01:00
|
|
|
func Get(key string) (*Item, error) {
|
2015-01-13 23:31:27 +00:00
|
|
|
return DefaultStore.Get(key)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Del(key string) error {
|
|
|
|
return DefaultStore.Del(key)
|
|
|
|
}
|
|
|
|
|
2015-05-23 21:25:55 +01:00
|
|
|
func Put(item *Item) error {
|
2015-01-13 23:31:27 +00:00
|
|
|
return DefaultStore.Put(item)
|
|
|
|
}
|