add Live/Ready/Health methods
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -149,6 +149,18 @@ func (m *memoryStore) Name() string {
|
||||
return m.opts.Name
|
||||
}
|
||||
|
||||
func (m *memoryStore) Live() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *memoryStore) Ready() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *memoryStore) Health() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *memoryStore) Exists(ctx context.Context, key string, opts ...store.ExistsOption) error {
|
||||
if m.opts.LazyConnect {
|
||||
if err := m.connect(ctx); err != nil {
|
||||
@@ -279,3 +291,16 @@ func (m *memoryStore) connect(ctx context.Context) error {
|
||||
m.isConnected.CompareAndSwap(0, 1)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *memoryStore) Watch(ctx context.Context, opts ...store.WatchOption) (store.Watcher, error) {
|
||||
return &watcher{}, nil
|
||||
}
|
||||
|
||||
type watcher struct{}
|
||||
|
||||
func (w *watcher) Next() (store.Event, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (w *watcher) Stop() {
|
||||
}
|
||||
|
||||
@@ -23,6 +23,18 @@ type noopStore struct {
|
||||
isConnected atomic.Int32
|
||||
}
|
||||
|
||||
func (n *noopStore) Live() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (n *noopStore) Ready() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (n *noopStore) Health() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func NewStore(opts ...Option) *noopStore {
|
||||
options := NewOptions(opts...)
|
||||
return &noopStore{opts: options}
|
||||
|
||||
@@ -45,7 +45,14 @@ type Store interface {
|
||||
Disconnect(ctx context.Context) error
|
||||
// String returns the name of the implementation.
|
||||
String() string
|
||||
// Watch returns events watcher
|
||||
Watch(ctx context.Context, opts ...WatchOption) (Watcher, error)
|
||||
// Live returns store liveness
|
||||
Live() bool
|
||||
// Ready returns store readiness
|
||||
Ready() bool
|
||||
// Health returns store health
|
||||
Health() bool
|
||||
}
|
||||
|
||||
type (
|
||||
|
||||
@@ -70,3 +70,15 @@ func (w *NamespaceStore) String() string {
|
||||
func (w *NamespaceStore) Watch(ctx context.Context, opts ...WatchOption) (Watcher, error) {
|
||||
return w.s.Watch(ctx, opts...)
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Live() bool {
|
||||
return w.s.Live()
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Ready() bool {
|
||||
return w.s.Ready()
|
||||
}
|
||||
|
||||
func (w *NamespaceStore) Health() bool {
|
||||
return w.s.Health()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user