Skip to content

Commit

Permalink
Updates components-contrib with new io.Closer impl (dapr#8074)
Browse files Browse the repository at this point in the history
* Updates components-contrib with new io.Closer impl

Signed-off-by: joshvanl <[email protected]>

* Update go.mod to point to contrib main HEAD

Signed-off-by: joshvanl <[email protected]>

* Adds `Close() error` to pluggable bindings impl

Adds `Close() error` func to pluggable gRPC binding impl to satisfy the
`io.Closer` interface.

Signed-off-by: joshvanl <[email protected]>

* Adds `Close() error` methods to mock components

Signed-off-by: joshvanl <[email protected]>

---------

Signed-off-by: joshvanl <[email protected]>
  • Loading branch information
JoshVanL authored Sep 17, 2024
1 parent d5fb330 commit 9e10691
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/argoproj/argo-rollouts v1.4.1
github.com/cenkalti/backoff/v4 v4.3.0
github.com/cloudevents/sdk-go/v2 v2.15.2
github.com/dapr/components-contrib v1.14.4
github.com/dapr/components-contrib v1.14.1-0.20240910151552-93f19c96d10c
github.com/dapr/kit v0.13.1-0.20240909215017-3823663aa4bb
github.com/diagridio/go-etcd-cron v0.2.3
github.com/evanphx/json-patch/v5 v5.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ github.com/dancannon/gorethink v4.0.0+incompatible h1:KFV7Gha3AuqT+gr0B/eKvGhbjm
github.com/dancannon/gorethink v4.0.0+incompatible/go.mod h1:BLvkat9KmZc1efyYwhz3WnybhRZtgF1K929FD8z1avU=
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
github.com/dapr/components-contrib v1.14.4 h1:ikBWb3c5OS4ntsYTWkJ2ZnskQ0CKquJ6V3pLusnIrDg=
github.com/dapr/components-contrib v1.14.4/go.mod h1:h2OsxAGYLVR/chY2hThFbulEupHWPvVI3BpMQBXcJtg=
github.com/dapr/components-contrib v1.14.1-0.20240910151552-93f19c96d10c h1:51pkfhDaT+ebIgPCPTVn+0XlRptju6anbRnZJcuvVGU=
github.com/dapr/components-contrib v1.14.1-0.20240910151552-93f19c96d10c/go.mod h1:h2OsxAGYLVR/chY2hThFbulEupHWPvVI3BpMQBXcJtg=
github.com/dapr/kit v0.13.1-0.20240909215017-3823663aa4bb h1:ahLO7pMmX6HAuT6/RxYWBY4AN2fXQJcYlU1msY6Kt7U=
github.com/dapr/kit v0.13.1-0.20240909215017-3823663aa4bb/go.mod h1:Hz1W2LmWfA4UX/12MdA+brsf+np6f/1dJt6C6F63cjI=
github.com/dave/jennifer v1.4.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/grpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,10 @@ func (m *mockConfigStore) Unsubscribe(ctx context.Context, req *configuration.Un
return nil
}

func (m *mockConfigStore) Close() error {
return nil
}

func TestTryLock(t *testing.T) {
l := logger.NewLogger("fakeLogger")
resiliencyConfig := resiliency.FromConfigurations(l, testResiliency)
Expand Down
12 changes: 12 additions & 0 deletions pkg/api/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4729,3 +4729,15 @@ func matchContextInterface(v any) bool {
_, ok := v.(context.Context)
return ok
}

func (c fakeConfigurationStore) Close() error {
return nil
}

func (l fakeLockStore) Close() error {
return nil
}

func (c fakeStateStore) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions pkg/components/bindings/output_pluggable.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (b *grpcOutputBinding) Invoke(ctx context.Context, req *bindings.InvokeRequ
}, nil
}

func (b *grpcOutputBinding) Close() error {
return b.GRPCConnector.Close()
}

// outputFromConnector creates a new GRPC outputbinding using the given underlying connector.
func outputFromConnector(_ logger.Logger, connector *pluggable.GRPCConnector[proto.OutputBindingClient]) *grpcOutputBinding {
return &grpcOutputBinding{
Expand Down
8 changes: 2 additions & 6 deletions pkg/runtime/processor/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package state
import (
"context"
"fmt"
"io"
"strings"
"sync"

Expand Down Expand Up @@ -162,11 +161,8 @@ func (s *state) Close(comp compapi.Component) error {

defer s.compStore.DeleteStateStore(comp.Name)

closer, ok := ss.(io.Closer)
if ok && closer != nil {
if err := closer.Close(); err != nil {
return err
}
if err := ss.Close(); err != nil {
return err
}

return nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/runtime/pubsub/outbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,10 @@ func (o *outboxStateMock) BulkDelete(ctx context.Context, req []state.DeleteRequ
return nil
}

func (o *outboxStateMock) Close() error {
return nil
}

func extractCloudEventProperty(cloudEvent map[string]any, property string) string {
if cloudEvent == nil {
return ""
Expand Down
4 changes: 4 additions & 0 deletions pkg/runtime/wfengine/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,7 @@ func getStatusString(status int32) string {
}
return "UNKNOWN"
}

func (c *workflowEngineComponent) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions pkg/testing/fake_state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ func (f *FakeStateStore) MultiMaxSize() int {
return f.MaxOperations
}

func (f *FakeStateStore) Close() error {
return nil
}

// Adapted from https://github.com/dapr/components-contrib/blob/a4b27ae49b7c99820c6e921d3891f03334692714/state/utils/utils.go#L16
func marshal(val interface{}) ([]byte, error) {
var err error = nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/testing/lock_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ func (mr *MockStoreMockRecorder) Unlock(ctx context.Context, req interface{}) *g
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unlock", reflect.TypeOf((*MockStore)(nil).Unlock), ctx, req)
}

func (m *MockStore) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions pkg/testing/nameresolution_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ func (m *MockResolver) ResolveID(_ context.Context, req nr.ResolveRequest) (stri
args := m.Called(req)
return args.String(0), args.Error(1)
}

func (m *MockResolver) Close() error {
return nil
}
8 changes: 8 additions & 0 deletions pkg/testing/store_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@ func (f *FailingConfigurationStore) Subscribe(ctx context.Context, req *configur
func (f *FailingConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error {
return f.Failure.PerformFailure(req.ID)
}

func (_m *MockConfigurationStore) Close() error {
return nil
}

func (f *FailingConfigurationStore) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions pkg/testing/workflow_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ func (w *MockWorkflow) Purge(ctx context.Context, req *workflowContrib.PurgeRequ
}
return nil
}

func (w *MockWorkflow) Close() error {
return nil
}

0 comments on commit 9e10691

Please sign in to comment.