diff --git a/examples/common/common.go b/examples/common/common.go index 90ac968..6461aa1 100644 --- a/examples/common/common.go +++ b/examples/common/common.go @@ -18,8 +18,8 @@ import ( "net/http" "strings" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" "github.com/go-chi/chi/v5" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" ) const ( diff --git a/examples/controlplane/controlplane.go b/examples/controlplane/controlplane.go index 960bced..a62fceb 100644 --- a/examples/controlplane/controlplane.go +++ b/examples/controlplane/controlplane.go @@ -21,9 +21,9 @@ import ( "net/url" "time" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" "github.com/google/uuid" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" ) const ( diff --git a/examples/natsservices/authentication.go b/examples/natsservices/authentication.go index 49d1681..7bd5c7a 100644 --- a/examples/natsservices/authentication.go +++ b/examples/natsservices/authentication.go @@ -15,7 +15,7 @@ package natsservices import ( "errors" "fmt" - "github.com/metaform/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" "github.com/nats-io/jwt/v2" "github.com/nats-io/nats-server/v2/logger" "github.com/nats-io/nats.go" diff --git a/examples/natsservices/subscriber.go b/examples/natsservices/subscriber.go index b9714c8..42b6585 100644 --- a/examples/natsservices/subscriber.go +++ b/examples/natsservices/subscriber.go @@ -13,7 +13,7 @@ package natsservices import ( - "github.com/metaform/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" "github.com/nats-io/nats.go" "log" ) diff --git a/examples/streaming-pull-dataplane/consumer/dataplane.go b/examples/streaming-pull-dataplane/consumer/dataplane.go index 4fb8d5c..ef25c75 100644 --- a/examples/streaming-pull-dataplane/consumer/dataplane.go +++ b/examples/streaming-pull-dataplane/consumer/dataplane.go @@ -18,10 +18,10 @@ import ( "log" "net/http" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/examples/natsservices" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" - "github.com/metaform/dataplane-sdk-go/pkg/memory" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/natsservices" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/memory" ) type ConsumerDataPlane struct { diff --git a/examples/streaming-pull-dataplane/launcher/services.go b/examples/streaming-pull-dataplane/launcher/services.go index ae9873f..dee704a 100644 --- a/examples/streaming-pull-dataplane/launcher/services.go +++ b/examples/streaming-pull-dataplane/launcher/services.go @@ -15,9 +15,9 @@ package launcher import ( "log" - "github.com/metaform/dataplane-sdk-go/examples/natsservices" - "github.com/metaform/dataplane-sdk-go/examples/streaming-pull-dataplane/consumer" - "github.com/metaform/dataplane-sdk-go/examples/streaming-pull-dataplane/provider" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/natsservices" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming-pull-dataplane/consumer" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming-pull-dataplane/provider" ) func LaunchServices() (*provider.ProviderDataPlane, *consumer.ConsumerDataPlane) { diff --git a/examples/streaming-pull-dataplane/main.go b/examples/streaming-pull-dataplane/main.go index a9e6013..d3cd9f0 100644 --- a/examples/streaming-pull-dataplane/main.go +++ b/examples/streaming-pull-dataplane/main.go @@ -1,8 +1,8 @@ package main import ( - "github.com/metaform/dataplane-sdk-go/examples/streaming" - "github.com/metaform/dataplane-sdk-go/examples/streaming-pull-dataplane/launcher" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming-pull-dataplane/launcher" ) func main() { diff --git a/examples/streaming-pull-dataplane/provider/dataplane.go b/examples/streaming-pull-dataplane/provider/dataplane.go index 672ac62..0db9dca 100644 --- a/examples/streaming-pull-dataplane/provider/dataplane.go +++ b/examples/streaming-pull-dataplane/provider/dataplane.go @@ -19,10 +19,10 @@ import ( "log" "net/http" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/examples/natsservices" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" - "github.com/metaform/dataplane-sdk-go/pkg/memory" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/natsservices" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/memory" ) // ProviderDataPlane demonstrates how to use the Data Plane SDK. This implementation supports pull event streaming. diff --git a/examples/streaming-pull-dataplane/provider/publisher.go b/examples/streaming-pull-dataplane/provider/publisher.go index 14f98df..8cccb87 100644 --- a/examples/streaming-pull-dataplane/provider/publisher.go +++ b/examples/streaming-pull-dataplane/provider/publisher.go @@ -15,8 +15,8 @@ package provider import ( "context" "fmt" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/examples/natsservices" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/natsservices" "github.com/nats-io/nats.go" "log" "time" diff --git a/examples/streaming-push-dataplane/consumer/dataplane.go b/examples/streaming-push-dataplane/consumer/dataplane.go index d9e8a8b..865c5da 100644 --- a/examples/streaming-push-dataplane/consumer/dataplane.go +++ b/examples/streaming-push-dataplane/consumer/dataplane.go @@ -19,10 +19,10 @@ import ( "log" "net/http" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/examples/natsservices" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" - "github.com/metaform/dataplane-sdk-go/pkg/memory" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/natsservices" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/memory" ) // ConsumerDataPlane demonstrates how to use the Data Plane SDK. This implementation supports push event streaming. diff --git a/examples/streaming-push-dataplane/launcher/services.go b/examples/streaming-push-dataplane/launcher/services.go index 802c2aa..cd10aea 100644 --- a/examples/streaming-push-dataplane/launcher/services.go +++ b/examples/streaming-push-dataplane/launcher/services.go @@ -13,10 +13,11 @@ package launcher import ( - "github.com/metaform/dataplane-sdk-go/examples/natsservices" - "github.com/metaform/dataplane-sdk-go/examples/streaming-push-dataplane/consumer" - "github.com/metaform/dataplane-sdk-go/examples/streaming-push-dataplane/provider" "log" + + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/natsservices" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming-push-dataplane/consumer" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming-push-dataplane/provider" ) func LaunchServices() (*provider.ProviderDataPlane, *consumer.ConsumerDataPlane) { diff --git a/examples/streaming-push-dataplane/main.go b/examples/streaming-push-dataplane/main.go index 706adaf..fdc7d86 100644 --- a/examples/streaming-push-dataplane/main.go +++ b/examples/streaming-push-dataplane/main.go @@ -13,8 +13,8 @@ package main import ( - "github.com/metaform/dataplane-sdk-go/examples/streaming" - "github.com/metaform/dataplane-sdk-go/examples/streaming-push-dataplane/launcher" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/streaming-push-dataplane/launcher" ) func main() { diff --git a/examples/streaming-push-dataplane/provider/dataplane.go b/examples/streaming-push-dataplane/provider/dataplane.go index 8b86d83..46a5f71 100644 --- a/examples/streaming-push-dataplane/provider/dataplane.go +++ b/examples/streaming-push-dataplane/provider/dataplane.go @@ -18,10 +18,10 @@ import ( "log" "net/http" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/examples/natsservices" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" - "github.com/metaform/dataplane-sdk-go/pkg/memory" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/natsservices" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/memory" ) type ProviderDataPlane struct { diff --git a/examples/streaming-push-dataplane/provider/publisher.go b/examples/streaming-push-dataplane/provider/publisher.go index e4cc201..e8ef094 100644 --- a/examples/streaming-push-dataplane/provider/publisher.go +++ b/examples/streaming-push-dataplane/provider/publisher.go @@ -15,7 +15,7 @@ package provider import ( "context" "fmt" - "github.com/metaform/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" "github.com/nats-io/nats.go" "log" "time" diff --git a/examples/streaming/terminate.go b/examples/streaming/terminate.go index 2a97c82..cb32534 100644 --- a/examples/streaming/terminate.go +++ b/examples/streaming/terminate.go @@ -17,8 +17,8 @@ import ( "log" "time" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/controlplane" "github.com/google/uuid" - "github.com/metaform/dataplane-sdk-go/examples/controlplane" ) // TerminateScenario coordinates a simulated data transfer scenario and forcibly terminates it after a predefined duration. diff --git a/examples/sync-pull-dataplane/consumer/client.go b/examples/sync-pull-dataplane/consumer/client.go index 82a2853..fbd4e46 100644 --- a/examples/sync-pull-dataplane/consumer/client.go +++ b/examples/sync-pull-dataplane/consumer/client.go @@ -21,7 +21,7 @@ import ( "net/http" "time" - "github.com/metaform/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" ) const ( diff --git a/examples/sync-pull-dataplane/consumer/dataplane.go b/examples/sync-pull-dataplane/consumer/dataplane.go index 7c7f01e..dd17194 100644 --- a/examples/sync-pull-dataplane/consumer/dataplane.go +++ b/examples/sync-pull-dataplane/consumer/dataplane.go @@ -19,9 +19,9 @@ import ( "log" "net/http" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" - "github.com/metaform/dataplane-sdk-go/pkg/memory" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/memory" ) const ( diff --git a/examples/sync-pull-dataplane/launcher/services.go b/examples/sync-pull-dataplane/launcher/services.go index d690d28..f4f6d02 100644 --- a/examples/sync-pull-dataplane/launcher/services.go +++ b/examples/sync-pull-dataplane/launcher/services.go @@ -17,8 +17,8 @@ import ( "sync" "time" - "github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/consumer" - "github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/provider" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/sync-pull-dataplane/consumer" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/sync-pull-dataplane/provider" ) func LaunchServicesAndWait(wg *sync.WaitGroup) { diff --git a/examples/sync-pull-dataplane/main.go b/examples/sync-pull-dataplane/main.go index 3e1bc1b..b2cf3d2 100644 --- a/examples/sync-pull-dataplane/main.go +++ b/examples/sync-pull-dataplane/main.go @@ -17,10 +17,10 @@ import ( "log" "sync" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/controlplane" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/sync-pull-dataplane/consumer" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/sync-pull-dataplane/launcher" "github.com/google/uuid" - "github.com/metaform/dataplane-sdk-go/examples/controlplane" - "github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/consumer" - "github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/launcher" ) // Demonstrates initiating a data transfer using a provider data plane that implements synchronous signaling start operations. diff --git a/examples/sync-pull-dataplane/provider/dataplane.go b/examples/sync-pull-dataplane/provider/dataplane.go index cb95c6c..1a1fcfd 100644 --- a/examples/sync-pull-dataplane/provider/dataplane.go +++ b/examples/sync-pull-dataplane/provider/dataplane.go @@ -20,10 +20,10 @@ import ( "log" "net/http" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/examples/common" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/memory" "github.com/google/uuid" - "github.com/metaform/dataplane-sdk-go/examples/common" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" - "github.com/metaform/dataplane-sdk-go/pkg/memory" ) const ( diff --git a/go.mod b/go.mod index aaa34a1..a911566 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ -module github.com/metaform/dataplane-sdk-go +module github.com/eclipse-dataplane-core/dataplane-sdk-go go 1.24.1 require ( - github.com/go-chi/chi/v5 v5.2.3 + github.com/go-chi/chi/v5 v5.5.1-0.20261018135022-9f8adb1aabaa github.com/go-playground/validator/v10 v10.27.0 github.com/google/uuid v1.6.0 github.com/lib/pq v1.10.9 diff --git a/go.sum b/go.sum index c0f09aa..3f4317c 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3G github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= +github.com/go-chi/chi/v5 v5.5.1-0.20261018135022-9f8adb1aabaa h1:bAIp0rpGqGbS/4/TAZVXIxsNu295q0ZZWh28VSn4EXA= +github.com/go-chi/chi/v5 v5.5.1-0.20261018135022-9f8adb1aabaa/go.mod h1:d1IG7GtKPSjPyBP365PH8sAGVHk3qfB/IhjFNRH1wWM= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= diff --git a/internal/tests/api_integration_test.go b/internal/tests/api_integration_test.go index 02fc558..aafa0fc 100644 --- a/internal/tests/api_integration_test.go +++ b/internal/tests/api_integration_test.go @@ -14,11 +14,11 @@ import ( "strings" "testing" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/postgres" "github.com/go-chi/chi/v5" "github.com/google/uuid" _ "github.com/lib/pq" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" - "github.com/metaform/dataplane-sdk-go/pkg/postgres" "github.com/stretchr/testify/assert" ) @@ -236,6 +236,26 @@ func Test_Prepare(t *testing.T) { assert.Equal(t, responseMessage.State, dsdk.Prepared) } +func Test_Prepare_InvalidPayload(t *testing.T) { + pm := newPrepareMessage() + pm.CounterPartyID = "" // should raise a validation error + payload, err := serialize(pm) + assert.NoError(t, err) + req, err := http.NewRequest(http.MethodPost, "/dataflows/prepare", bytes.NewBuffer(payload)) + assert.NoError(t, err) + + rr := httptest.NewRecorder() + handler.ServeHTTP(rr, req) + assert.Equal(t, http.StatusBadRequest, rr.Code) + + // the handler must stop after the validation error and write exactly one response body + decoder := json.NewDecoder(rr.Body) + var responseMessage dsdk.DataFlowResponseMessage + assert.NoError(t, decoder.Decode(&responseMessage)) + assert.NotEmpty(t, responseMessage.Error) + assert.False(t, decoder.More()) +} + func Test_Prepare_WrongState(t *testing.T) { s := postgres.NewStore(database) diff --git a/pkg/dsdk/api.go b/pkg/dsdk/api.go index 9e241e5..fb4e70e 100644 --- a/pkg/dsdk/api.go +++ b/pkg/dsdk/api.go @@ -48,6 +48,7 @@ func (d *DataPlaneApi) Prepare(w http.ResponseWriter, r *http.Request) { if err := prepareMessage.Validate(); err != nil { d.handleError(err, w) + return } response, err := d.sdk.Prepare(r.Context(), prepareMessage) diff --git a/pkg/dsdk/dsdk.go b/pkg/dsdk/dsdk.go index 62c0d27..c84e5fe 100644 --- a/pkg/dsdk/dsdk.go +++ b/pkg/dsdk/dsdk.go @@ -288,7 +288,7 @@ func (dsdk *DataPlaneSDK) Complete(ctx context.Context, dataflowID string) error return e } storeErr := dsdk.Store.Save(ctx, flow) - if err != nil { + if storeErr != nil { return fmt.Errorf("completing data flow %s: %w", flow.ID, storeErr) } return nil diff --git a/pkg/dsdk/dsdk_test.go b/pkg/dsdk/dsdk_test.go index 661a129..81081e3 100644 --- a/pkg/dsdk/dsdk_test.go +++ b/pkg/dsdk/dsdk_test.go @@ -685,6 +685,29 @@ func Test_DataPlaneSDK_Completed(t *testing.T) { assert.NoError(t, err) } +func Test_DataPlaneSDK_Completed_StoreError(t *testing.T) { + store := NewMockDataplaneStore(t) + dsdk := DataPlaneSDK{ + Store: store, + TrxContext: &mockTrxContext{}, + onComplete: func(ctx context.Context, flow *DataFlow) error { + return nil + }, + } + + ctx := context.Background() + + store.EXPECT().FindById(ctx, "flow123").Return(&DataFlow{ + ID: "flow123", + State: Started, + }, nil) + store.EXPECT().Save(ctx, mock.AnythingOfType("*dsdk.DataFlow")).Return(fmt.Errorf("store error")) + + err := dsdk.Complete(ctx, "flow123") + + assert.ErrorContains(t, err, "store error") +} + func Test_DataPlaneSDK_Completed_AlreadyCompleted(t *testing.T) { store := NewMockDataplaneStore(t) dsdk := DataPlaneSDK{ diff --git a/pkg/memory/memory.go b/pkg/memory/memory.go index 0920658..1d7ad78 100644 --- a/pkg/memory/memory.go +++ b/pkg/memory/memory.go @@ -16,7 +16,7 @@ import ( "context" "sync" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" ) // InMemoryStore is a thread-safe in-memory implementation of DataplaneStore diff --git a/pkg/memory/memory_test.go b/pkg/memory/memory_test.go index 4a9a5fe..f5fe6de 100644 --- a/pkg/memory/memory_test.go +++ b/pkg/memory/memory_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/postgres/postgres_store.go b/pkg/postgres/postgres_store.go index 4583803..2d3d7ee 100644 --- a/pkg/postgres/postgres_store.go +++ b/pkg/postgres/postgres_store.go @@ -10,8 +10,8 @@ import ( "log" "time" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" "github.com/lib/pq" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" ) type PostgresStore struct { diff --git a/pkg/postgres/postgres_store_test.go b/pkg/postgres/postgres_store_test.go index c00c9d7..2b2365a 100644 --- a/pkg/postgres/postgres_store_test.go +++ b/pkg/postgres/postgres_store_test.go @@ -10,9 +10,9 @@ import ( "testing" "time" + "github.com/eclipse-dataplane-core/dataplane-sdk-go/pkg/dsdk" "github.com/google/uuid" _ "github.com/lib/pq" - "github.com/metaform/dataplane-sdk-go/pkg/dsdk" "github.com/stretchr/testify/assert" "github.com/testcontainers/testcontainers-go" )