Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename go-runtime/sdk to go-runtime/ftl #931

Merged
merged 2 commits into from
Feb 13, 2024
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
4 changes: 2 additions & 2 deletions cmd/ftl/cmd_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/titanous/json5"

"github.com/TBD54566975/ftl/backend/common/log"
"github.com/TBD54566975/ftl/go-runtime/sdk"
"github.com/TBD54566975/ftl/go-runtime/ftl"
ftlv1 "github.com/TBD54566975/ftl/protos/xyz/block/ftl/v1"
"github.com/TBD54566975/ftl/protos/xyz/block/ftl/v1/ftlv1connect"
)

type callCmd struct {
Verb sdk.VerbRef `arg:"" required:"" help:"Full path of Verb to call."`
Verb ftl.VerbRef `arg:"" required:"" help:"Full path of Verb to call."`
Request string `arg:"" optional:"" help:"JSON5 request payload." default:"{}"`
}

Expand Down
6 changes: 3 additions & 3 deletions examples/go/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

"ftl/time"

"github.com/TBD54566975/ftl/go-runtime/sdk"
"github.com/TBD54566975/ftl/go-runtime/ftl"
)

// An echo request.
type EchoRequest struct {
Name sdk.Option[string] `json:"name"`
Name ftl.Option[string] `json:"name"`
}

type EchoResponse struct {
Expand All @@ -26,7 +26,7 @@ type EchoResponse struct {
//ftl:verb
func Echo(ctx context.Context, req EchoRequest) (EchoResponse, error) {
fmt.Println("Echo received a request!")
tresp, err := sdk.Call(ctx, time.Time, time.TimeRequest{})
tresp, err := ftl.Call(ctx, time.Time, time.TimeRequest{})
if err != nil {
return EchoResponse{}, err
}
Expand Down
34 changes: 17 additions & 17 deletions examples/go/httpingress/httpingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"ftl/builtin"

"github.com/TBD54566975/ftl/go-runtime/sdk"
"github.com/TBD54566975/ftl/go-runtime/ftl"
)

type GetRequest struct {
Expand All @@ -28,10 +28,10 @@ type GetResponse struct {
//
//ftl:verb
//ftl:ingress http GET /http/users/{userID}/posts
func Get(ctx context.Context, req builtin.HttpRequest[GetRequest]) (builtin.HttpResponse[GetResponse, sdk.Unit], error) {
return builtin.HttpResponse[GetResponse, sdk.Unit]{
func Get(ctx context.Context, req builtin.HttpRequest[GetRequest]) (builtin.HttpResponse[GetResponse, ftl.Unit], error) {
return builtin.HttpResponse[GetResponse, ftl.Unit]{
Headers: map[string][]string{"Get": {"Header from FTL"}},
Body: sdk.Some(GetResponse{
Body: ftl.Some(GetResponse{
Message: fmt.Sprintf("Got userId %s and postId %s", req.Body.UserID, req.Body.PostID),
Nested: Nested{GoodStuff: "Nested Good Stuff"},
}),
Expand All @@ -51,11 +51,11 @@ type PostResponse struct {
//
//ftl:verb
//ftl:ingress http POST /http/users
func Post(ctx context.Context, req builtin.HttpRequest[PostRequest]) (builtin.HttpResponse[PostResponse, sdk.Unit], error) {
return builtin.HttpResponse[PostResponse, sdk.Unit]{
func Post(ctx context.Context, req builtin.HttpRequest[PostRequest]) (builtin.HttpResponse[PostResponse, ftl.Unit], error) {
return builtin.HttpResponse[PostResponse, ftl.Unit]{
Status: 201,
Headers: map[string][]string{"Post": {"Header from FTL"}},
Body: sdk.Some(PostResponse{Success: true}),
Body: ftl.Some(PostResponse{Success: true}),
}, nil
}

Expand All @@ -70,8 +70,8 @@ type PutResponse struct{}
//
//ftl:verb
//ftl:ingress http PUT /http/users/{userID}
func Put(ctx context.Context, req builtin.HttpRequest[PutRequest]) (builtin.HttpResponse[PutResponse, sdk.Unit], error) {
return builtin.HttpResponse[PutResponse, sdk.Unit]{
func Put(ctx context.Context, req builtin.HttpRequest[PutRequest]) (builtin.HttpResponse[PutResponse, ftl.Unit], error) {
return builtin.HttpResponse[PutResponse, ftl.Unit]{
Headers: map[string][]string{"Put": {"Header from FTL"}},
}, nil
}
Expand All @@ -86,8 +86,8 @@ type DeleteResponse struct{}
//
//ftl:verb
//ftl:ingress http DELETE /http/users/{userID}
func Delete(ctx context.Context, req builtin.HttpRequest[DeleteRequest]) (builtin.HttpResponse[DeleteResponse, sdk.Unit], error) {
return builtin.HttpResponse[DeleteResponse, sdk.Unit]{
func Delete(ctx context.Context, req builtin.HttpRequest[DeleteRequest]) (builtin.HttpResponse[DeleteResponse, ftl.Unit], error) {
return builtin.HttpResponse[DeleteResponse, ftl.Unit]{
Headers: map[string][]string{"Put": {"Header from FTL"}},
}, nil
}
Expand All @@ -96,20 +96,20 @@ type HtmlRequest struct{}

//ftl:verb
//ftl:ingress http GET /http/html
func Html(ctx context.Context, req builtin.HttpRequest[HtmlRequest]) (builtin.HttpResponse[string, sdk.Unit], error) {
return builtin.HttpResponse[string, sdk.Unit]{
func Html(ctx context.Context, req builtin.HttpRequest[HtmlRequest]) (builtin.HttpResponse[string, ftl.Unit], error) {
return builtin.HttpResponse[string, ftl.Unit]{
Headers: map[string][]string{"Content-Type": {"text/html; charset=utf-8"}},
Body: sdk.Some("<html><body><h1>HTML Page From FTL 🚀!</h1></body></html>"),
Body: ftl.Some("<html><body><h1>HTML Page From FTL 🚀!</h1></body></html>"),
}, nil
}

// Example: curl -X POST http://localhost:8892/ingress/http/bytes -d 'Your data here'
//
//ftl:verb
//ftl:ingress http POST /http/bytes
func Bytes(ctx context.Context, req builtin.HttpRequest[[]byte]) (builtin.HttpResponse[[]byte, sdk.Unit], error) {
return builtin.HttpResponse[[]byte, sdk.Unit]{
func Bytes(ctx context.Context, req builtin.HttpRequest[[]byte]) (builtin.HttpResponse[[]byte, ftl.Unit], error) {
return builtin.HttpResponse[[]byte, ftl.Unit]{
Headers: map[string][]string{"Content-Type": {"application/octet-stream"}},
Body: sdk.Some(req.Body),
Body: ftl.Some(req.Body),
}, nil
}
2 changes: 1 addition & 1 deletion examples/online-boutique/services/checkout/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/TBD54566975/ftl/backend/common/slices"
"github.com/TBD54566975/ftl/examples/online-boutique/common/money"

ftl "github.com/TBD54566975/ftl/go-runtime/sdk"
ftl "github.com/TBD54566975/ftl/go-runtime/ftl"
)

type PlaceOrderRequest struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"ftl/builtin"
"ftl/productcatalog"

ftl "github.com/TBD54566975/ftl/go-runtime/sdk"
ftl "github.com/TBD54566975/ftl/go-runtime/ftl"
)

type ListRequest struct {
Expand Down
6 changes: 3 additions & 3 deletions go-runtime/compile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var scaffoldFuncs = scaffolder.FuncMap{
imports["time"] = "stdtime"

case *schema.Optional, *schema.Unit:
imports["github.com/TBD54566975/ftl/go-runtime/sdk"] = ""
imports["github.com/TBD54566975/ftl/go-runtime/ftl"] = ""

default:
}
Expand Down Expand Up @@ -230,10 +230,10 @@ func genType(module *schema.Module, t schema.Type) string {
return "map[" + genType(module, t.Key) + "]" + genType(module, t.Value)

case *schema.Optional:
return "sdk.Option[" + genType(module, t.Type) + "]"
return "ftl.Option[" + genType(module, t.Type) + "]"

case *schema.Unit:
return "sdk.Unit"
return "ftl.Unit"

case *schema.Any:
return "any"
Expand Down

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

6 changes: 3 additions & 3 deletions go-runtime/compile/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
errorIFaceType = once(func() *types.Interface {
return mustLoadRef("builtin", "error").Type().Underlying().(*types.Interface) //nolint:forcetypeassert
})
ftlCallFuncPath = "github.com/TBD54566975/ftl/go-runtime/sdk.Call"
ftlCallFuncPath = "github.com/TBD54566975/ftl/go-runtime/ftl.Call"

aliasFieldTag = "alias"
)
Expand Down Expand Up @@ -462,10 +462,10 @@ func visitType(pctx *parseContext, node ast.Node, tnode types.Type) (schema.Type
case "time.Time":
return &schema.Time{Pos: goPosToSchemaPos(node.Pos())}, nil

case "github.com/TBD54566975/ftl/go-runtime/sdk.Unit":
case "github.com/TBD54566975/ftl/go-runtime/ftl.Unit":
return &schema.Unit{Pos: goPosToSchemaPos(node.Pos())}, nil

case "github.com/TBD54566975/ftl/go-runtime/sdk.Option":
case "github.com/TBD54566975/ftl/go-runtime/ftl.Option":
underlying, err := visitType(pctx, node, named.TypeArgs().At(0))
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions go-runtime/compile/testdata/one/one.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/TBD54566975/ftl/go-runtime/compile/testdata/two"
"github.com/TBD54566975/ftl/go-runtime/sdk"
"github.com/TBD54566975/ftl/go-runtime/ftl"
)

type Nested struct {
Expand All @@ -20,7 +20,7 @@ type Req struct {
Slice []string
Map map[string]string
Nested Nested
Optional sdk.Option[Nested]
Optional ftl.Option[Nested]
Time time.Time
User two.User `alias:"u"`
Bytes []byte
Expand Down
4 changes: 2 additions & 2 deletions go-runtime/compile/testdata/two/two.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package two
import (
"context"

"github.com/TBD54566975/ftl/go-runtime/sdk"
"github.com/TBD54566975/ftl/go-runtime/ftl"
)

type User struct {
Expand All @@ -22,5 +22,5 @@ func Two(ctx context.Context, req Payload[string]) (Payload[string], error) {

//ftl:verb
func CallsTwo(ctx context.Context, req Payload[string]) (Payload[string], error) {
return sdk.Call(ctx, Two, req)
return ftl.Call(ctx, Two, req)
}
10 changes: 5 additions & 5 deletions go-runtime/encoding/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/alecthomas/assert/v2"

. "github.com/TBD54566975/ftl/go-runtime/encoding"
"github.com/TBD54566975/ftl/go-runtime/sdk"
"github.com/TBD54566975/ftl/go-runtime/ftl"
)

func TestMarshal(t *testing.T) {
type inner struct {
FooBar string
}
somePtr := sdk.Some(42)
somePtr := ftl.Some(42)
tests := []struct {
name string
input any
Expand All @@ -28,9 +28,9 @@ func TestMarshal(t *testing.T) {
{name: "Nil", input: struct{ Nil *int }{nil}, expected: `{"nil":null}`},
{name: "Slice", input: struct{ Slice []int }{[]int{1, 2, 3}}, expected: `{"slice":[1,2,3]}`},
{name: "Map", input: struct{ Map map[string]int }{map[string]int{"foo": 42}}, expected: `{"map":{"foo":42}}`},
{name: "Option", input: struct{ Option sdk.Option[int] }{sdk.Some(42)}, expected: `{"option":42}`},
{name: "OptionPtr", input: struct{ Option *sdk.Option[int] }{&somePtr}, expected: `{"option":42}`},
{name: "OptionStruct", input: struct{ Option sdk.Option[inner] }{sdk.Some(inner{"foo"})}, expected: `{"option":{"fooBar":"foo"}}`},
{name: "Option", input: struct{ Option ftl.Option[int] }{ftl.Some(42)}, expected: `{"option":42}`},
{name: "OptionPtr", input: struct{ Option *ftl.Option[int] }{&somePtr}, expected: `{"option":42}`},
{name: "OptionStruct", input: struct{ Option ftl.Option[inner] }{ftl.Some(inner{"foo"})}, expected: `{"option":{"fooBar":"foo"}}`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/sdk/call.go → go-runtime/ftl/call.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions go-runtime/sdk/config.go → go-runtime/ftl/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"encoding/json"
Expand Down Expand Up @@ -49,7 +49,7 @@ func callerModule() string {
panic("failed to get caller")
}
module := details.Name()
if strings.HasPrefix(module, "github.com/TBD54566975/ftl/go-runtime/sdk") {
if strings.HasPrefix(module, "github.com/TBD54566975/ftl/go-runtime/ftl") {
return "testing"
}
if !strings.HasPrefix(module, "ftl/") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"database/sql"
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/sdk/logging.go → go-runtime/ftl/logging.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/sdk/option.go → go-runtime/ftl/option.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//nolint:wrapcheck
package sdk
package ftl

import (
"database/sql"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"database/sql"
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/sdk/secrets.go → go-runtime/ftl/secrets.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/sdk/types.go → go-runtime/ftl/types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sdk
package ftl

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"fmt"

ftl "github.com/TBD54566975/ftl/go-runtime/sdk" // Import the FTL SDK.
"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

type EchoRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/TBD54566975/ftl/backend/common/plugin"
"github.com/TBD54566975/ftl/backend/common/rpc"
"github.com/TBD54566975/ftl/go-runtime/encoding"
sdkgo "github.com/TBD54566975/ftl/go-runtime/sdk"
sdkgo "github.com/TBD54566975/ftl/go-runtime/ftl"
ftlv1 "github.com/TBD54566975/ftl/protos/xyz/block/ftl/v1"
"github.com/TBD54566975/ftl/protos/xyz/block/ftl/v1/ftlv1connect"
)
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/go/database/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package echo
import (
"context"

ftl "github.com/TBD54566975/ftl/go-runtime/sdk" // Import the FTL SDK.
"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

var db = ftl.PostgresDatabase("testdb")
Expand Down
3 changes: 2 additions & 1 deletion integration/testdata/go/externalcalls/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"fmt"

"ftl/echo2"
ftl "github.com/TBD54566975/ftl/go-runtime/sdk" // Import the FTL SDK.

"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

type EchoRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/go/httpingress/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"ftl/builtin"

ftl "github.com/TBD54566975/ftl/go-runtime/sdk" // Import the FTL SDK.
"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

type GetRequest struct {
Expand Down