Replies: 1 comment
-
Hey @pablogore, thank you first of all :) I haven't had the time for it yet but MySQL/Postgres implementation is definitely on the todo list. If you'd like to do the implementation, you would need to create the // backend/postgres/store_test.go
//go:build postgres
package postgres_test
import (
"testing"
"github.com/modernice/goes/backend/postgres"
"github.com/modernice/goes/backend/testing/eventstoretest"
"github.com/modernice/goes/codec"
"github.com/modernice/goes/event"
)
var _ event.Store = postgres.NewEventStore()
func TestEventStore(t *testing.T) {
eventstoretest.Run(t, "postgres", func(codec.Encoding) event.Store {
return postgres.NewEventStore()
})
} Then implement the event store in package postgres
type EventStore struct { ... }
type EventStoreOption func(*EventStore)
func NewEventStore(opts ...EventStoreOption) *EventStore { ... }
func (*EventStore) Insert(context.Context, ...event.Event) error { ... }
func (*EventStore) Find(context.Context, uuid.UUID) (event.Event, error) { ... }
func (*EventStore) Query(context.Context, event.Query) (<-chan event.Event, <-chan error, error) { ... }
func (*EventStore) Delete(context.Context, ...event.Event) error { ... } The store should connect to package example
func example() {
store := postgres.NewEventStore(postgres.Connection("postgres://username:password@localhost:5432/database_name"))
} I would recommend using the pgx package to implement the store. For guidance you can look at the in-memory and MongoDB implementations of the event store. If you're familiar with Docker, then roughly this docker-compose configuration should be created as version: '3.8'
services:
postgresstore:
image: postgres
test:
depends_on:
- postgresstore
build:
context: ..
dockerfile: .docker/tag-test.Dockerfile
args:
TAGS: postgres And this script should be added to the .PHONY: postgres-test
postgres-test:
docker-compose -f .docker/postgres-test.yml up --build --abort-on-container-exit --remove-orphans; \
docker-compose -f .docker/postgres-test.yml down --remove-orphans If you have any questions or issues, feel free to ask :) |
Beta Was this translation helpful? Give feedback.
-
Do you plan to add new stores to the list, like Postgres or MySQL,?
Could you add some guidelines to help me, I could add Postgres store implementation, really you did wonderful work.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions