Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Optimize offline SearchValue slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Sep 1, 2018
1 parent 928b4de commit 4d4425f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions offline/offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ func (c *offlineRouting) GetValue(ctx context.Context, key string, _ ...ropts.Op
}

func (c *offlineRouting) SearchValue(ctx context.Context, key string, _ ...ropts.Option) (<-chan []byte, error) {
out := make(chan []byte)
out := make(chan []byte, 1)
go func() {
defer close(out)
v, _ := c.GetValue(ctx, key)
select {
case out <- v:
case <-ctx.Done():
v, err := c.GetValue(ctx, key)
if err == nil {
out <- v
}
}()
return out, nil
Expand Down

0 comments on commit 4d4425f

Please sign in to comment.