From a5140df7ef6c5a81d0128d4548d8284c42e0c0ba Mon Sep 17 00:00:00 2001 From: Florimond Husquinet Date: Mon, 29 Jan 2024 07:50:31 +0100 Subject: [PATCH] [FIX] Storage implement the Surveyee interface This is a proper fix for #323 --- internal/broker/service.go | 6 +----- internal/provider/storage/storage.go | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/broker/service.go b/internal/broker/service.go index 8f1ad6c7..92d6004b 100644 --- a/internal/broker/service.go +++ b/internal/broker/service.go @@ -157,11 +157,7 @@ func NewService(ctx context.Context, cfg *config.Config) (s *Service, err error) s.surveyor = survey.New(s.pubsub, s.cluster) s.presence = presence.New(s, s.pubsub, s.surveyor, s.subscriptions) if s.cluster != nil { - if s.storage.Name() == ssdstore.Name() { - s.surveyor.HandleFunc(s.presence, ssdstore) - } else if s.storage.Name() == memstore.Name() { - s.surveyor.HandleFunc(s.presence, memstore) - } + s.surveyor.HandleFunc(s.storage) } // Create a new cipher from the licence provided diff --git a/internal/provider/storage/storage.go b/internal/provider/storage/storage.go index e3689195..ac76d0a7 100644 --- a/internal/provider/storage/storage.go +++ b/internal/provider/storage/storage.go @@ -22,6 +22,7 @@ import ( "github.com/emitter-io/config" "github.com/emitter-io/emitter/internal/message" "github.com/emitter-io/emitter/internal/security" + "github.com/emitter-io/emitter/internal/service/survey" ) var ( @@ -37,6 +38,7 @@ const ( type Storage interface { config.Provider io.Closer + survey.Surveyee // Store is used to store a message, the SSID provided must be a full SSID // SSID, where first element should be a contract ID. The time resolution @@ -139,3 +141,8 @@ func (s *Noop) Query(ssid message.Ssid, from, until time.Time, startFromID messa func (s *Noop) Close() error { return nil } + +// OnSurvey handles an incoming cluster lookup request. +func (s *Noop) OnSurvey(surveyType string, payload []byte) ([]byte, bool) { + return []byte{}, true +}