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

internal/grpcsync: Provide an internal-only pub-sub type API #6167

Merged
merged 17 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move pubsub from genericpubsub to grpcsync
and rename it to pubsub
  • Loading branch information
my4-dev committed Apr 4, 2023
commit 4f83a06b5b77afd7e8b1171e8bc90bcad638f1eb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 16,11 @@
*
*/

// Package genericpubsub provides functionality to report and track
// target changes of struct which is registered as a subscriber.
package genericpubsub
package grpcsync

import (
"context"
"sync"

"google.golang.org/grpc/internal/grpcsync"
)

// Watcher wraps the functionality to be implemented by components
Expand All @@ -43,7 39,7 @@ type Watcher interface {
// Components interested in target updates of the tracked entity
// subscribe to updates by calling the AddWatcher() method.
type Tracker struct {
cs *grpcsync.CallbackSerializer
cs *CallbackSerializer
cancel context.CancelFunc

// Access to the below fields are guarded by this mutex.
Expand All @@ -58,7 54,7 @@ type Tracker struct {
func NewTracker(target interface{}) *Tracker {
ctx, cancel := context.WithCancel(context.Background())
return &Tracker{
cs: grpcsync.NewCallbackSerializer(ctx),
cs: NewCallbackSerializer(ctx),
cancel: cancel,
target: target,
watchers: map[Watcher]bool{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 16,16 @@
*
*/

package genericpubsub
package grpcsync

import (
"sync"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"google.golang.org/grpc/internal/grpctest"
)

type s struct {
grpctest.Tester
}

func Test(t *testing.T) {
grpctest.RunSubTests(t, s{})
}

type mockWatcher struct {
mu sync.Mutex
t *testing.T
Expand Down