From 1c90e55ca705f270aa44438d38fb6414d6a3b52e Mon Sep 17 00:00:00 2001 From: Ben Meier Date: Sat, 26 Oct 2024 21:20:22 +0100 Subject: [PATCH] chore: rename to NotifyReceivedChanges Signed-off-by: Ben Meier --- examples/http2writer/main.go | 2 +- read.go | 6 +++--- read_test.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/http2writer/main.go b/examples/http2writer/main.go index 884bd69..14f7c2e 100644 --- a/examples/http2writer/main.go +++ b/examples/http2writer/main.go @@ -44,7 +44,7 @@ func mainInner() error { } else if _, err := doc.Commit("commit"); err != nil { panic(err) } - a.NotifyPossibleChanges() + a.NotifyReceivedChanges() } }() diff --git a/read.go b/read.go index f39f4c4..d596646 100644 --- a/read.go +++ b/read.go @@ -11,10 +11,10 @@ import ( "github.com/automerge/automerge-go" ) -// NotifyPossibleChanges should be called after the shared doc has "received" a message. This allows any goroutines that +// NotifyReceivedChanges should be called after the shared doc has "received" a message. This allows any goroutines that // are generating messages to be preempted and know that new messaged may be available. This is a broadcast because // any number of goroutines may be writing changes to the doc to their client. -func (b *SharedDoc) NotifyPossibleChanges() { +func (b *SharedDoc) NotifyReceivedChanges() { b.mutex.Lock() defer b.mutex.Unlock() for _, channel := range b.channels { @@ -44,7 +44,7 @@ func (b *SharedDoc) consumeMessagesFromReader(ctx context.Context, state *autome received += 1 receivedChanges += len(m.Changes()) receivedBytes += len(sc.Bytes()) + 1 - b.NotifyPossibleChanges() + b.NotifyReceivedChanges() if terminationCheck(state.Doc, m) { log.InfoContext(ctx, "termination check met") diff --git a/read_test.go b/read_test.go index 9c9ccc3..7a44251 100644 --- a/read_test.go +++ b/read_test.go @@ -15,7 +15,7 @@ import ( func TestNotifyPossibleChanges_no_subs(t *testing.T) { t.Parallel() a := NewSharedDoc(automerge.New()) - a.NotifyPossibleChanges() + a.NotifyReceivedChanges() } func TestNotifyPossibleChanges_with_sub(t *testing.T) { @@ -33,7 +33,7 @@ func TestNotifyPossibleChanges_with_sub(t *testing.T) { }) t.Run("message available after notify", func(t *testing.T) { - a.NotifyPossibleChanges() + a.NotifyReceivedChanges() select { case v := <-sub: @@ -45,7 +45,7 @@ func TestNotifyPossibleChanges_with_sub(t *testing.T) { t.Run("closer function close channel", func(t *testing.T) { fin() - a.NotifyPossibleChanges() + a.NotifyReceivedChanges() _, ok := <-sub assertEqual(t, false, ok) })