Skip to content

Commit 1586163

Browse files
committed
Renamed package
1 parent 3278513 commit 1586163

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PG Listener Tests
1+
name: PG Watcher Tests
22

33
on:
44
push:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# PG Listener
1+
# PG Watcher
22

3-
[![PG Listener Tests](https://github.com/smarter-day/pg-listener/actions/workflows/tests.yml/badge.svg)](https://github.com/smarter-day/pg-listener/actions/workflows/tests.yml)
3+
[![PG Watcher Tests](https://github.com/smarter-day/pg-listener/actions/workflows/tests.yml/badge.svg)](https://github.com/smarter-day/pg-listener/actions/workflows/tests.yml)
44

55
A lightweight Go library for listening to PostgreSQL notifications in parallel across channels while preserving in-order delivery within each channel. It reconnects on errors, ensuring fault tolerance and redundancy.
66

@@ -37,7 +37,7 @@ import (
3737
"time"
3838

3939
"github.com/jackc/pgx/v5/pgxpool"
40-
"github.com/smarter-day/pg-listener"
40+
"github.com/smarter-day/pgwatcher"
4141
)
4242

4343
func main() {
@@ -49,10 +49,10 @@ func main() {
4949
defer dbpool.Close()
5050

5151
// 2. Create an IListener
52-
l := listener.NewListener(dbpool)
52+
l := pgwatcher.NewListener(dbpool)
5353

5454
// 3. Create and run the notifier
55-
n := listener.NewNotifier(l)
55+
n := pgwatcher.NewNotifier(l)
5656
ctx, cancel := context.WithCancel(context.Background())
5757
if err := n.Run(ctx); err != nil {
5858
panic(err)

examples/two-collections/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"github.com/jackc/pgx/v5/pgxpool"
66
"github.com/jackc/pgx/v5/tracelog"
7-
"listener"
7+
"github.com/smarter-day/pgwatcher"
88
"log"
99
"os"
1010
"time"
@@ -44,8 +44,8 @@ func main() {
4444
defer pool.Close()
4545

4646
// Initialize IListener and INotifier
47-
l := listener.NewListener(pool)
48-
n := listener.NewNotifier(l)
47+
l := pgwatcher.NewListener(pool)
48+
n := pgwatcher.NewNotifier(l)
4949

5050
// Run INotifier with context cancellation
5151
ctx, cancel := context.WithTimeout(context.Background(), time.Hour)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module listener
1+
module github.com/smarter-day/pgwatcher
22

33
go 1.22.8
44

listener.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package listener
1+
package pgwatcher
22

33
import (
44
"context"

notifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package listener
1+
package pgwatcher
22

33
import (
44
"context"

notifier_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package listener_test
1+
package pgwatcher_test
22

33
import (
44
"context"
55
"errors"
6-
"listener"
6+
"github.com/smarter-day/pgwatcher"
77
"sync"
88
"testing"
99
"time"
@@ -16,13 +16,13 @@ type mockListener struct {
1616
mu sync.Mutex
1717
connected bool
1818
channels map[string]bool
19-
notificationsC chan *listener.Notification
19+
notificationsC chan *pgwatcher.Notification
2020
}
2121

2222
func newMockListener() *mockListener {
2323
return &mockListener{
2424
channels: make(map[string]bool),
25-
notificationsC: make(chan *listener.Notification, 100),
25+
notificationsC: make(chan *pgwatcher.Notification, 100),
2626
}
2727
}
2828

@@ -58,7 +58,7 @@ func (m *mockListener) UnListen(ctx context.Context, channel string) error {
5858
return nil
5959
}
6060

61-
func (m *mockListener) WaitForNotification(ctx context.Context) (*listener.Notification, error) {
61+
func (m *mockListener) WaitForNotification(ctx context.Context) (*pgwatcher.Notification, error) {
6262
select {
6363
case <-ctx.Done():
6464
return nil, ctx.Err()
@@ -80,7 +80,7 @@ func (m *mockListener) Ping(ctx context.Context) error {
8080
}
8181

8282
// pushNotification simulates server pushing a notification.
83-
func (m *mockListener) pushNotification(ntf *listener.Notification) {
83+
func (m *mockListener) pushNotification(ntf *pgwatcher.Notification) {
8484
m.notificationsC <- ntf
8585
}
8686

@@ -94,7 +94,7 @@ func TestNotifierWithSingleChannel(t *testing.T) {
9494
defer cancel()
9595

9696
mockL := newMockListener()
97-
n := listener.NewNotifier(mockL)
97+
n := pgwatcher.NewNotifier(mockL)
9898

9999
// Start the Notifier (it will Connect automatically in the runLoop).
100100
err := n.Run(ctx)
@@ -109,7 +109,7 @@ func TestNotifierWithSingleChannel(t *testing.T) {
109109
go func() {
110110
time.Sleep(200 * time.Millisecond) // Let it set up
111111
for _, w := range want {
112-
mockL.pushNotification(&listener.Notification{
112+
mockL.pushNotification(&pgwatcher.Notification{
113113
Channel: "foo",
114114
Payload: []byte(w),
115115
})
@@ -141,7 +141,7 @@ func TestNotifierWithMultipleChannels(t *testing.T) {
141141
defer cancel()
142142

143143
mockL := newMockListener()
144-
n := listener.NewNotifier(mockL)
144+
n := pgwatcher.NewNotifier(mockL)
145145
err := n.Run(ctx)
146146
is.NoErr(err)
147147

@@ -152,10 +152,10 @@ func TestNotifierWithMultipleChannels(t *testing.T) {
152152
// We want to ensure concurrency across channels, so we push them at the same time.
153153
go func() {
154154
time.Sleep(200 * time.Millisecond)
155-
mockL.pushNotification(&listener.Notification{Channel: "foo", Payload: []byte("foo1")})
156-
mockL.pushNotification(&listener.Notification{Channel: "bar", Payload: []byte("bar1")})
157-
mockL.pushNotification(&listener.Notification{Channel: "foo", Payload: []byte("foo2")})
158-
mockL.pushNotification(&listener.Notification{Channel: "bar", Payload: []byte("bar2")})
155+
mockL.pushNotification(&pgwatcher.Notification{Channel: "foo", Payload: []byte("foo1")})
156+
mockL.pushNotification(&pgwatcher.Notification{Channel: "bar", Payload: []byte("bar1")})
157+
mockL.pushNotification(&pgwatcher.Notification{Channel: "foo", Payload: []byte("foo2")})
158+
mockL.pushNotification(&pgwatcher.Notification{Channel: "bar", Payload: []byte("bar2")})
159159
}()
160160

161161
var gotFoo, gotBar []string

types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package listener
1+
package pgwatcher
22

33
import "context"
44

0 commit comments

Comments
 (0)