Skip to content

Commit 8c10291

Browse files
authored
fix: State add flush and fix migration bug (#1039)
This fixes a bug in state backend where table weren't created. I also tested it with cloudquery/cloudquery#11855 which seems to work with minor modifications (will open a PR shortly to the CLI PR)
1 parent d369262 commit 8c10291

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed
File renamed without changes.

internal/clients/state/v3/state.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package state
33
import (
44
"bytes"
55
"context"
6-
"fmt"
76
"io"
87
"sync"
98

@@ -71,6 +70,9 @@ func NewClient(ctx context.Context, pbClient pb.PluginClient, tableName string)
7170
}); err != nil {
7271
return nil, err
7372
}
73+
if _, err := writeClient.CloseAndRecv(); err != nil {
74+
return nil, err
75+
}
7476

7577
readClient, err := c.client.Read(ctx, &pb.Read_Request{
7678
Table: tableBytes,
@@ -158,5 +160,5 @@ func (c *Client) GetKey(_ context.Context, key string) (string, error) {
158160
if val, ok := c.mem[key]; ok {
159161
return val, nil
160162
}
161-
return "", fmt.Errorf("key not found")
163+
return "", nil
162164
}

state/state.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
type Client interface {
1515
SetKey(ctx context.Context, key string, value string) error
1616
GetKey(ctx context.Context, key string) (string, error)
17+
Flush(ctx context.Context) error
1718
}
1819

1920
func NewClient(ctx context.Context, conn *grpc.ClientConn, tableName string) (Client, error) {

0 commit comments

Comments
 (0)