Skip to content

Commit 6615951

Browse files
committed
fix review comments
Signed-off-by: jyjiangkai <[email protected]>
1 parent 23dcb26 commit 6615951

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Diff for: client/client.go

-3
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,8 @@ func (c *client) Eventbus(ctx context.Context, opts ...api.EventbusOption) (api.
8989
}
9090

9191
func (c *client) Disconnect(ctx context.Context) {
92-
c.mu.Lock()
93-
defer c.mu.Unlock()
9492
c.cache.Range(func(key, value interface{}) bool {
9593
value.(api.Eventbus).Close(ctx)
96-
c.cache.Delete(key)
9794
return true
9895
})
9996
}

Diff for: client/examples/eventbus/append/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func main() {
4141
if err != nil {
4242
panic("invalid id")
4343
}
44-
bus, err := c.Eventbus(ctx, api.WithName("quick-start"), api.WithID(eventbusID.Uint64()))
44+
bus, err := c.Eventbus(ctx, api.WithID(eventbusID.Uint64()))
4545
if err != nil {
4646
panic(err.Error())
4747
}

Diff for: client/pkg/eventbus/eventbus.go

+6
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ func (w *busWriter) pickWritableLog(ctx context.Context, opts *api.WriteOptions)
512512
if err != nil {
513513
return nil, err
514514
}
515+
if lw == nil {
516+
return nil, errors.ErrResourceCanNotOp.WithMessage("can not pick writable log")
517+
}
515518

516519
return lw.Writer(), nil
517520
}
@@ -588,6 +591,9 @@ func (r *busReader) pickReadableLog(ctx context.Context, opts *api.ReadOptions)
588591
if err != nil {
589592
return nil, err
590593
}
594+
if lr == nil {
595+
return nil, errors.ErrResourceCanNotOp.WithMessage("can not pick readable log")
596+
}
591597

592598
return lr.Reader(eventlog.ReaderConfig{PollingTimeout: opts.PollingTimeout}), nil
593599
}

0 commit comments

Comments
 (0)