mirror of https://github.com/dapr/go-sdk.git
Compare commits
4 Commits
v1.12.0-rc
...
main
Author | SHA1 | Date |
---|---|---|
|
16374cdb7b | |
|
a3df75f17b | |
|
81312e9da9 | |
|
c81a381811 |
|
@ -38,8 +38,9 @@ jobs:
|
|||
run: |
|
||||
echo "RELEASE_VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV
|
||||
|
||||
- name: Release
|
||||
- name: Release Main
|
||||
uses: actions/create-release@v1
|
||||
if: ${{ !contains(github.ref , 'rc') }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
@ -49,6 +50,18 @@ jobs:
|
|||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Release RC
|
||||
uses: actions/create-release@v1
|
||||
if: ${{ contains(github.ref, 'rc') }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
body: Automatic Go Dapr client release
|
||||
draft: false
|
||||
prerelease: true
|
||||
|
||||
- name: Notify
|
||||
uses: rjstone/discord-webhook-notify@v1
|
||||
with:
|
||||
|
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GOLANGCILINT_VER: v1.61.0
|
||||
GOLANGCILINT_VER: v1.64.6
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GOLANGCILINT_VER: v1.61.0
|
||||
GOLANGCILINT_VER: v1.64.6
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
- "macos-latest"
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
GOLANGCILINT_VER: v1.61.0 # Make sure to bump /tools/check-lint-version/main_test.go
|
||||
GOLANGCILINT_VER: v1.64.6 # Make sure to bump /tools/check-lint-version/main_test.go
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
DAPR_INSTALL_URL: ${{ env.DAPR_INSTALL_URL }}
|
||||
DAPR_CLI_VER: ${{ steps.outputs.outputs.DAPR_CLI_VER }}
|
||||
DAPR_CLI_REF: ${{ steps.outputs.outputs.DAPR_CLI_REF }}
|
||||
DAPR_RUNTIME_VER: 1.15.0-rc.2
|
||||
DAPR_RUNTIME_VER: ${{ steps.outputs.outputs.DAPR_RUNTIME_VER }}
|
||||
CHECKOUT_REPO: ${{ steps.outputs.outputs.CHECKOUT_REPO }}
|
||||
CHECKOUT_REF: ${{ steps.outputs.outputs.CHECKOUT_REF }}
|
||||
DAPR_REF: ${{ steps.outputs.outputs.DAPR_REF }}
|
||||
|
|
|
@ -234,7 +234,6 @@ linters:
|
|||
- lll
|
||||
- unparam
|
||||
- wsl
|
||||
- gomnd
|
||||
- testpackage
|
||||
- nestif
|
||||
- nlreturn
|
||||
|
@ -271,8 +270,6 @@ linters:
|
|||
- tagalign
|
||||
- mnd
|
||||
- canonicalheader
|
||||
- exportloopref
|
||||
- execinquery
|
||||
- err113
|
||||
- fatcontext
|
||||
- forbidigo # TODO: Re-enable and remove fmt.println
|
4
Makefile
4
Makefile
|
@ -33,6 +33,10 @@ cover: ## Displays test coverage in the client and service packages
|
|||
lint: check-lint ## Lints the entire project
|
||||
golangci-lint run --timeout=3m
|
||||
|
||||
.PHONY: lint-fix
|
||||
lint-fix: check-lint ## Lints the entire project
|
||||
golangci-lint run --timeout=3m --fix
|
||||
|
||||
.PHONY: check-lint
|
||||
check-lint: ## Compares the locally installed linter with the workflow version
|
||||
cd ./tools/check-lint-version && \
|
||||
|
|
|
@ -48,6 +48,7 @@ func TestRegisterActorFactoryAndInvokeMethod(t *testing.T) {
|
|||
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
|
||||
rt.RegisterActorFactory(actorMock.ActorImplFactory)
|
||||
|
||||
//nolint:usetesting
|
||||
mockServer.EXPECT().InvokeMethod(context.Background(), "mockActorID", "Invoke", []byte("param")).Return([]byte("response"), actorErr.Success)
|
||||
rspData, err := rt.InvokeActorMethod("testActorType", "mockActorID", "Invoke", []byte("param"))
|
||||
|
||||
|
@ -89,6 +90,7 @@ func TestInvokeReminder(t *testing.T) {
|
|||
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
|
||||
rt.RegisterActorFactory(actorMock.ActorImplFactory)
|
||||
|
||||
//nolint:usetesting
|
||||
mockServer.EXPECT().InvokeReminder(context.Background(), "mockActorID", "mockReminder", []byte("param")).Return(actorErr.Success)
|
||||
err = rt.InvokeReminder("testActorType", "mockActorID", "mockReminder", []byte("param"))
|
||||
|
||||
|
@ -109,6 +111,7 @@ func TestInvokeTimer(t *testing.T) {
|
|||
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
|
||||
rt.RegisterActorFactory(actorMock.ActorImplFactory)
|
||||
|
||||
//nolint:usetesting
|
||||
mockServer.EXPECT().InvokeTimer(context.Background(), "mockActorID", "mockTimer", []byte("param")).Return(actorErr.Success)
|
||||
err = rt.InvokeTimer("testActorType", "mockActorID", "mockTimer", []byte("param"))
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -25,7 +24,7 @@ import (
|
|||
const testActorType = "test"
|
||||
|
||||
func TestInvokeActor(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
in := &InvokeActorRequest{
|
||||
ActorID: "fn",
|
||||
Method: "mockMethod",
|
||||
|
@ -74,7 +73,7 @@ func TestInvokeActor(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRegisterActorReminder(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
in := &RegisterActorReminderRequest{
|
||||
ActorID: "fn",
|
||||
Data: []byte(`{hello}`),
|
||||
|
@ -137,7 +136,7 @@ func TestRegisterActorReminder(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRegisterActorTimer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
in := &RegisterActorTimerRequest{
|
||||
ActorID: "fn",
|
||||
Data: []byte(`{hello}`),
|
||||
|
@ -215,7 +214,7 @@ func TestRegisterActorTimer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnregisterActorReminder(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
in := &UnregisterActorReminderRequest{
|
||||
ActorID: "fn",
|
||||
ActorType: testActorType,
|
||||
|
@ -260,7 +259,7 @@ func TestUnregisterActorReminder(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnregisterActorTimer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
in := &UnregisterActorTimerRequest{
|
||||
ActorID: "fn",
|
||||
ActorType: testActorType,
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -25,7 +24,7 @@ import (
|
|||
// go test -timeout 30s ./client -count 1 -run ^TestInvokeBinding$
|
||||
|
||||
func TestInvokeBinding(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
in := &InvokeBindingRequest{
|
||||
Name: "test",
|
||||
Operation: "fn",
|
||||
|
|
|
@ -98,7 +98,7 @@ func TestNewClient(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("new client with trace ID", func(t *testing.T) {
|
||||
_ = testClient.WithTraceID(context.Background(), "test")
|
||||
_ = testClient.WithTraceID(t.Context(), "test")
|
||||
})
|
||||
|
||||
t.Run("new socket client closed with token", func(t *testing.T) {
|
||||
|
@ -120,13 +120,13 @@ func TestNewClient(t *testing.T) {
|
|||
c, err := NewClientWithSocket(testSocket)
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
ctx := c.WithTraceID(context.Background(), "")
|
||||
ctx := c.WithTraceID(t.Context(), "")
|
||||
_ = c.WithTraceID(ctx, "test")
|
||||
})
|
||||
}
|
||||
|
||||
func TestShutdown(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("shutdown", func(t *testing.T) {
|
||||
err := testClient.Shutdown(ctx)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -16,7 +15,7 @@ const (
|
|||
)
|
||||
|
||||
func TestGetConfigurationItem(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("get configuration item", func(t *testing.T) {
|
||||
resp, err := testClient.GetConfigurationItem(ctx, "example-config", "mykey")
|
||||
|
@ -31,7 +30,7 @@ func TestGetConfigurationItem(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetConfigurationItems(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
keys := []string{"mykey1", "mykey2", "mykey3"}
|
||||
t.Run("Test get configuration items", func(t *testing.T) {
|
||||
|
@ -44,7 +43,7 @@ func TestGetConfigurationItems(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSubscribeConfigurationItems(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
var counter, totalCounter uint32
|
||||
counter = 0
|
||||
|
@ -67,7 +66,7 @@ func TestSubscribeConfigurationItems(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnSubscribeConfigurationItems(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
var counter, totalCounter uint32
|
||||
t.Run("Test unsubscribe configuration items", func(t *testing.T) {
|
||||
|
|
|
@ -44,8 +44,8 @@ type conversationRequestOption func(request *conversationRequest)
|
|||
|
||||
// ConversationInput defines a single input.
|
||||
type ConversationInput struct {
|
||||
// The string to send to the llm.
|
||||
Message string
|
||||
// The content to send to the llm.
|
||||
Content string
|
||||
// The role of the message.
|
||||
Role *string
|
||||
// Whether to Scrub PII from the input
|
||||
|
@ -104,7 +104,7 @@ func (c *GRPCClient) ConverseAlpha1(ctx context.Context, req conversationRequest
|
|||
cinputs := make([]*runtimev1pb.ConversationInput, len(req.inputs))
|
||||
for i, in := range req.inputs {
|
||||
cinputs[i] = &runtimev1pb.ConversationInput{
|
||||
Message: in.Message,
|
||||
Content: in.Content,
|
||||
Role: in.Role,
|
||||
ScrubPII: in.ScrubPII,
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
)
|
||||
|
||||
func TestEncrypt(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("missing ComponentName", func(t *testing.T) {
|
||||
out, err := testClient.Encrypt(ctx,
|
||||
|
@ -138,7 +138,7 @@ func TestEncrypt(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecrypt(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("missing ComponentName", func(t *testing.T) {
|
||||
out, err := testClient.Decrypt(ctx,
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -39,7 +38,7 @@ type _testStructwithSlices struct {
|
|||
}
|
||||
|
||||
func TestInvokeMethodWithContent(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
data := "ping"
|
||||
|
||||
t.Run("with content", func(t *testing.T) {
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -29,7 +28,7 @@ const (
|
|||
)
|
||||
|
||||
func TestLock(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("try lock invalid store name", func(t *testing.T) {
|
||||
r, err := testClient.TryLockAlpha1(ctx, "", &LockRequest{})
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -11,7 +10,7 @@ import (
|
|||
|
||||
// Test GetMetadata returns
|
||||
func TestGetMetadata(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
t.Run("get meta", func(t *testing.T) {
|
||||
metadata, err := testClient.GetMetadata(ctx)
|
||||
require.NoError(t, err)
|
||||
|
@ -20,7 +19,7 @@ func TestGetMetadata(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetMetadata(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
t.Run("set meta", func(t *testing.T) {
|
||||
err := testClient.SetMetadata(ctx, "test_key", "test_value")
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -39,7 +38,7 @@ type _testCustomContentwithSlices struct {
|
|||
|
||||
// go test -timeout 30s ./client -count 1 -run ^TestPublishEvent$
|
||||
func TestPublishEvent(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("with data", func(t *testing.T) {
|
||||
err := testClient.PublishEvent(ctx, "messages", "test", []byte("ping"))
|
||||
|
@ -96,7 +95,7 @@ func TestPublishEvent(t *testing.T) {
|
|||
|
||||
// go test -timeout 30s ./client -count 1 -run ^TestPublishEvents$
|
||||
func TestPublishEvents(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("without pubsub name", func(t *testing.T) {
|
||||
res := testClient.PublishEvents(ctx, "", "test", []interface{}{"ping", "pong"})
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -23,7 +22,7 @@ import (
|
|||
)
|
||||
|
||||
func TestSchedulingAlpha1(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("schedule job - valid", func(t *testing.T) {
|
||||
err := testClient.ScheduleJobAlpha1(ctx, &Job{
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -24,7 +23,7 @@ import (
|
|||
|
||||
// go test -timeout 30s ./client -count 1 -run ^TestGetSecret$
|
||||
func TestGetSecret(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("without store", func(t *testing.T) {
|
||||
out, err := testClient.GetSecret(ctx, "", "key1", nil)
|
||||
|
@ -53,7 +52,7 @@ func TestGetSecret(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetBulkSecret(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
t.Run("without store", func(t *testing.T) {
|
||||
out, err := testClient.GetBulkSecret(ctx, "", nil)
|
||||
|
|
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -77,7 +76,7 @@ func TestStateOptionsConverter(t *testing.T) {
|
|||
|
||||
// go test -timeout 30s ./client -count 1 -run ^TestSaveState$
|
||||
func TestSaveState(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
data := testData
|
||||
store := testStore
|
||||
key := "key1"
|
||||
|
@ -118,7 +117,7 @@ func TestSaveState(t *testing.T) {
|
|||
|
||||
// go test -timeout 30s ./client -count 1 -run ^TestDeleteState$
|
||||
func TestDeleteState(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
data := testData
|
||||
store := testStore
|
||||
key := "key1"
|
||||
|
@ -189,7 +188,7 @@ func TestDeleteState(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteBulkState(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
data := testData
|
||||
store := testStore
|
||||
keys := []string{"key1", "key2", "key3"}
|
||||
|
@ -337,7 +336,7 @@ func TestDeleteBulkState(t *testing.T) {
|
|||
|
||||
// go test -timeout 30s ./client -count 1 -run ^TestStateTransactions$
|
||||
func TestStateTransactions(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
data := `{ "message": "test" }`
|
||||
store := testStore
|
||||
meta := map[string]string{}
|
||||
|
@ -410,7 +409,7 @@ func TestStateTransactions(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestQueryState(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
data := testData
|
||||
store := testStore
|
||||
key1 := "key1"
|
||||
|
|
|
@ -23,6 +23,9 @@ import (
|
|||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
|
||||
"github.com/dapr/go-sdk/service/common"
|
||||
)
|
||||
|
@ -37,10 +40,15 @@ type SubscriptionOptions struct {
|
|||
}
|
||||
|
||||
type Subscription struct {
|
||||
ctx context.Context
|
||||
stream pb.Dapr_SubscribeTopicEventsAlpha1Client
|
||||
|
||||
// lock locks concurrent writes to subscription stream.
|
||||
lock sync.Mutex
|
||||
closed atomic.Bool
|
||||
|
||||
createStream func(ctx context.Context, opts SubscriptionOptions) (pb.Dapr_SubscribeTopicEventsAlpha1Client, error)
|
||||
opts SubscriptionOptions
|
||||
}
|
||||
|
||||
type SubscriptionMessage struct {
|
||||
|
@ -55,7 +63,10 @@ func (c *GRPCClient) Subscribe(ctx context.Context, opts SubscriptionOptions) (*
|
|||
}
|
||||
|
||||
s := &Subscription{
|
||||
stream: stream,
|
||||
ctx: ctx,
|
||||
stream: stream,
|
||||
createStream: c.subscribeInitialRequest,
|
||||
opts: opts,
|
||||
}
|
||||
|
||||
return s, nil
|
||||
|
@ -101,52 +112,96 @@ func (s *Subscription) Close() error {
|
|||
}
|
||||
|
||||
func (s *Subscription) Receive() (*SubscriptionMessage, error) {
|
||||
resp, err := s.stream.Recv()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
event := resp.GetEventMessage()
|
||||
|
||||
data := any(event.GetData())
|
||||
if len(event.GetData()) > 0 {
|
||||
mediaType, _, err := mime.ParseMediaType(event.GetDataContentType())
|
||||
if err == nil {
|
||||
var v interface{}
|
||||
switch mediaType {
|
||||
case "application/json":
|
||||
if err := json.Unmarshal(event.GetData(), &v); err == nil {
|
||||
data = v
|
||||
}
|
||||
case "text/plain":
|
||||
// Assume UTF-8 encoded string.
|
||||
data = string(event.GetData())
|
||||
for {
|
||||
resp, err := s.stream.Recv()
|
||||
if err != nil {
|
||||
select {
|
||||
case <-s.ctx.Done():
|
||||
return nil, errors.New("subscription context closed")
|
||||
default:
|
||||
if strings.HasPrefix(mediaType, "application/") &&
|
||||
strings.HasSuffix(mediaType, "+json") {
|
||||
// proceed to check the gRPC status error
|
||||
}
|
||||
|
||||
st, ok := status.FromError(err)
|
||||
if !ok {
|
||||
// not a grpc status error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch st.Code() {
|
||||
case codes.Unavailable, codes.Unknown:
|
||||
logger.Printf("gRPC error while reading from stream: %s (code=%v)",
|
||||
st.Message(), st.Code())
|
||||
// close the current stream and reconnect
|
||||
if s.closed.Load() {
|
||||
return nil, errors.New("subscription is permanently closed; cannot reconnect")
|
||||
}
|
||||
if err := s.closeStreamOnly(); err != nil {
|
||||
logger.Printf("error closing current stream: %v", err)
|
||||
}
|
||||
|
||||
newStream, nerr := s.createStream(s.ctx, s.opts)
|
||||
if nerr != nil {
|
||||
return nil, errors.New("re-subscribe failed")
|
||||
}
|
||||
|
||||
s.lock.Lock()
|
||||
s.stream = newStream
|
||||
s.lock.Unlock()
|
||||
|
||||
// try receiving again
|
||||
continue
|
||||
|
||||
case codes.Canceled:
|
||||
return nil, errors.New("stream canceled")
|
||||
|
||||
default:
|
||||
return nil, errors.New("subscription recv error")
|
||||
}
|
||||
}
|
||||
|
||||
event := resp.GetEventMessage()
|
||||
data := any(event.GetData())
|
||||
if len(event.GetData()) > 0 {
|
||||
mediaType, _, err := mime.ParseMediaType(event.GetDataContentType())
|
||||
if err == nil {
|
||||
var v interface{}
|
||||
switch mediaType {
|
||||
case "application/json":
|
||||
if err := json.Unmarshal(event.GetData(), &v); err == nil {
|
||||
data = v
|
||||
}
|
||||
case "text/plain":
|
||||
// Assume UTF-8 encoded string.
|
||||
data = string(event.GetData())
|
||||
default:
|
||||
if strings.HasPrefix(mediaType, "application/") &&
|
||||
strings.HasSuffix(mediaType, "+json") {
|
||||
if err := json.Unmarshal(event.GetData(), &v); err == nil {
|
||||
data = v
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
topicEvent := &common.TopicEvent{
|
||||
ID: event.GetId(),
|
||||
Source: event.GetSource(),
|
||||
Type: event.GetType(),
|
||||
SpecVersion: event.GetSpecVersion(),
|
||||
DataContentType: event.GetDataContentType(),
|
||||
Data: data,
|
||||
RawData: event.GetData(),
|
||||
Topic: event.GetTopic(),
|
||||
PubsubName: event.GetPubsubName(),
|
||||
}
|
||||
topicEvent := &common.TopicEvent{
|
||||
ID: event.GetId(),
|
||||
Source: event.GetSource(),
|
||||
Type: event.GetType(),
|
||||
SpecVersion: event.GetSpecVersion(),
|
||||
DataContentType: event.GetDataContentType(),
|
||||
Data: data,
|
||||
RawData: event.GetData(),
|
||||
Topic: event.GetTopic(),
|
||||
PubsubName: event.GetPubsubName(),
|
||||
}
|
||||
|
||||
return &SubscriptionMessage{
|
||||
sub: s,
|
||||
TopicEvent: topicEvent,
|
||||
}, nil
|
||||
return &SubscriptionMessage{
|
||||
sub: s,
|
||||
TopicEvent: topicEvent,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SubscriptionMessage) Success() error {
|
||||
|
@ -232,3 +287,13 @@ func (c *GRPCClient) subscribeInitialRequest(ctx context.Context, opts Subscript
|
|||
|
||||
return stream, nil
|
||||
}
|
||||
|
||||
func (s *Subscription) closeStreamOnly() error {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
if s.stream != nil {
|
||||
return s.stream.CloseSend()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -116,14 +116,14 @@ func createNonBlockingClient(ctx context.Context, serverAddr string) (client Cli
|
|||
}
|
||||
|
||||
func TestGrpcWaitHappyCase(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
err := testClient.Wait(ctx, waitTimeout)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestGrpcWaitUnresponsiveTcpServer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
server, err := createUnresponsiveTCPServer()
|
||||
require.NoError(t, err)
|
||||
|
@ -141,7 +141,7 @@ func TestGrpcWaitUnresponsiveTcpServer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGrpcWaitUnresponsiveUnixServer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
server, err := createUnresponsiveUnixServer()
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -15,7 +15,6 @@ limitations under the License.
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
|
@ -35,7 +34,7 @@ func TestMarshalInput(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWorkflowBeta1(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// 1: StartWorkflow
|
||||
t.Run("start workflow - valid (without id)", func(t *testing.T) {
|
||||
|
|
|
@ -88,6 +88,91 @@ resp, err = client.InvokeMethodWithContent(ctx, "app-id", "method-name", "post",
|
|||
|
||||
For a full guide on service invocation, visit [How-To: Invoke a service]({{< ref howto-invoke-discover-services.md >}}).
|
||||
|
||||
### Workflows
|
||||
|
||||
Workflows and their activities can be authored and managed using the Dapr Go SDK like so:
|
||||
|
||||
```go
|
||||
import (
|
||||
...
|
||||
"github.com/dapr/go-sdk/workflow"
|
||||
...
|
||||
)
|
||||
|
||||
func ExampleWorkflow(ctx *workflow.WorkflowContext) (any, error) {
|
||||
var output string
|
||||
input := "world"
|
||||
|
||||
if err := ctx.CallActivity(ExampleActivity, workflow.ActivityInput(input)).Await(&output); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Print output - "hello world"
|
||||
fmt.Println(output)
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func ExampleActivity(ctx workflow.ActivityContext) (any, error) {
|
||||
var input int
|
||||
if err := ctx.GetInput(&input); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("hello %s", input), nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Create a workflow worker
|
||||
w, err := workflow.NewWorker()
|
||||
if err != nil {
|
||||
log.Fatalf("error creating worker: %v", err)
|
||||
}
|
||||
|
||||
// Register the workflow
|
||||
w.RegisterWorkflow(ExampleWorkflow)
|
||||
|
||||
// Register the activity
|
||||
w.RegisterActivity(ExampleActivity)
|
||||
|
||||
// Start workflow runner
|
||||
if err := w.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Create a workflow client
|
||||
wfClient, err := workflow.NewClient()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Start a new workflow
|
||||
id, err := wfClient.ScheduleNewWorkflow(context.Background(), "ExampleWorkflow")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for the workflow to complete
|
||||
metadata, err := wfClient.WaitForWorkflowCompletion(ctx, id)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Print workflow status post-completion
|
||||
fmt.Println(metadata.RuntimeStatus)
|
||||
|
||||
// Shutdown Worker
|
||||
w.Shutdown()
|
||||
}
|
||||
```
|
||||
|
||||
- For a more comprehensive guide on workflows visit these How-To guides:
|
||||
- [How-To: Author a workflow]({{< ref howto-author-workflow.md >}}).
|
||||
- [How-To: Manage a workflow]({{< ref howto-manage-workflow.md >}}).
|
||||
- Visit the Go SDK Examples to jump into complete examples:
|
||||
- [Workflow Example](https://github.com/dapr/go-sdk/tree/main/examples/workflow)
|
||||
- [Workflow - Parallelised](https://github.com/dapr/go-sdk/tree/main/examples/workflow-parallel)
|
||||
|
||||
### State Management
|
||||
|
||||
For simple use-cases, Dapr client provides easy to use `Save`, `Get`, `Delete` methods:
|
||||
|
|
|
@ -17,8 +17,9 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
dapr "github.com/dapr/go-sdk/client"
|
||||
"log"
|
||||
|
||||
dapr "github.com/dapr/go-sdk/client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -28,12 +29,12 @@ func main() {
|
|||
}
|
||||
|
||||
input := dapr.ConversationInput{
|
||||
Message: "hello world",
|
||||
Content: "hello world",
|
||||
// Role: nil, // Optional
|
||||
// ScrubPII: nil, // Optional
|
||||
}
|
||||
|
||||
fmt.Printf("conversation input: %s\n", input.Message)
|
||||
fmt.Printf("conversation input: %s\n", input.Content)
|
||||
|
||||
var conversationComponent = "echo"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module github.com/dapr/go-sdk/examples
|
||||
|
||||
go 1.23.3
|
||||
go 1.24.2
|
||||
|
||||
replace github.com/dapr/go-sdk => ../
|
||||
|
||||
|
@ -9,31 +9,32 @@ require (
|
|||
github.com/dapr/go-sdk v0.0.0-00010101000000-000000000000
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/google/uuid v1.6.0
|
||||
google.golang.org/grpc v1.68.1
|
||||
google.golang.org/grpc v1.72.0
|
||||
google.golang.org/grpc/examples v0.0.0-20240516203910-e22436abb809
|
||||
google.golang.org/protobuf v1.35.2
|
||||
google.golang.org/protobuf v1.36.6
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dapr/dapr v1.15.0-rc.1 // indirect
|
||||
github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530 // indirect
|
||||
github.com/dapr/dapr v1.15.5 // indirect
|
||||
github.com/dapr/durabletask-go v0.6.5 // indirect
|
||||
github.com/dapr/kit v0.15.2 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/go-chi/chi/v5 v5.1.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/marusama/semaphore/v2 v2.5.0 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
|
||||
go.opentelemetry.io/otel v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.32.0 // indirect
|
||||
golang.org/x/net v0.32.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.35.0 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e // indirect
|
||||
)
|
||||
|
|
|
@ -6,19 +6,20 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
|
|||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/dapr/dapr v1.15.0-rc.1 h1:7JP3zSannxQwV27A9pPR2b/DSNmgcSjJOhRDwM4eFpQ=
|
||||
github.com/dapr/dapr v1.15.0-rc.1/go.mod h1:SycZrBWgfmog+C5T4p0X6VIpnREQ3xajrYxdih+gn9w=
|
||||
github.com/dapr/durabletask-go v0.5.1-0.20241127212625-4232880fd198 h1:vTq9HmTXow4iVb/1dO4qVZhK7XC5KlwbLl2iNIE23Qc=
|
||||
github.com/dapr/durabletask-go v0.5.1-0.20241127212625-4232880fd198/go.mod h1:C4ykYCSNv1k2C4wvZv11h2ClkE/qsXw0tv6idOWVmDc=
|
||||
github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530/go.mod h1:C4ykYCSNv1k2C4wvZv11h2ClkE/qsXw0tv6idOWVmDc=
|
||||
github.com/dapr/dapr v1.15.5 h1:bkCmcQQfaQ5C49P3l0elCzDr4/Oja5kitM3jStY+2RY=
|
||||
github.com/dapr/dapr v1.15.5/go.mod h1:wwopO8AD9CZOgVj4bsdXNmeQujMo0v3MLAqeaX+gb00=
|
||||
github.com/dapr/durabletask-go v0.6.5 h1:aWcxMfYudojpgRjJRdUr7yyZ7rGcvLtWXUuA4cGHBR0=
|
||||
github.com/dapr/durabletask-go v0.6.5/go.mod h1:nTZ5fCbJLnZbVdi6Z2YxdDF1OgQZL3LroogGuetrwuA=
|
||||
github.com/dapr/kit v0.15.2 h1:5H9IhKScU/SpE2Hxvr5vUlmYN1e2MJN15RoT8/KSziU=
|
||||
github.com/dapr/kit v0.15.2/go.mod h1:HwFsBKEbcyLanWlDZE7u/jnaDCD/tU+n3pkFNUctQNw=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
|
||||
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
|
@ -32,65 +33,63 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
|||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/marusama/semaphore/v2 v2.5.0 h1:o/1QJD9DBYOWRnDhPwDVAXQn6mQYD0gZaS1Tpx6DJGM=
|
||||
github.com/marusama/semaphore/v2 v2.5.0/go.mod h1:z9nMiNUekt/LTpTUQdpp+4sJeYqUGpwMHfW0Z8V8fnQ=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
|
||||
go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts=
|
||||
go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc=
|
||||
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
|
||||
go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w=
|
||||
go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ=
|
||||
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
|
||||
go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc=
|
||||
go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o=
|
||||
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 h1:N9BgCIAUvn/M+p4NJccWPWb3BWh88+zyL0ll9HgbEeM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
|
||||
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
|
||||
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
||||
google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 h1:IqsN8hx+lWLqlN+Sc3DoMy/watjofWiU8sRFgQ8fhKM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
|
||||
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
|
||||
google.golang.org/grpc/examples v0.0.0-20240516203910-e22436abb809 h1:f96Rv5C5Y2CWlbKK6KhKDdyFgGOjPHPEMsdyaxE9k0c=
|
||||
google.golang.org/grpc/examples v0.0.0-20240516203910-e22436abb809/go.mod h1:uaPEAc5V00jjG3DPhGFLXGT290RUV3+aNQigs1W50/8=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
@ -99,5 +98,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
|
|||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e h1:KqK5c/ghOm8xkHYhlodbp6i6+r+ChV2vuAuVRdFbLro=
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
|
|
|
@ -16,7 +16,7 @@ output_match_mode: substring
|
|||
expected_stdout_lines:
|
||||
- "ContentType:text/plain, Verb:POST, QueryString:, hellow"
|
||||
background: true
|
||||
sleep: 15
|
||||
sleep: 30
|
||||
timeout_seconds: 60
|
||||
-->
|
||||
|
||||
|
@ -91,7 +91,7 @@ expected_stdout_lines:
|
|||
```bash
|
||||
dapr run --app-id custom-grpc-client \
|
||||
-d ./config \
|
||||
--dapr-http-max-request-size 41 \
|
||||
--max-body-size 41Mi \
|
||||
--log-level debug \
|
||||
go run ./custom-grpc-client/main.go
|
||||
```
|
||||
|
|
33
go.mod
33
go.mod
|
@ -1,33 +1,34 @@
|
|||
module github.com/dapr/go-sdk
|
||||
|
||||
go 1.23.3
|
||||
go 1.24.2
|
||||
|
||||
require (
|
||||
github.com/dapr/dapr v1.15.0-rc.1
|
||||
github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530
|
||||
github.com/dapr/dapr v1.15.5
|
||||
github.com/dapr/durabletask-go v0.6.5
|
||||
github.com/go-chi/chi/v5 v5.1.0
|
||||
github.com/golang/mock v1.6.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
google.golang.org/grpc v1.68.1
|
||||
google.golang.org/protobuf v1.35.2
|
||||
github.com/stretchr/testify v1.10.0
|
||||
google.golang.org/grpc v1.72.0
|
||||
google.golang.org/protobuf v1.36.6
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/dapr/kit v0.15.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/marusama/semaphore/v2 v2.5.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
go.opentelemetry.io/otel v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.32.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.32.0 // indirect
|
||||
golang.org/x/net v0.32.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.35.0 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 // indirect
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e // indirect
|
||||
)
|
||||
|
|
86
go.sum
86
go.sum
|
@ -1,10 +1,13 @@
|
|||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/dapr/dapr v1.15.0-rc.1 h1:7JP3zSannxQwV27A9pPR2b/DSNmgcSjJOhRDwM4eFpQ=
|
||||
github.com/dapr/dapr v1.15.0-rc.1/go.mod h1:SycZrBWgfmog+C5T4p0X6VIpnREQ3xajrYxdih+gn9w=
|
||||
github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530 h1:bfTcj9ewG6vYqV2Xm9fSGzXlLN5IzpeeBUUgoNiqcOg=
|
||||
github.com/dapr/durabletask-go v0.5.1-0.20241216172832-16da3e7c3530/go.mod h1:C4ykYCSNv1k2C4wvZv11h2ClkE/qsXw0tv6idOWVmDc=
|
||||
github.com/dapr/dapr v1.15.5 h1:bkCmcQQfaQ5C49P3l0elCzDr4/Oja5kitM3jStY+2RY=
|
||||
github.com/dapr/dapr v1.15.5/go.mod h1:wwopO8AD9CZOgVj4bsdXNmeQujMo0v3MLAqeaX+gb00=
|
||||
github.com/dapr/durabletask-go v0.6.5 h1:aWcxMfYudojpgRjJRdUr7yyZ7rGcvLtWXUuA4cGHBR0=
|
||||
github.com/dapr/durabletask-go v0.6.5/go.mod h1:nTZ5fCbJLnZbVdi6Z2YxdDF1OgQZL3LroogGuetrwuA=
|
||||
github.com/dapr/kit v0.15.2 h1:5H9IhKScU/SpE2Hxvr5vUlmYN1e2MJN15RoT8/KSziU=
|
||||
github.com/dapr/kit v0.15.2/go.mod h1:HwFsBKEbcyLanWlDZE7u/jnaDCD/tU+n3pkFNUctQNw=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
|
||||
|
@ -18,39 +21,48 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
|||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/marusama/semaphore/v2 v2.5.0 h1:o/1QJD9DBYOWRnDhPwDVAXQn6mQYD0gZaS1Tpx6DJGM=
|
||||
github.com/marusama/semaphore/v2 v2.5.0/go.mod h1:z9nMiNUekt/LTpTUQdpp+4sJeYqUGpwMHfW0Z8V8fnQ=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
|
||||
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
|
||||
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
|
||||
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
|
||||
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
|
||||
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
|
||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
|
||||
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
@ -58,27 +70,31 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1:hgh8P4EuoxpsuKMXX/To36nOFD7vixReXgn8lPGnt+o=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
|
||||
google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0=
|
||||
google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 h1:IqsN8hx+lWLqlN+Sc3DoMy/watjofWiU8sRFgQ8fhKM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
|
||||
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e h1:KqK5c/ghOm8xkHYhlodbp6i6+r+ChV2vuAuVRdFbLro=
|
||||
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
|
|
|
@ -107,6 +107,8 @@ type Subscription struct {
|
|||
Priority int `json:"priority"`
|
||||
// DisableTopicValidation allows to receive events from publisher topics that differ from the subscribed topic.
|
||||
DisableTopicValidation bool `json:"disableTopicValidation"`
|
||||
// DeadLetterTopic is the name of the deadletter topic.
|
||||
DeadLetterTopic string `json:"deadLetterTopic"`
|
||||
}
|
||||
|
||||
type SubscriptionResponseStatus string
|
||||
|
|
|
@ -40,7 +40,7 @@ func TestListInputBindings(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
err = server.AddBindingInvocationHandler("test2", testBindingHandler)
|
||||
require.NoError(t, err)
|
||||
resp, err := server.ListInputBindings(context.Background(), &emptypb.Empty{})
|
||||
resp, err := server.ListInputBindings(t.Context(), &emptypb.Empty{})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Lenf(t, resp.GetBindings(), 2, "expected 2 handlers")
|
||||
|
@ -57,7 +57,7 @@ func TestBindingForErrors(t *testing.T) {
|
|||
|
||||
// go test -timeout 30s ./service/grpc -count 1 -run ^TestBinding$
|
||||
func TestBinding(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
methodName := "test"
|
||||
|
||||
server := getTestServer()
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestHealthCheckHandlerForErrors(t *testing.T) {
|
|||
|
||||
// go test -timeout 30s ./service/grpc -count 1 -run ^TestHealthCheck$
|
||||
func TestHealthCheck(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
server := getTestServer()
|
||||
startTestServer(server)
|
||||
|
|
|
@ -67,21 +67,21 @@ func TestInvokeWithToken(t *testing.T) {
|
|||
grpcMetadata := metadata.New(map[string]string{
|
||||
cc.APITokenKey: os.Getenv(cc.AppAPITokenEnvVar),
|
||||
})
|
||||
ctx := metadata.NewIncomingContext(context.Background(), grpcMetadata)
|
||||
ctx := metadata.NewIncomingContext(t.Context(), grpcMetadata)
|
||||
in := &common.InvokeRequest{Method: methodName}
|
||||
_, err := server.OnInvoke(ctx, in)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
t.Run("invoke with empty token, return failed", func(t *testing.T) {
|
||||
in := &common.InvokeRequest{Method: methodName}
|
||||
_, err := server.OnInvoke(context.Background(), in)
|
||||
_, err := server.OnInvoke(t.Context(), in)
|
||||
require.Error(t, err)
|
||||
})
|
||||
t.Run("invoke with mismatch token, return failed", func(t *testing.T) {
|
||||
grpcMetadata := metadata.New(map[string]string{
|
||||
cc.APITokenKey: "mismatch-token",
|
||||
})
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), grpcMetadata)
|
||||
ctx := metadata.NewOutgoingContext(t.Context(), grpcMetadata)
|
||||
in := &common.InvokeRequest{Method: methodName}
|
||||
_, err := server.OnInvoke(ctx, in)
|
||||
require.Error(t, err)
|
||||
|
@ -93,7 +93,7 @@ func TestInvokeWithToken(t *testing.T) {
|
|||
func TestInvoke(t *testing.T) {
|
||||
methodName := "test"
|
||||
methodNameWithError := "error"
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
server := getTestServer()
|
||||
err := server.AddServiceInvocationHandler("/"+methodName, testInvokeHandler)
|
||||
|
|
|
@ -53,10 +53,11 @@ func (s *Server) ListTopicSubscriptions(ctx context.Context, in *emptypb.Empty)
|
|||
for _, v := range s.topicRegistrar {
|
||||
s := v.Subscription
|
||||
sub := &runtimev1pb.TopicSubscription{
|
||||
PubsubName: s.PubsubName,
|
||||
Topic: s.Topic,
|
||||
Metadata: s.Metadata,
|
||||
Routes: convertRoutes(s.Routes),
|
||||
PubsubName: s.PubsubName,
|
||||
Topic: s.Topic,
|
||||
Metadata: s.Metadata,
|
||||
Routes: convertRoutes(s.Routes),
|
||||
DeadLetterTopic: s.DeadLetterTopic,
|
||||
}
|
||||
subs = append(subs, sub)
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestTopicSubscriptionList(t *testing.T) {
|
|||
}
|
||||
err := server.AddTopicEventHandler(sub1, eventHandler)
|
||||
require.NoError(t, err)
|
||||
resp, err := server.ListTopicSubscriptions(context.Background(), &emptypb.Empty{})
|
||||
resp, err := server.ListTopicSubscriptions(t.Context(), &emptypb.Empty{})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
if assert.Lenf(t, resp.GetSubscriptions(), 1, "expected 1 handlers") {
|
||||
|
@ -76,7 +76,7 @@ func TestTopicSubscriptionList(t *testing.T) {
|
|||
}
|
||||
err = server.AddTopicEventHandler(sub2, eventHandler)
|
||||
require.NoError(t, err)
|
||||
resp, err = server.ListTopicSubscriptions(context.Background(), &emptypb.Empty{})
|
||||
resp, err = server.ListTopicSubscriptions(t.Context(), &emptypb.Empty{})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
if assert.Lenf(t, resp.GetSubscriptions(), 1, "expected 1 handlers") {
|
||||
|
@ -96,7 +96,7 @@ func TestTopicSubscriptionList(t *testing.T) {
|
|||
|
||||
// go test -timeout 30s ./service/grpc -count 1 -run ^TestTopic$
|
||||
func TestTopic(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
sub := &common.Subscription{
|
||||
PubsubName: "messages",
|
||||
|
@ -158,7 +158,7 @@ func TestTopic(t *testing.T) {
|
|||
Topic: sub2.Topic,
|
||||
PubsubName: sub2.PubsubName,
|
||||
}
|
||||
ctx := metadata.NewIncomingContext(context.Background(), metadata.New(map[string]string{"Metadata.key1": "value1"}))
|
||||
ctx := metadata.NewIncomingContext(t.Context(), metadata.New(map[string]string{"Metadata.key1": "value1"}))
|
||||
_, err = server.OnTopicEvent(ctx, in)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
@ -167,7 +167,7 @@ func TestTopic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTopicWithValidationDisabled(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
sub := &common.Subscription{
|
||||
PubsubName: "messages",
|
||||
|
@ -197,7 +197,7 @@ func TestTopicWithValidationDisabled(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTopicWithErrors(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
sub1 := &common.Subscription{
|
||||
PubsubName: "messages",
|
||||
|
@ -269,7 +269,7 @@ func eventHandlerWithError(ctx context.Context, event *common.TopicEvent) (retry
|
|||
}
|
||||
|
||||
func TestEventDataHandling(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tests := map[string]struct {
|
||||
contentType string
|
||||
|
|
|
@ -39,7 +39,7 @@ func (m TopicRegistrar) AddSubscription(sub *common.Subscription, fn common.Topi
|
|||
ts, ok := m[key]
|
||||
if !ok {
|
||||
ts = &TopicRegistration{
|
||||
Subscription: NewTopicSubscription(sub.PubsubName, sub.Topic),
|
||||
Subscription: NewTopicSubscription(sub.PubsubName, sub.Topic, sub.DeadLetterTopic),
|
||||
RouteHandlers: make(map[string]common.TopicEventSubscriber),
|
||||
DefaultHandler: nil,
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ type TopicSubscription struct {
|
|||
Routes *TopicRoutes `json:"routes,omitempty"`
|
||||
// Metadata is the subscription metadata.
|
||||
Metadata map[string]string `json:"metadata,omitempty"`
|
||||
// DeadLetterTopic is the name of the deadletter topic.
|
||||
DeadLetterTopic string `json:"deadLetterTopic"`
|
||||
}
|
||||
|
||||
// TopicRoutes encapsulates the default route and multiple routing rules.
|
||||
|
@ -42,10 +44,11 @@ type TopicRule struct {
|
|||
}
|
||||
|
||||
// NewTopicSubscription creates a new `TopicSubscription`.
|
||||
func NewTopicSubscription(pubsubName, topic string) *TopicSubscription {
|
||||
func NewTopicSubscription(pubsubName, topic, deadLetterTopic string) *TopicSubscription {
|
||||
return &TopicSubscription{ //nolint:exhaustivestruct
|
||||
PubsubName: pubsubName,
|
||||
Topic: topic,
|
||||
PubsubName: pubsubName,
|
||||
Topic: topic,
|
||||
DeadLetterTopic: deadLetterTopic,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
func TestTopicSubscripiton(t *testing.T) {
|
||||
t.Run("duplicate metadata", func(t *testing.T) {
|
||||
sub := internal.NewTopicSubscription("test", "mytopic")
|
||||
sub := internal.NewTopicSubscription("test", "mytopic", "")
|
||||
require.NoError(t, sub.SetMetadata(map[string]string{
|
||||
"test": "test",
|
||||
}))
|
||||
|
@ -22,7 +22,7 @@ func TestTopicSubscripiton(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("duplicate route", func(t *testing.T) {
|
||||
sub := internal.NewTopicSubscription("test", "mytopic")
|
||||
sub := internal.NewTopicSubscription("test", "mytopic", "")
|
||||
require.NoError(t, sub.SetDefaultRoute("/test"))
|
||||
assert.Equal(t, "/test", sub.Route)
|
||||
require.EqualError(t, sub.SetDefaultRoute("/test"),
|
||||
|
@ -30,7 +30,7 @@ func TestTopicSubscripiton(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("duplicate route after routing rule", func(t *testing.T) {
|
||||
sub := internal.NewTopicSubscription("test", "mytopic")
|
||||
sub := internal.NewTopicSubscription("test", "mytopic", "")
|
||||
require.NoError(t, sub.AddRoutingRule("/other", `event.type == "test"`, 0))
|
||||
require.NoError(t, sub.SetDefaultRoute("/test"))
|
||||
require.EqualError(t, sub.SetDefaultRoute("/test"),
|
||||
|
@ -38,7 +38,7 @@ func TestTopicSubscripiton(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("default route after routing rule", func(t *testing.T) {
|
||||
sub := internal.NewTopicSubscription("test", "mytopic")
|
||||
sub := internal.NewTopicSubscription("test", "mytopic", "")
|
||||
require.NoError(t, sub.SetDefaultRoute("/test"))
|
||||
assert.Equal(t, "/test", sub.Route)
|
||||
require.NoError(t, sub.AddRoutingRule("/other", `event.type == "test"`, 0))
|
||||
|
@ -49,14 +49,14 @@ func TestTopicSubscripiton(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("duplicate routing rule priority", func(t *testing.T) {
|
||||
sub := internal.NewTopicSubscription("test", "mytopic")
|
||||
sub := internal.NewTopicSubscription("test", "mytopic", "")
|
||||
require.NoError(t, sub.AddRoutingRule("/other", `event.type == "other"`, 1))
|
||||
require.EqualError(t, sub.AddRoutingRule("/test", `event.type == "test"`, 1),
|
||||
"subscription for topic mytopic on pubsub test already has a routing rule with priority 1")
|
||||
})
|
||||
|
||||
t.Run("priority ordering", func(t *testing.T) {
|
||||
sub := internal.NewTopicSubscription("test", "mytopic")
|
||||
sub := internal.NewTopicSubscription("test", "mytopic", "")
|
||||
require.NoError(t, sub.AddRoutingRule("/100", `event.type == "100"`, 100))
|
||||
require.NoError(t, sub.AddRoutingRule("/1", `event.type == "1"`, 1))
|
||||
require.NoError(t, sub.AddRoutingRule("/50", `event.type == "50"`, 50))
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestParseWorkflow(t *testing.T) {
|
|||
|
||||
t.Run("parse testing workflow file", func(t *testing.T) {
|
||||
parsedVersion, err := parseWorkflowVersionFromFile("../../.github/workflows/test-tooling.yml")
|
||||
assert.Equal(t, "v1.61.0", parsedVersion)
|
||||
assert.Equal(t, "v1.64.6", parsedVersion)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func TestParseWorkflow(t *testing.T) {
|
|||
func TestGetCurrentVersion(t *testing.T) {
|
||||
t.Run("get current version from system", func(t *testing.T) {
|
||||
currentVersion, err := getCurrentVersion()
|
||||
assert.Equal(t, "v1.61.0", currentVersion)
|
||||
assert.Equal(t, "v1.64.6", currentVersion)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
|
@ -49,23 +49,23 @@ func TestGetCurrentVersion(t *testing.T) {
|
|||
|
||||
func TestIsVersionValid(t *testing.T) {
|
||||
t.Run("compare versions - exactly equal to", func(t *testing.T) {
|
||||
assert.True(t, true, isVersionValid("v1.54.2", "v1.54.2"))
|
||||
assert.True(t, isVersionValid("v1.54.2", "v1.54.2"))
|
||||
})
|
||||
|
||||
t.Run("compare versions - patch version greater (workflow)", func(t *testing.T) {
|
||||
assert.True(t, true, isVersionValid("v1.54.3", "v1.54.2"))
|
||||
assert.True(t, isVersionValid("v1.54.3", "v1.54.2"))
|
||||
})
|
||||
|
||||
t.Run("compare versions - patch version greater (installed)", func(t *testing.T) {
|
||||
assert.True(t, true, isVersionValid("v1.54.2", "v1.54.3"))
|
||||
assert.True(t, isVersionValid("v1.54.2", "v1.54.3"))
|
||||
})
|
||||
|
||||
t.Run("compare versions - invalid (installed)", func(t *testing.T) {
|
||||
assert.False(t, false, isVersionValid("v1.54.2", "v1.52.2"))
|
||||
assert.False(t, isVersionValid("v1.54.2", "v1.52.2"))
|
||||
})
|
||||
|
||||
t.Run("compare versions - invalid (workflow)", func(t *testing.T) {
|
||||
assert.False(t, false, isVersionValid("v1.52.2", "v1.54.2"))
|
||||
assert.False(t, isVersionValid("v1.52.2", "v1.54.2"))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
v1.12.0-rc.1
|
||||
v1.12.0
|
|
@ -29,6 +29,7 @@ import (
|
|||
|
||||
type testingTaskActivityContext struct {
|
||||
inputBytes []byte
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func (t *testingTaskActivityContext) GetInput(v any) error {
|
||||
|
@ -36,7 +37,7 @@ func (t *testingTaskActivityContext) GetInput(v any) error {
|
|||
}
|
||||
|
||||
func (t *testingTaskActivityContext) Context() context.Context {
|
||||
return context.TODO()
|
||||
return t.ctx
|
||||
}
|
||||
|
||||
func TestActivityContext(t *testing.T) {
|
||||
|
@ -44,7 +45,7 @@ func TestActivityContext(t *testing.T) {
|
|||
inputBytes, err := json.Marshal(inputString)
|
||||
require.NoErrorf(t, err, "required no error, but got %v", err)
|
||||
|
||||
ac := ActivityContext{ctx: &testingTaskActivityContext{inputBytes: inputBytes}}
|
||||
ac := ActivityContext{ctx: &testingTaskActivityContext{inputBytes: inputBytes, ctx: t.Context()}}
|
||||
t.Run("test getinput", func(t *testing.T) {
|
||||
var inputReturn string
|
||||
err := ac.GetInput(&inputReturn)
|
||||
|
@ -53,7 +54,7 @@ func TestActivityContext(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("test context", func(t *testing.T) {
|
||||
assert.Equal(t, context.TODO(), ac.Context())
|
||||
assert.Equal(t, t.Context(), ac.Context())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ limitations under the License.
|
|||
package workflow
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -52,7 +51,7 @@ func TestClientMethods(t *testing.T) {
|
|||
testClient := Client{
|
||||
taskHubClient: nil,
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
t.Run("ScheduleNewWorkflow - empty wf name", func(t *testing.T) {
|
||||
id, err := testClient.ScheduleNewWorkflow(ctx, "", WithReuseIDPolicy(WorkflowIDReusePolicy{
|
||||
OperationStatus: []Status{StatusCompleted},
|
||||
|
|
|
@ -125,7 +125,13 @@ func wrapActivity(a Activity) task.Activity {
|
|||
return func(ctx task.ActivityContext) (any, error) {
|
||||
aCtx := ActivityContext{ctx: ctx}
|
||||
|
||||
return a(aCtx)
|
||||
result, err := a(aCtx)
|
||||
if err != nil {
|
||||
activityName, _ := getFunctionName(a) // Get the activity name for context
|
||||
return nil, fmt.Errorf("activity %s failed: %w", activityName, err)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue