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
30 changes: 23 additions & 7 deletions examples/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ package common
import (
"errors"
"fmt"
"github.com/metaform/dataplane-sdk-go/pkg/dsdk"
"net/http"
"strings"

"github.com/go-chi/chi/v5"
"github.com/metaform/dataplane-sdk-go/pkg/dsdk"
)

const (
Expand All @@ -36,13 +38,27 @@ type TokenResponse struct {

// NewSignalingServer creates and returns a new HTTP server configured with dataplane signaling endpoints.
func NewSignalingServer(sdkApi *dsdk.DataPlaneApi, port int) *http.Server {
mux := http.NewServeMux()
mux.HandleFunc("/start", sdkApi.Start)
mux.HandleFunc("/prepare", sdkApi.Prepare)
mux.HandleFunc("/terminate/", sdkApi.Terminate)
mux.HandleFunc("/suspend/", sdkApi.Suspend)
r := chi.NewRouter()
r.Post("/dataflows/start", sdkApi.Start)
r.Post("/dataflows/{id}/start", func(writer http.ResponseWriter, request *http.Request) {
id := chi.URLParam(request, "id")
sdkApi.StartById(writer, request, id)
})
r.Post("/dataflows/prepare", sdkApi.Prepare)
r.Post("/dataflows/{id}/terminate", func(writer http.ResponseWriter, request *http.Request) {
id := chi.URLParam(request, "id")
sdkApi.Terminate(id, writer, request)
})
r.Post("/dataflows/{id}/suspend", func(writer http.ResponseWriter, request *http.Request) {
id := chi.URLParam(request, "id")
sdkApi.Suspend(id, writer, request)
})
r.Get("/dataflows/{id}/status", func(writer http.ResponseWriter, request *http.Request) {
id := chi.URLParam(request, "id")
sdkApi.Status(id, writer, request)
})

return &http.Server{Addr: fmt.Sprintf(":%d", port), Handler: mux}
return &http.Server{Addr: fmt.Sprintf(":%d", port), Handler: r}
}

// NewDataServer creates and initializes a new HTTP server with a specified port and request handler.
Expand Down
6 changes: 3 additions & 3 deletions examples/controlplane/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
)

const (
startUrl = "http://localhost:%d/start"
terminateUrl = "http://localhost:%d/terminate/%s"
consumerPrepareURL = "http://localhost:%d/prepare"
startUrl = "http://localhost:%d/dataflows/start"
terminateUrl = "http://localhost:%d/dataflows/%s/terminate"
consumerPrepareURL = "http://localhost:%d/dataflows/prepare"
providerCallbackURL = "http://provider.com/dp/callback"
contentType = "Content-Type"
jsonContentType = "application/json"
Expand Down
3 changes: 2 additions & 1 deletion examples/streaming-pull-dataplane/launcher/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
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"
"log"
)

func LaunchServices() (*provider.ProviderDataPlane, *consumer.ConsumerDataPlane) {
Expand Down
5 changes: 3 additions & 2 deletions examples/streaming/terminate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ package streaming

import (
"context"
"github.com/google/uuid"
"github.com/metaform/dataplane-sdk-go/examples/controlplane"
"log"
"time"

"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
5 changes: 3 additions & 2 deletions examples/sync-pull-dataplane/launcher/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ package launcher

import (
"context"
"github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/consumer"
"github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/provider"
"sync"
"time"

"github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/consumer"
"github.com/metaform/dataplane-sdk-go/examples/sync-pull-dataplane/provider"
)

func LaunchServicesAndWait(wg *sync.WaitGroup) {
Expand Down
5 changes: 3 additions & 2 deletions examples/sync-pull-dataplane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ package main

import (
"context"
"log"
"sync"

"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"
"log"
"sync"
)

// Demonstrates initiating a data transfer using a provider data plane that implements synchronous signaling start operations.
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/metaform/dataplane-sdk-go
go 1.24.1

require (
github.com/go-chi/chi/v5 v5.2.3
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 @@ -42,6 +42,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
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-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
Loading