Update store

This commit is contained in:
Aleksandr Tolstikhin 2024-11-28 01:26:41 +07:00
parent dc0ff91b83
commit e0f3418e80

View File

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