Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions examples/controlplane/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion examples/natsservices/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/natsservices/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
8 changes: 4 additions & 4 deletions examples/streaming-pull-dataplane/consumer/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions examples/streaming-pull-dataplane/launcher/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions examples/streaming-pull-dataplane/main.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions examples/streaming-pull-dataplane/provider/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/streaming-pull-dataplane/provider/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions examples/streaming-push-dataplane/consumer/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions examples/streaming-push-dataplane/launcher/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions examples/streaming-push-dataplane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions examples/streaming-push-dataplane/provider/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/streaming-push-dataplane/provider/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/streaming/terminate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/sync-pull-dataplane/consumer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions examples/sync-pull-dataplane/consumer/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions examples/sync-pull-dataplane/launcher/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions examples/sync-pull-dataplane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions examples/sync-pull-dataplane/provider/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
24 changes: 22 additions & 2 deletions internal/tests/api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/dsdk/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dsdk/dsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions pkg/dsdk/dsdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/memory/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/postgres/postgres_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/postgres/postgres_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Loading