-
Notifications
You must be signed in to change notification settings - Fork 8
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: module context over gRPC #1311
Conversation
d0b529d
to
8a62999
Compare
8a62999
to
56866f3
Compare
4d4dbc5
to
3232724
Compare
Smaller PR for this: #1311 Just includes protobuf changes
95786d2
to
ae2b543
Compare
common/modulecontext/builder.go
Outdated
@@ -0,0 +1,254 @@ | |||
package modulecontext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments to the public functions/types in here.
common/modulecontext/builder.go
Outdated
return "", fmt.Errorf("missing environment variable %q", r.name) | ||
} | ||
return value, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builder feels like a lot of machinery to do what seems like it should be fairly straightforward? Currently there's only a config manager, a secret manager, and DB envars. Can all this code just be a single function that takes those and outputs a ModuleContext?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this to just a helper function in the controller packager rather than using modulecontext.
It's in a separate file to avoid bloating controller.go more
@@ -0,0 +1,96 @@ | |||
package modulecontext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's too much mixing of concerns in this package - it is used both on the server side and the client side. That needs to be split out - the server should be very straightforward, just converting state to the proto and sending it, while the client should be most of what is in this package now, with any server-side code removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh agreed.
Simplified it a lot after removing modulecontext from the serverside, and removing the difference between global / non global.
There might be use still for data vs value when we have testing, but that's no longer in this PR anyway, so I've simplified that away as well.
f65f327
to
1929079
Compare
b290154
to
7cff44e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more minor comments, but overall LGTM.
// Propagate to runner processes. | ||
// TODO: This is a bit of a hack until we get proper configuration | ||
// management through the Controller. | ||
os.Setenv("FTL_CONFIG", strings.Join(projectconfig.ConfigPaths(cli.ConfigFlag), ",")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice!
common/modulecontext/builder.go
Outdated
} | ||
} | ||
|
||
func (b *Builder) Build(ctx context.Context) (*ModuleContext, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given there are now no "builder" methods, I'd just make this a single global function modulecontext.FromProto() (*ModuleContext, error)
and remove anything Builder related as it seems like an unnecessary abstraction for now. We can revisit once we get around to fleshing out the testing story.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved the builder to the test PR
go-runtime/ftl/database.go
Outdated
// Get returns the sql db connection for the database. | ||
func (d Database) Get(ctx context.Context) *sql.DB { | ||
provider := modulecontext.DBProviderFromContext(ctx) | ||
db, err := provider.GetDB(d.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice I like this.
5d66e67
to
30da785
Compare
Doc: https://hackmd.io/@ftl/SyynEK2eC
Other PRs
Changes:
ftl.PostgresDatabase(name string)
now returns a handler, withGet()
needing to be called to get*sql.DB
configuration.MutableProvider
andconfiguration.Resolver
. This allows us to have a backing store for configs and secrets forModuleContext
which shares the same behaviour for (un)marshalling json.configuration.Manager
now has raw data versions ofGet()
andSet()
calledGetData()
andSetData()
which expose the features without needing unnecessary conversion steps. This helps when moving values between configuration managers directly or over gRPC.