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

[Go] production server #233

Merged
merged 4 commits into from
May 23, 2024
Merged

[Go] production server #233

merged 4 commits into from
May 23, 2024

Conversation

jba
Copy link
Contributor

@jba jba commented May 23, 2024

Implement NewFlowServeMux, which returns an http.ServeMux
that has a route for each defined flow.

Provide convenience functions for using that ServeMux as a server,
and also for selecting which server to use based on the current
development environment.

@jba
Copy link
Contributor Author

jba commented May 23, 2024

@pavelgj WDYT of the API here?

  • StartServer to start a server depending on GENKIT_ENV
  • StartDevServer and StartProdServer if you know what you want
  • NewFlowServeMux to get the prod router piece that has the flow routes, so you can make it part of a larger server.

I know the names don't quite align; do you have suggestions?
(BTW, for the js, I think "flowServer" is better than "flowsServer" because it doesn't have the double 's'.)

Copy link
Contributor

@ianlancetaylor ianlancetaylor left a comment

Choose a reason for hiding this comment

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

This seems to do much more than rename some things. Not clear on what is happening here.

@@ -280,6 +229,189 @@ type listFlowStatesResult struct {
ContinuationToken string `json:"continuationToken"`
}

// Copyright 2024 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this copyright message doing down here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@jba
Copy link
Contributor Author

jba commented May 23, 2024

I tried to do a poor person's CL stack by making two separate commits. It took the message from the first instead of the second. I edited the top comment.

I meant to suggest reviewing the commits separately.

Comment on lines 50 to 60
switch e := currentEnvironment(); e {
case EnvironmentDev:
return StartDevServer(addr)
case EnvironmentProd:
return StartProdServer(addr)
default:
return fmt.Errorf("unknown environment value: %q", e)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

the idea is that StartProdServer should always start (regardless of currentEnvironment()), even in dev mode. Dev (reflection API) server should only run in dev mode.

So the logic here should be:

if currentEnvironment() == EnvironmentDev {
  StartDevServer(addr)
}
StartProdServer(addr)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. I was going about this wrong.
I removed StartServer and changed StartProdServer to StartFlowServer.
When you call StartFlowServer, you'll get a dev server too.

jba added 4 commits May 23, 2024 15:35
This commit renames dev_server* to servers*.
Implement NewFlowServeMux, which returns an http.ServeMux
that has a route for each defined flow.

Provide convenience functions for using that ServeMux as a server,
and also for selecting which server to use based on the current
development environment.
@jba jba merged commit 209e0d3 into main May 23, 2024
5 checks passed
@jba jba deleted the jba-flows-server branch May 23, 2024 20:19
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