From 4d4425f378e68e5ed97c18479df2a397830572d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 1 Sep 2018 14:07:40 +0200 Subject: [PATCH] Optimize offline SearchValue slightly --- offline/offline.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/offline/offline.go b/offline/offline.go index 252ea8f..4f522e4 100644 --- a/offline/offline.go +++ b/offline/offline.go @@ -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