New creates a new Pubsub implementation using a PostgreSQL connection.
(startCtx context.Context, logger slog.Logger, db *sql.DB, connectURL string)
| 683 | |
| 684 | // New creates a new Pubsub implementation using a PostgreSQL connection. |
| 685 | func New(startCtx context.Context, logger slog.Logger, db *sql.DB, connectURL string) (*PGPubsub, error) { |
| 686 | p := newWithoutListener(logger, db) |
| 687 | if err := p.startListener(startCtx, connectURL); err != nil { |
| 688 | return nil, err |
| 689 | } |
| 690 | go p.listen() |
| 691 | logger.Debug(startCtx, "pubsub has started") |
| 692 | return p, nil |
| 693 | } |
| 694 | |
| 695 | // newWithoutListener creates a new PGPubsub without creating the pqListener. |
| 696 | func newWithoutListener(logger slog.Logger, db *sql.DB) *PGPubsub { |