Skip to content

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.

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
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 force-pushed the jba-flows-server branch from a3be587 to 9c594b1 Compare May 23, 2024 19:38
@jba jba requested review from ianlancetaylor and pavelgj May 23, 2024 19:41
@jba jba merged commit 209e0d3 into main May 23, 2024
@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