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: support injected verb clients in Go #2828

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

worstell
Copy link
Contributor

@worstell worstell commented Sep 26, 2024

https://hackmd.io/OULeRFQQQvaMURysN27eEw

only the TestLifecycle integration test is updated with the new approach in this PR, to demonstrate that both old and new verb call strategies are still functional. will remove other usages of ftl.Call(...) to follow

  • generates <Verb>Client signatures in external stubs and (local) signatures in types.ftl.go
  • generates resource registrations in main.go and types.ftl.go, e.g. "providers" for verb clients
    -go-runtime/build.go changes accompanying the above^ bunch of stuff to get imports working now that we're generating full verb request/response types rather than just function references
  • updates go-runtime/server.go to inject the registered providers when processing an inbound call

#2641

@worstell worstell requested review from a team and gak and removed request for a team September 26, 2024 01:00
This was referenced Sep 26, 2024
Copy link
Contributor

@gak gak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic 🪄

@worstell worstell force-pushed the worstell/20240925-inject-verbs-go-trimmed branch 2 times, most recently from 5fe4861 to a48563b Compare September 26, 2024 01:57
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looking good!

@@ -24,8 +24,8 @@ type EchoResponse struct {
// Echo returns a greeting with the current time.
//
//ftl:verb
func Echo(ctx context.Context, req EchoRequest) (EchoResponse, error) {
tresp, err := ftl.Call(ctx, time.Time, time.TimeRequest{})
func Echo(ctx context.Context, req EchoRequest, tc time.TimeClient) (EchoResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@@ -18,7 +18,7 @@ type EchoResponse struct {
}

//ftl:verb
func Echo(ctx context.Context, req EchoRequest) (EchoResponse, error) {
ftl.Call(ctx, other.Echo, other.EchoRequest{})
func Echo(ctx context.Context, req EchoRequest, oc other.EchoClient) (EchoResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know which parameter is the request? Must it always be the 2nd?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this implementation yes, though maybe it could be inferred? the first non-resource-typed param (where verb clients are functions and other resources are known types, e.g. ftl.PostgresDatabase etc.) we encounter

maybe worth landing the other resource types first and then revisiting this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current approach allows a request as the 2nd parameter, optionally. if it's not there we just start consuming resources

@worstell worstell force-pushed the worstell/20240925-inject-verbs-go-trimmed branch 6 times, most recently from c7c5864 to 06a20eb Compare September 26, 2024 21:58
@worstell worstell force-pushed the worstell/20240925-inject-verbs-go-trimmed branch from 775cc98 to 54b239d Compare September 26, 2024 22:05
@worstell worstell merged commit ef6056f into main Sep 26, 2024
91 checks passed
@worstell worstell deleted the worstell/20240925-inject-verbs-go-trimmed branch September 26, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants