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

feat: inject configs and secrets #3454

Open
wants to merge 1 commit into
base: worstell/20241114-pubsub-injection
Choose a base branch
from
Open
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 backend/controller/admin/testdata/go/dischema/dischema.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

var defaultUser = ftl.Config[string]("defaultUser")
type DefaultUser = ftl.Config[string]

type EchoRequest struct {
Name ftl.Option[string] `json:"name"`
Expand All @@ -18,6 +18,6 @@ type EchoResponse struct {
}

//ftl:verb
func Echo(ctx context.Context, req EchoRequest) (EchoResponse, error) {
func Echo(ctx context.Context, req EchoRequest, defaultUser DefaultUser) (EchoResponse, error) {
return EchoResponse{Message: fmt.Sprintf("Hello, %s!", req.Name.Default(defaultUser.Get(ctx)))}, nil
}
15 changes: 15 additions & 0 deletions backend/controller/admin/testdata/go/dischema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ require (
connectrpc.com/grpcreflect v1.2.0 // indirect
connectrpc.com/otelconnect v0.7.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/XSAM/otelsql v0.35.0 // indirect
github.com/alecthomas/atomic v0.1.0-alpha2 // indirect
github.com/alecthomas/concurrency v0.0.2 // indirect
github.com/alecthomas/kong v1.4.0 // indirect
github.com/alecthomas/participle/v2 v2.1.1 // indirect
github.com/alecthomas/types v0.17.0 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/hashicorp/cronexpr v1.1.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
Expand All @@ -35,15 +40,25 @@ require (
github.com/swaggest/refl v1.3.0 // indirect
github.com/zalando/go-keyring v0.2.6 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.2 // indirect
)

Expand Down
26 changes: 26 additions & 0 deletions backend/controller/admin/testdata/go/dischema/go.sum

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

19 changes: 19 additions & 0 deletions backend/controller/admin/testdata/go/dischema/types.ftl.go

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

4 changes: 2 additions & 2 deletions examples/go/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/TBD54566975/ftl/go-runtime/ftl"
)

var defaultName = ftl.Config[string]("default")
type DefaultName = ftl.Config[string]

// An echo request.
type EchoRequest struct {
Expand All @@ -24,7 +24,7 @@ type EchoResponse struct {
// Echo returns a greeting with the current time.
//
//ftl:verb export
func Echo(ctx context.Context, req EchoRequest, tc time.TimeClient) (EchoResponse, error) {
func Echo(ctx context.Context, req EchoRequest, tc time.TimeClient, defaultName DefaultName) (EchoResponse, error) {
tresp, err := tc(ctx, time.TimeRequest{})
if err != nil {
return EchoResponse{}, err
Expand Down
1 change: 1 addition & 0 deletions examples/go/echo/types.ftl.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ func init() {
{{- with getTopicHandle . }}
server.TopicHandle[{{.EventType.TypeName}}]("{{.Module}}", "{{.Name}}"),
{{- end }}
{{- with getConfigHandle . }}
server.Config[{{.Type.TypeName}}]("{{.Module}}", "{{.Name}}"),
{{- end }}
{{- with getSecretHandle . }}
server.Secret[{{.Type.TypeName}}]("{{.Module}}", "{{.Name}}"),
{{- end }}
{{- end}}
),
{{- end}}
Expand Down
6 changes: 6 additions & 0 deletions go-runtime/compile/build-template/types.ftl.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func init() {
{{- with getTopicHandle . }}
server.TopicHandle[{{ trimModuleQualifier $moduleName .EventType.TypeName }}]("{{.Module}}", "{{.Name}}"),
{{- end }}
{{- with getConfigHandle . }}
server.Config[{{ trimModuleQualifier $moduleName .Type.TypeName }}]("{{.Module}}", "{{.Name}}"),
{{- end }}
{{- with getSecretHandle . }}
server.Secret[{{ trimModuleQualifier $moduleName .Type.TypeName }}]("{{.Module}}", "{{.Name}}"),
{{- end }}
{{- end}}
),
{{- end}}
Expand Down
Loading
Loading