From 47cd62d182616f8bad20659ec2f26126f559c074 Mon Sep 17 00:00:00 2001 From: Ulrich Eckhardt Date: Fri, 5 Jan 2024 22:24:26 +0100 Subject: [PATCH] mongodb: Implement stubs for the changed API --- mongodb/eventstore.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/mongodb/eventstore.go b/mongodb/eventstore.go index 69de8ad..9a70ae9 100644 --- a/mongodb/eventstore.go +++ b/mongodb/eventstore.go @@ -12,6 +12,8 @@ import ( "api-broker-prototype/events" "context" "errors" + + "github.com/gofrs/uuid" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" @@ -69,6 +71,12 @@ func (env *mongoDBEnvelope) Created() time.Time { return env.CreatedVal.Time() } +// ExternalUUID implements the Envelope interface. +func (env *mongoDBEnvelope) ExternalUUID() uuid.UUID { + // TODO: implement UUID support + return uuid.Nil +} + // CausationID implements the Envelope interface. func (env *mongoDBEnvelope) CausationID() int32 { return env.CausationIDVal @@ -192,7 +200,12 @@ func (s *MongoDBEventStore) Close() error { } // Insert implements the EventStore interface. -func (s *MongoDBEventStore) Insert(ctx context.Context, event events.Event, causationID int32) (events.Envelope, error) { +func (s *MongoDBEventStore) Insert(ctx context.Context, externalUUID uuid.UUID, event events.Event, causationID int32) (events.Envelope, error) { + // TODO: implement UUID support + if externalUUID != uuid.Nil { + return nil, errors.New("UUID support not implemented") + } + // don't do anything if the error state of the store is set already s.connect(ctx) if s.err != nil { @@ -275,6 +288,12 @@ func (s *MongoDBEventStore) Insert(ctx context.Context, event events.Event, caus return res, nil } +// ResolveUUID implements the EventStore interface. +func (s *MongoDBEventStore) ResolveUUID(ctx context.Context, externalUUID uuid.UUID) (int32, error) { + // TODO: implement UUID support + return 0, errors.New("UUID support not implemented") +} + // find next free ID to use for an insert // This returns zero and sets the error state if an error occurs. func (s *MongoDBEventStore) findNextID(ctx context.Context) int32 {