Skip to content

Commit

Permalink
fix: State add flush and fix migration bug (#1039)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
yevgenypats authored Jul 1, 2023
1 parent d369262 commit 8c10291
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
File renamed without changes.
6 changes: 4 additions & 2 deletions internal/clients/state/v3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package state
import (
"bytes"
"context"
"fmt"
"io"
"sync"

Expand Down Expand Up @@ -71,6 +70,9 @@ func NewClient(ctx context.Context, pbClient pb.PluginClient, tableName string)
}); err != nil {
return nil, err
}
if _, err := writeClient.CloseAndRecv(); err != nil {
return nil, err
}

readClient, err := c.client.Read(ctx, &pb.Read_Request{
Table: tableBytes,
Expand Down Expand Up @@ -158,5 +160,5 @@ func (c *Client) GetKey(_ context.Context, key string) (string, error) {
if val, ok := c.mem[key]; ok {
return val, nil
}
return "", fmt.Errorf("key not found")
return "", nil
}
1 change: 1 addition & 0 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
type Client interface {
SetKey(ctx context.Context, key string, value string) error
GetKey(ctx context.Context, key string) (string, error)
Flush(ctx context.Context) error
}

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

0 comments on commit 8c10291

Please sign in to comment.