Skip to content

Commit 9464a84

Browse files
authored
Merge pull request #1230 from kissejau/master
chore(breaking): rename Listener.Channel to Listener.CreateChannel
2 parents 16b9ca4 + 32d85ae commit 9464a84

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

driver/pgdriver/listener.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ func (ln *Listener) unlisten(ctx context.Context, cn *Conn, channels ...string)
196196
}
197197

198198
// Receive indefinitely waits for a notification. This is low-level API
199-
// and in most cases Channel should be used instead.
199+
// and in most cases CreateChannel should be used instead.
200200
func (ln *Listener) Receive(ctx context.Context) (channel string, payload string, err error) {
201201
return ln.ReceiveTimeout(ctx, 0)
202202
}
203203

204204
// ReceiveTimeout waits for a notification until timeout is reached.
205-
// This is low-level API and in most cases Channel should be used instead.
205+
// This is low-level API and in most cases CreateChannel should be used instead.
206206
func (ln *Listener) ReceiveTimeout(
207207
ctx context.Context, timeout time.Duration,
208208
) (channel, payload string, err error) {
@@ -226,12 +226,12 @@ func (ln *Listener) ReceiveTimeout(
226226
return channel, payload, nil
227227
}
228228

229-
// Channel returns a channel for concurrently receiving notifications.
229+
// CreateChannel creates and returns a channel for concurrently receiving notifications.
230230
// It periodically sends Ping notification to test connection health.
231231
//
232232
// The channel is closed with Listener. Receive* APIs can not be used
233233
// after channel is created.
234-
func (ln *Listener) Channel(opts ...ChannelOption) <-chan Notification {
234+
func (ln *Listener) CreateChannel(opts ...ChannelOption) <-chan Notification {
235235
return newChannel(ln, opts).ch
236236
}
237237

example/pg-listen/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func main() {
3838
panic(err)
3939
}
4040

41-
for notif := range ln.Channel() {
41+
for notif := range ln.CreateChannel() {
4242
fmt.Println(notif.Channel, notif.Payload)
4343
}
4444
}

internal/dbtest/listener_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestListenerChannel(t *testing.T) {
5858
db := pg(t)
5959

6060
ln := pgdriver.NewListener(db)
61-
ch := ln.Channel()
61+
ch := ln.CreateChannel()
6262

6363
err := ln.Listen(ctx, "test_channel")
6464
require.NoError(t, err)
@@ -101,7 +101,7 @@ func TestListenerChannelOverflowHandler(t *testing.T) {
101101
var overflowCount atomic.Int32
102102

103103
// Create channel with small buffer and overflow handler
104-
ch := ln.Channel(
104+
ch := ln.CreateChannel(
105105
pgdriver.WithChannelSize(channelSize),
106106
pgdriver.WithChannelOverflowHandler(func(n pgdriver.Notification) {
107107
overflowCount.Add(1)

0 commit comments

Comments
 (0)