From 24c631a1d638c3bd602c30302df2b32d90eb6f12 Mon Sep 17 00:00:00 2001 From: renanbastos93 Date: Sat, 8 Jun 2024 15:09:23 -0300 Subject: [PATCH 1/3] feat: added shutdown method in app template --- templates/files/component.go.tpl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/templates/files/component.go.tpl b/templates/files/component.go.tpl index 02d74ff..8b2f2ab 100644 --- a/templates/files/component.go.tpl +++ b/templates/files/component.go.tpl @@ -30,7 +30,8 @@ type Config struct { type implapp struct { weaver.Implements[Component] weaver.WithConfig[Config] - db *store.Queries + dbConn *sql.DB + db *store.Queries } func (e *implapp) Init(ctx context.Context) error { @@ -48,6 +49,12 @@ func (e *implapp) Init(ctx context.Context) error { return nil } + +func (e *implapp) Shutdown(ctx context.Context) error { + // TODO: create your logic to shutdown the component + return e.dbConn.Close() +} + func (e implapp) AllExamples(ctx context.Context) (out AllExamplesOut, err error) { examples, err := e.db.ListExamples(ctx) if err != nil { From f30b015082284303d1558a27b237df867ef4f26f Mon Sep 17 00:00:00 2001 From: renanbastos93 Date: Sat, 8 Jun 2024 15:09:58 -0300 Subject: [PATCH 2/3] chore: update version to v0.5.3 --- internal/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/version.go b/internal/version.go index 50f2efa..d136b28 100644 --- a/internal/version.go +++ b/internal/version.go @@ -7,7 +7,7 @@ import ( "strings" ) -const Version = "v0.5.2" +const Version = "v0.5.3" func ValidateLatestVersion() { cmd := exec.Command("go", "list", "-m", "github.com/renanbastos93/boneless@latest") From 69142d4155ea4a3bbbb7392b27cb3e02365e2f21 Mon Sep 17 00:00:00 2001 From: renanbastos93 Date: Sat, 8 Jun 2024 15:12:54 -0300 Subject: [PATCH 3/3] feat: attr database conn in Init --- templates/files/component.go.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/files/component.go.tpl b/templates/files/component.go.tpl index 8b2f2ab..c85bdab 100644 --- a/templates/files/component.go.tpl +++ b/templates/files/component.go.tpl @@ -45,6 +45,7 @@ func (e *implapp) Init(ctx context.Context) error { return fmt.Errorf("failed to ping: %w", err) } + e.dbConn = db e.db = store.New(db) return nil }