Skip to content

Commit ee1ee5f

Browse files
authored
feat: Add state.NoOpClient (#1047)
Adds a `state.NoOpClient` that can be used by plugins when `plugin.SyncOptions.BackendOptions` is nil: ``` var stateClient state.Client if options.BackendOptions == nil { c.logger.Info().Msg("No backend options provided, using no state backend") stateClient = state.NoOpClient{} } else { ... ```
1 parent 1241a93 commit ee1ee5f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

state/state.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,20 @@ func NewClient(ctx context.Context, conn *grpc.ClientConn, tableName string) (Cl
2828
}
2929
return nil, fmt.Errorf("please upgrade your state backend plugin. state supporting version 3 plugin has %v", versions.Versions)
3030
}
31+
32+
type NoOpClient struct{}
33+
34+
func (*NoOpClient) SetKey(_ context.Context, _ string, _ string) error {
35+
return nil
36+
}
37+
38+
func (*NoOpClient) GetKey(_ context.Context, _ string) (string, error) {
39+
return "", nil
40+
}
41+
42+
func (*NoOpClient) Flush(_ context.Context) error {
43+
return nil
44+
}
45+
46+
// static check
47+
var _ Client = (*NoOpClient)(nil)

0 commit comments

Comments
 (0)