From 91bdd939561caff99e9c40fcf521489b1b2d866c Mon Sep 17 00:00:00 2001 From: Callum Styan Date: Mon, 20 Feb 2023 14:11:12 -0800 Subject: [PATCH] Add new test client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Callum Styan Signed-off-by: Nicolás Pazos --- storage/remote/client.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/storage/remote/client.go b/storage/remote/client.go index fbb6804983..a345f32cf4 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -19,6 +19,7 @@ import ( "context" "fmt" "io" + "math/rand" "net/http" "strconv" "strings" @@ -341,3 +342,26 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query) (*prompb.QueryRe return resp.Results[0], nil } + +type TestClient struct { + name string + url string +} + +func NewTestClient(name, url string) WriteClient { + return &TestClient{name: name, url: url} +} + +func (c *TestClient) Store(_ context.Context, req []byte) error { + r := rand.Intn(200-100) + 100 + time.Sleep(time.Duration(r) * time.Millisecond) + return nil +} + +func (c *TestClient) Name() string { + return c.name +} + +func (c *TestClient) Endpoint() string { + return c.url +}