Skip to content

Commit

Permalink
chore: convert database runtime to a oneof to support more connection…
Browse files Browse the repository at this point in the history
… methods in the future (#3499)

The idea is to have the different ways to do DB connections in the
DatabaseRuntime, and then to use that in DB proxies to establish the
connection.
  • Loading branch information
jvmakine authored Nov 25, 2024
1 parent d4720e4 commit 1abde9c
Show file tree
Hide file tree
Showing 13 changed files with 1,270 additions and 1,061 deletions.
10 changes: 7 additions & 3 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,13 @@ func (s *Service) GetModuleContext(ctx context.Context, req *connect.Request[ftl
dbTypes[db.Name] = dbType
// TODO: Move the DSN resolution to the runtime once MySQL proxy is working
if db.Runtime != nil && dbType == modulecontext.DBTypeMySQL {
databases[db.Name] = modulecontext.Database{
DSN: db.Runtime.DSN,
DBType: dbType,
if dsn, ok := db.Runtime.(*schema.DSNDatabaseRuntime); ok {
databases[db.Name] = modulecontext.Database{
DSN: dsn.DSN,
DBType: dbType,
}
} else {
return connect.NewError(connect.CodeInternal, fmt.Errorf("unknown database runtime type: %T", db.Runtime))
}
}
}
Expand Down
Loading

0 comments on commit 1abde9c

Please sign in to comment.