Skip to content
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
13 changes: 13 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/types/known/emptypb"

pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
)
Expand Down Expand Up @@ -90,6 +91,9 @@ type Client interface {
// DeleteBulkState deletes content for multiple keys from store.
DeleteBulkStateItems(ctx context.Context, storeName string, items []*DeleteStateItem) error

// Shutdown the sidecar.
Shutdown(ctx context.Context) error

// WithTraceID adds existing trace ID to the outgoing context.
WithTraceID(ctx context.Context, id string) context.Context

Expand Down Expand Up @@ -194,3 +198,12 @@ func (c *GRPCClient) withAuthToken(ctx context.Context) context.Context {
}
return metadata.NewOutgoingContext(ctx, metadata.Pairs(apiTokenKey, string(c.authToken)))
}

// Shutdown the sidecar.
func (c *GRPCClient) Shutdown(ctx context.Context) error {
_, err := c.protoClient.Shutdown(c.withAuthToken(ctx), &emptypb.Empty{})
if err != nil {
return errors.Wrap(err, "error shutting down the sidecar")
}
return nil
}
14 changes: 14 additions & 0 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ func TestNewClient(t *testing.T) {
})
}

func TestShutdown(t *testing.T) {
ctx := context.Background()

t.Run("shutdown", func(t *testing.T) {
err := testClient.Shutdown(ctx)
assert.NoError(t, err)
})
}


func getTestClient(ctx context.Context) (client Client, closer func()) {
s := grpc.NewServer()
pb.RegisterDaprServer(s, &testDaprServer{
Expand Down Expand Up @@ -220,3 +230,7 @@ func (s *testDaprServer) RegisterActorTimer(context.Context, *pb.RegisterActorTi
func (s *testDaprServer) UnregisterActorTimer(context.Context, *pb.UnregisterActorTimerRequest) (*empty.Empty, error) {
return nil, errors.New("actors not implemented in go SDK")
}

func (s *testDaprServer) Shutdown(ctx context.Context, req *empty.Empty) (*empty.Empty, error) {
return &empty.Empty{}, nil
}
68 changes: 37 additions & 31 deletions dapr/proto/runtime/v1/dapr.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions dapr/proto/runtime/v1/dapr_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.