Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PostgreSQL Messaging Pub/Sub Watermill #1680

Merged
merged 11 commits into from
Nov 22, 2023
21 changes: 19 additions & 2 deletions cmd/server/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package app

import (
"database/sql"
"fmt"
"log"
"net/url"
Expand Down Expand Up @@ -65,13 +66,29 @@ var serveCmd = &cobra.Command{
if err != nil {
return fmt.Errorf("unable to connect to database: %w", err)
}
defer dbConn.Close()
defer func(dbConn *sql.DB) {
err := dbConn.Close()
if err != nil {
log.Printf("error closing database connection: %v", err)
}
}(dbConn)

store := db.NewStore(dbConn)

dbConnEvents, _, err := cfg.DatabaseQueue.GetDBConnection(ctx)
if err != nil {
return fmt.Errorf("unable to connect to events database: %w", err)
}
defer func(dbConnEvents *sql.DB) {
err := dbConnEvents.Close()
if err != nil {
log.Printf("error closing events database connection: %v", err)
}
}(dbConnEvents)

errg, ctx := errgroup.WithContext(ctx)

evt, err := events.Setup(ctx, &cfg.Events)
evt, err := events.Setup(ctx, &cfg.Events, dbConnEvents)
if err != nil {
log.Printf("Failed to set up eventer: %v", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion config/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ github:
events: ["*"]

events:
driver: go-channel
driver: postgresql
JAORMX marked this conversation as resolved.
Show resolved Hide resolved
router_close_timeout: 10
go-channel: {}
JAORMX marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading