From e0f3418e802da3ecc2185e7c16ef32802442eec8 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Thu, 28 Nov 2024 01:26:41 +0700 Subject: [PATCH] Update store --- store/store.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/store/store.go b/store/store.go index 896c1350..db69f9f6 100644 --- a/store/store.go +++ b/store/store.go @@ -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)