https://github.com/davidroman0o/watermill-comfymill
Watermill Sqlite3 Pub/Sub
https://github.com/davidroman0o/watermill-comfymill
cqrs event-driven event-sourcing events go golang sqlite3 watermill
Last synced: 7 months ago
JSON representation
Watermill Sqlite3 Pub/Sub
- Host: GitHub
- URL: https://github.com/davidroman0o/watermill-comfymill
- Owner: davidroman0O
- Created: 2024-04-02T21:52:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-23T01:20:18.000Z (about 1 year ago)
- Last Synced: 2025-04-02T20:43:33.451Z (7 months ago)
- Topics: cqrs, event-driven, event-sourcing, events, go, golang, sqlite3, watermill
- Language: Go
- Homepage:
- Size: 297 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Watermill Comfylite Pub/Sub
This is an unofficial `sqlite3` provider leveraging [`comfylite3`](https://github.com/davidroman0O/comfylite3) for the [Watermill](https://watermill.io/) project.
Since there are a lot of issues using `sqlite3` for either in memory or with a file when used in concurrency situations, `comfylite3` provide a while bypass for us.
All you need to use `comfymill.NewDatabase`, use your own parameters (check `comfylite3` docs) and tadam!

# Install
```
go get -u github.com/davidroman0O/watermill-comfymill
```
# Example
It's a simple implementation of the MySql code for Sqlite3, here an example usage of it:
```go
comfy, err := comfylite3.New(comfylite3.WithMemory())
if err != nil {
panic(err)
}
db := comfylite3.OpenDB(comfy)
if err != nil {
panic(err)
}
subscriber, err := sql.NewSubscriber(
db,
sql.SubscriberConfig{
SchemaAdapter: comfymill.DefaultSQLite3Schema{},
OffsetsAdapter: comfymill.DefaultSQLite3OffsetsAdapter{},
InitializeSchema: true,
},
logger,
)
if err != nil {
panic(err)
}
messages, err := subscriber.Subscribe(context.Background(), "example_topic")
if err != nil {
panic(err)
}
go process(messages)
publisher, err := sql.NewPublisher(
db,
sql.PublisherConfig{
SchemaAdapter: comfymill.DefaultSQLite3Schema{},
},
logger,
)
if err != nil {
panic(err)
}
```
You can refer to the [basic example too](./_example/basic/main.go)