Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

Commit a477a51

Browse files
feat: Data persistence using Atlas and SQLBoiler (#86)
1 parent 2c1e40f commit a477a51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4511
-336
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v3
2020
- uses: actions/setup-go@v4
2121
with:
22-
go-version: '1.21.3'
22+
go-version: '1.21.5'
2323
cache: false
2424
- name: golangci-lint
2525
uses: golangci/golangci-lint-action@v3

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ check_pkgx:
2424
all: check_pkgx
2525
pkgx --sync
2626
pkgx killport@latest 7233
27+
sleep 1
2728
pkgx temporal@latest server start-dev &
29+
sleep 2
2830
pkgx task@latest run:all

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ make
3939
```
4040

4141
> [!NOTE]
42-
> Under the hood, we use [pkgx][pkgx] to run Temporal's [dev server][temporal-cli], and Docker to run [Jaeger][jaeger] (a telemetry backend).
42+
>
43+
> Under the hood, we use [pkgx][pkgx] to run Temporal's [dev
44+
> server][temporal-cli], and Docker to run [Jaeger][jaeger] (a telemetry
45+
> backend).
4346
4447
[temporal-cli]: https://github.com/temporalio/cli
4548
[pkgx]: https://pkgx.sh/

Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ includes:
99
taskfile: ./taskfiles/golang.yml
1010
run:
1111
taskfile: ./taskfiles/run.yml
12+
sqlboiler:
13+
taskfile: ./taskfiles/sqlboiler.yml
1214

1315
tasks:
1416
generate:

cmd/saga/start/service/service.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
temporalPB "buf.build/gen/go/kevinmichaelchen/temporalapis/protocolbuffers/go/temporal/v1beta1"
1010
"connectrpc.com/connect"
1111
"github.com/bufbuild/protovalidate-go"
12+
"github.com/google/uuid"
1213
"github.com/sirupsen/logrus"
1314
"go.temporal.io/sdk/client"
1415

@@ -53,10 +54,26 @@ func (s *Service) CreateOnboardingWorkflow(
5354
TaskQueue: saga.CreateLicenseTaskQueue,
5455
}
5556

57+
orgID := uuid.New().String()
58+
profileID := uuid.New().String()
59+
licenseID := uuid.New().String()
60+
5661
args := saga.CreateLicenseInputArgs{
57-
OrgName: req.Msg.GetOrg().GetName(),
58-
ProfileName: req.Msg.GetProfile().GetName(),
59-
LicenseName: "New License",
62+
Org: saga.Org{
63+
ID: orgID,
64+
Name: req.Msg.GetOrg().GetName(),
65+
},
66+
Profile: saga.Profile{
67+
ID: profileID,
68+
FullName: req.Msg.GetProfile().GetFullName(),
69+
OrgID: orgID,
70+
},
71+
License: saga.License{
72+
ID: licenseID,
73+
Start: req.Msg.GetLicense().GetStart().AsTime(),
74+
End: req.Msg.GetLicense().GetEnd().AsTime(),
75+
UserID: profileID,
76+
},
6077
}
6178

6279
workflow, err := temporalClient.ExecuteWorkflow(
@@ -73,6 +90,9 @@ func (s *Service) CreateOnboardingWorkflow(
7390

7491
res := &temporalPB.CreateOnboardingWorkflowResponse{
7592
WorkflowId: workflow.GetID(),
93+
OrgId: orgID,
94+
ProfileId: profileID,
95+
LicenseId: licenseID,
7696
}
7797

7898
out := connect.NewResponse(res)
@@ -83,9 +103,8 @@ func (s *Service) CreateOnboardingWorkflow(
83103

84104
func printResults(args saga.CreateLicenseInputArgs, workflowID, runID string) {
85105
logrus.WithFields(logrus.Fields{
86-
"org_name": args.OrgName,
87-
"profile_name": args.ProfileName,
88-
"license_name": args.LicenseName,
106+
"org_name": args.Org.Name,
107+
"profile_name": args.Profile.FullName,
89108
"temporal.workflow_id": workflowID,
90109
"temporal.run_id": runID,
91110
}).Info("Successfully completed Workflow")

cmd/saga/start/service/validate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestValidate(t *testing.T) {
2929
Name: "Name",
3030
},
3131
Profile: &temporalPB.Profile{
32-
Name: "Name",
32+
FullName: "Name",
3333
},
3434
}
3535
}

cmd/svc/license/app/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
modConnect "github.com/kevinmichaelchen/temporal-saga-grpc/pkg/fxmod/connect"
1313
"github.com/kevinmichaelchen/temporal-saga-grpc/pkg/fxmod/logging"
1414
"github.com/kevinmichaelchen/temporal-saga-grpc/pkg/fxmod/otel"
15+
"github.com/kevinmichaelchen/temporal-saga-grpc/pkg/fxmod/sql"
1516
)
1617

1718
// Module - An FX module for the application.
@@ -38,4 +39,5 @@ var Module = fx.Options(
3839
otel.CreateModule(otel.ModuleOptions{
3940
ServiceName: "license-svc",
4041
}),
42+
sql.Module,
4143
)

cmd/svc/license/app/service/service.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
package service
33

44
import (
5+
"database/sql"
6+
57
"go.uber.org/fx"
68

79
"github.com/kevinmichaelchen/temporal-saga-grpc/cmd/svc/license/service"
@@ -15,6 +17,6 @@ var Module = fx.Module("service",
1517
)
1618

1719
// NewService - Returns a new Service.
18-
func NewService() *service.Service {
19-
return service.NewService()
20+
func NewService(db *sql.DB) *service.Service {
21+
return service.NewService(db)
2022
}

cmd/svc/license/models/boil_queries.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/svc/license/models/boil_table_names.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)