Skip to content

Commit

Permalink
fix: use @SQLDatasource declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Mar 4, 2025
1 parent bcffdad commit e65c812
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion internal/integration/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
)

const dumpPath = "/tmp/ftl-kube-report"
const appDumpPatch = "/tmp/ftl-test-app"

var RedPandaBrokers = []string{"127.0.0.1:19092"}

Expand Down Expand Up @@ -363,7 +364,6 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
kubeClient: optional.Ptr(kubeClient),
}
defer dumpKubePods(ctx, ic.kubeClient, ic.kubeNamespace)

if opts.startController || opts.kube {
ic.Admin = admin
ic.Schema = schema
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package xyz.block.ftl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotation to specify a SQL datasource.
*
* This can be added anywhere in your application, but it is recommended to add it to a package-info.java file
* at the root of your package hierarchy.
* This can be added anywhere in your application.
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.PACKAGE, ElementType.TYPE })
public @interface SQLDatasource {
/**
* The name of the datasource.
Expand Down
14 changes: 7 additions & 7 deletions jvm-runtime/jvm_hot_reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ func TestLifecycleJVM(t *testing.T) {
in.Call("echo", "hello", map[string]string{"name": "Bob"}, func(t testing.TB, response map[string]string) {
assert.Equal(t, "Bye, Bob!", response["message"])
}),
// Now lets add a database, add the ftl config
in.EditFile("echo", func(content []byte) []byte {
return []byte(`
quarkus.datasource.testdb.db-kind=postgresql
quarkus.hibernate-orm.datasource=testdb
`)
}, "src/main/resources/application.properties"),
// Now let's add the DB
in.IfLanguage("java", in.EditFile("echo", func(content []byte) []byte {
return []byte(strings.ReplaceAll(string(content), "@Export", "@Export\n\n@SQLDatasource(name = \"testdb\", type = SQLDatabaseType.POSTGRESQL)"))
}, "src/main/java/ftl/echo/Echo.java")),
in.IfLanguage("kotlin", in.EditFile("echo", func(content []byte) []byte {
return []byte(strings.ReplaceAll(string(content), "@Export", "@Export\n\n@SQLDatasource(name = \"testdb\", type = SQLDatabaseType.POSTGRESQL)"))
}, "src/main/kotlin/ftl/echo/Echo.kt")),

// Create a new datasource
in.Exec("ftl", "postgres", "new", "echo.testdb"),
Expand Down
7 changes: 5 additions & 2 deletions jvm-runtime/plugin/common/jvmcommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,11 @@ func (s *Service) runQuarkusDev(parentCtx context.Context, stream *connect.Serve
case bc := <-events:
logger.Debugf("Build context updated")
buildCtx = bc.buildCtx

result, err := client.Reload(ctx, connect.NewRequest(&hotreloadpb.ReloadRequest{Force: true}))
if err != nil {
return fmt.Errorf("failed to invoke hot reload for build context update %w", err)
logger.Errorf(err, "failed to invoke hot reload for build context update")
continue
}
reloadEvents <- &buildResult{state: result.Msg.GetState(), forceReload: true, buildContextUpdated: true, failed: result.Msg.Failed}
case <-fileEvents:
Expand All @@ -475,7 +477,8 @@ func (s *Service) runQuarkusDev(parentCtx context.Context, stream *connect.Serve
changed := false
result, err := client.Reload(ctx, connect.NewRequest(&hotreloadpb.ReloadRequest{Force: true}))
if err != nil {
return fmt.Errorf("failed to invoke hot reload for build context update %w", err)
logger.Errorf(err, "failed to invoke hot reload for file update")
continue
}
reloadEvents <- &buildResult{state: result.Msg.GetState(), forceReload: changed, failed: result.Msg.Failed}
case <-ctx.Done():
Expand Down

0 comments on commit e65c812

Please sign in to comment.