Skip to content

fix: State add flush and fix migration bug #1039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to return "" if not found but we can later on make this an option which the user can decide if they want to use "" or NotFoundErr

}
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's flush for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not flushing the content every Set otherwise data is not written back. It is already implemented on the state implementation but just wasn't exposed

}

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