Skip to content

Commit

Permalink
mongodb: Implement stubs for the changed API
Browse files Browse the repository at this point in the history
  • Loading branch information
UlrichEckhardt committed Jan 6, 2024
1 parent bfddbd9 commit 47cd62d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion mongodb/eventstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 47cd62d

Please sign in to comment.