Skip to content

Commit

Permalink
s/New/NewClient and namespace the client option funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
snormore committed Jul 11, 2022
1 parent 3a0680b commit 9d1706e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func queryMessages(t *testing.T, c *node.WakuNode, peerAddr string, contentTopic
pi, err := peer.AddrInfoFromString(peerAddr)
require.NoError(t, err)

client, err := store.New(
store.WithLog(log),
store.WithHost(c.Host()),
store.WithPeer(pi.ID),
client, err := store.NewClient(
store.WithClientLog(log),
store.WithClientHost(c.Host()),
store.WithClientPeer(pi.ID),
)
require.NoError(t, err)

Expand Down
8 changes: 4 additions & 4 deletions store/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ var (

type ClientOption func(c *Client)

func WithLog(log *zap.Logger) ClientOption {
func WithClientLog(log *zap.Logger) ClientOption {
return func(c *Client) {
c.log = log
}
}

func WithHost(host host.Host) ClientOption {
func WithClientHost(host host.Host) ClientOption {
return func(c *Client) {
c.host = host
}
}

func WithPeer(id peer.ID) ClientOption {
func WithClientPeer(id peer.ID) ClientOption {
return func(c *Client) {
c.peer = &id
}
}

func New(opts ...ClientOption) (*Client, error) {
func NewClient(opts ...ClientOption) (*Client, error) {
c := &Client{}
for _, opt := range opts {
opt(c)
Expand Down
22 changes: 11 additions & 11 deletions store/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestStoreClient_New(t *testing.T) {
{
name: "missing host",
opts: []ClientOption{
WithLog(log),
WithClientLog(log),
},
expect: func(t *testing.T, c *Client, err error) {
require.Equal(t, ErrMissingHostOption, err)
Expand All @@ -43,8 +43,8 @@ func TestStoreClient_New(t *testing.T) {
{
name: "missing peer",
opts: []ClientOption{
WithLog(log),
WithHost(host),
WithClientLog(log),
WithClientHost(host),
},
expect: func(t *testing.T, c *Client, err error) {
require.Equal(t, ErrMissingPeerOption, err)
Expand All @@ -54,9 +54,9 @@ func TestStoreClient_New(t *testing.T) {
{
name: "success",
opts: []ClientOption{
WithLog(log),
WithHost(host),
WithPeer(peerID),
WithClientLog(log),
WithClientHost(host),
WithClientPeer(peerID),
},
expect: func(t *testing.T, c *Client, err error) {
require.NoError(t, err)
Expand All @@ -68,7 +68,7 @@ func TestStoreClient_New(t *testing.T) {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
c, err := New(tc.opts...)
c, err := NewClient(tc.opts...)
tc.expect(t, c, err)
})
}
Expand Down Expand Up @@ -372,10 +372,10 @@ func TestStoreClient_Query_PagingShouldStopOnReturnFalse(t *testing.T) {
func newTestClient(t *testing.T, peerID peer.ID) *Client {
host := test.NewPeer(t)
log := test.NewLog(t)
c, err := New(
WithLog(log),
WithHost(host),
WithPeer(peerID),
c, err := NewClient(
WithClientLog(log),
WithClientHost(host),
WithClientPeer(peerID),
)
require.NoError(t, err)
require.NotNil(t, c)
Expand Down
8 changes: 4 additions & 4 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ func (s *XmtpStore) Resume(ctx context.Context, pubsubTopic string, peers []peer
}

func (s *XmtpStore) queryPeer(ctx context.Context, req *pb.HistoryQuery, peerID peer.ID, msgFn func(*pb.WakuMessage) bool) (int, error) {
c, err := New(
WithLog(s.log),
WithHost(s.h),
WithPeer(peerID),
c, err := NewClient(
WithClientLog(s.log),
WithClientHost(s.h),
WithClientPeer(peerID),
)
if err != nil {
return 0, err
Expand Down

0 comments on commit 9d1706e

Please sign in to comment.