From 14322daf83ff30d5a97c7608315d41a9b37f693d Mon Sep 17 00:00:00 2001 From: Peter Marton Date: Fri, 18 Oct 2024 09:00:09 -0700 Subject: [PATCH] fix(storage): async insert (#1704) --- openmeter/sink/storage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openmeter/sink/storage.go b/openmeter/sink/storage.go index 01766f032..28dbd056e 100644 --- a/openmeter/sink/storage.go +++ b/openmeter/sink/storage.go @@ -50,10 +50,11 @@ func (c *ClickHouseStorage) BatchInsert(ctx context.Context, messages []sinkmode // With the `wait_for_async_insert` setting, you can configure // if you want an insert statement to return with an acknowledgment // either immediately after the data got inserted into the buffer. - ctx = clickhouse.Context(ctx, clickhouse.WithStdAsync(c.config.AsyncInsertWait)) + err = c.config.ClickHouse.AsyncInsert(ctx, sql, c.config.AsyncInsertWait, args...) + } else { + err = c.config.ClickHouse.Exec(ctx, sql, args...) } - err = c.config.ClickHouse.Exec(ctx, sql, args...) if err != nil { return fmt.Errorf("failed to batch insert events: %w", err) }