Update store
This commit is contained in:
parent
dc0ff91b83
commit
e0f3418e80
@ -6,6 +6,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type EventType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
EventTypeUnknown = iota
|
||||||
|
EventTypeConnect
|
||||||
|
EventTypeDisconnect
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrNotFound is returned when a key doesn't exist
|
// ErrNotFound is returned when a key doesn't exist
|
||||||
ErrNotFound = errors.New("not found")
|
ErrNotFound = errors.New("not found")
|
||||||
@ -17,6 +25,11 @@ var (
|
|||||||
DefaultSeparator = "/"
|
DefaultSeparator = "/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Event interface {
|
||||||
|
Error() error
|
||||||
|
Type() EventType
|
||||||
|
}
|
||||||
|
|
||||||
// Store is a data storage interface
|
// Store is a data storage interface
|
||||||
type Store interface {
|
type Store interface {
|
||||||
Name() string
|
Name() string
|
||||||
@ -41,3 +54,12 @@ type Store interface {
|
|||||||
// String returns the name of the implementation.
|
// String returns the name of the implementation.
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Watcher interface {
|
||||||
|
// Next is a blocking call
|
||||||
|
Next() (Event, error)
|
||||||
|
// Stop stops the watcher
|
||||||
|
Stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Watch(context.Context) (Watcher, error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user