Skip to content

Commit 299e4dd

Browse files
Merge branch 'main' into fix_redis_diag_panic
2 parents 9fb6a46 + 46a336c commit 299e4dd

Some content is hidden

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

61 files changed

+1381
-659
lines changed

.github/workflows/bench.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ jobs:
6868
- name: Run benchmarks
6969
run: |
7070
echo "## Default run" > benchmark.md
71-
hyperfine --warmup 1 --export-markdown bench-mysql.md -n 'mysql-main' './bench-main -runs 2 -backend mysql' -n 'mysql-pr' './bench-pr -runs 2 -backend mysql'
72-
hyperfine --warmup 1 --export-markdown bench-sqlite.md -n 'sqlite-main' './bench-main -runs 2 -backend sqlite' -n 'sqlite-pr' './bench-pr -runs 2 -backend sqlite'
73-
hyperfine --warmup 1 --export-markdown bench-redis.md -n 'redis-main' './bench-main -runs 2 -backend redis' -n 'redis-pr' './bench-pr -runs 2 -backend redis'
71+
hyperfine --show-output --warmup 1 --export-markdown bench-mysql.md -n 'mysql-main' './bench-main -runs 2 -backend mysql' -n 'mysql-pr' './bench-pr -runs 2 -backend mysql'
72+
hyperfine --show-output --warmup 1 --export-markdown bench-sqlite.md -n 'sqlite-main' './bench-main -runs 2 -backend sqlite' -n 'sqlite-pr' './bench-pr -runs 2 -backend sqlite'
73+
hyperfine --show-output --warmup 1 --export-markdown bench-redis.md -n 'redis-main' './bench-main -runs 2 -backend redis' -n 'redis-pr' './bench-pr -runs 2 -backend redis'
7474
cat bench-mysql.md >> benchmark.md
7575
echo $'\n' >> benchmark.md
7676
cat bench-sqlite.md >> benchmark.md
@@ -79,30 +79,29 @@ jobs:
7979
8080
- name: Run large benchmarks
8181
if: github.event.issue.pull_request && contains(github.event.comment.body, '!large')
82-
# hyperfine --show-output --warmup 1 --export-markdown bench-mysql-l.md -n 'mysql-main' './bench-main -resultsize 1000000 -runs 2 -backend mysql -timeout 240s' -n 'mysql-pr' './bench-pr -resultsize 1000000 -runs 2 -backend mysql -timeout 240s'
83-
# hyperfine --show-output --warmup 1 --export-markdown bench-sqlite-l.md -n 'sqlite-main' './bench-main -resultsize 1000000 -runs 2 -backend sqlite -timeout 240s' -n 'sqlite-pr' './bench-pr -resultsize 1000000 -runs 2 -backend sqlite -timeout 240s'
84-
# cat bench-mysql-l.md >> benchmark.md
85-
# echo $'\n' >> benchmark.md
86-
# cat bench-sqlite-l.md >> benchmark.md
87-
# echo $'\n' >> benchmark.md
8882
run: |
8983
echo "## Large payload run (1MB)" >> benchmark.md
90-
hyperfine --show-output --warmup 1 --export-markdown bench-redis-l.md -n 'redis-main' './bench-main -resultsize 1000000 -runs 2 -backend redis -timeout 240s' -n 'redis-pr' './bench-pr -resultsize 1000000 -runs 2 -backend redis -timeout 240s'
84+
hyperfine --show-output --warmup 1 --export-markdown bench-mysql-l.md -n 'mysql-main' './bench-main -resultsize 1000000 -activities 10 -runs 2 -backend mysql -timeout 240s' -n 'mysql-pr' './bench-pr -resultsize 1000000 -activities 10 -runs 2 -backend mysql -timeout 240s'
85+
hyperfine --show-output --warmup 1 --export-markdown bench-sqlite-l.md -n 'sqlite-main' './bench-main -resultsize 1000000 -activities 10 -runs 2 -backend sqlite -timeout 240s' -n 'sqlite-pr' './bench-pr -resultsize 1000000 -activities 10 -runs 2 -backend sqlite -timeout 240s'
86+
hyperfine --show-output --warmup 1 --export-markdown bench-redis-l.md -n 'redis-main' './bench-main -resultsize 1000000 -activities 10 -runs 2 -backend redis -timeout 240s' -n 'redis-pr' './bench-pr -resultsize 1000000 -activities 10 -runs 2 -backend redis -timeout 240s'
87+
cat bench-mysql-l.md >> benchmark.md
88+
echo $'\n' >> benchmark.md
89+
cat bench-sqlite-l.md >> benchmark.md
90+
echo $'\n' >> benchmark.md
9191
cat bench-redis-l.md >> benchmark.md
9292
93-
9493
- name: Run very large benchmarks
9594
if: github.event.issue.pull_request && contains(github.event.comment.body, '!verylarge')
96-
# hyperfine --show-output --warmup 1 --export-markdown bench-mysql-l.md -n 'mysql-main' './bench-main -resultsize 5000000 -runs 2 -backend mysql -timeout 240s' -n 'mysql-pr' './bench-pr -resultsize 5000000 -runs 2 -backend mysql -timeout 240s'
97-
# hyperfine --show-output --warmup 1 --export-markdown bench-sqlite-l.md -n 'sqlite-main' './bench-main -resultsize 5000000 -runs 2 -backend sqlite -timeout 240s' -n 'sqlite-pr' './bench-pr -resultsize 5000000 -runs 2 -backend sqlite -timeout 240s'
98-
# cat bench-mysql-l.md >> benchmark.md
99-
# echo $'\n' >> benchmark.md
100-
# cat bench-sqlite-l.md >> benchmark.md
101-
# echo $'\n' >> benchmark.md
10295
run: |
103-
echo "## Large payload run (5MB)" >> benchmark.md
104-
hyperfine --show-output --warmup 1 --export-markdown bench-redis-l.md -n 'redis-main' './bench-main -resultsize 5000000 -runs 2 -backend redis -timeout 240s' -n 'redis-pr' './bench-pr -resultsize 5000000 -runs 2 -backend redis -timeout 240s'
105-
cat bench-redis-l.md >> benchmark.md
96+
echo "## Very Large payload run (5MB)" >> benchmark.md
97+
hyperfine --show-output --warmup 1 --export-markdown bench-mysql-vl.md -n 'mysql-main' './bench-main -resultsize 5000000 -runs 2 -backend mysql -timeout 240s' -n 'mysql-pr' './bench-pr -resultsize 5000000 -runs 2 -backend mysql -timeout 240s'
98+
hyperfine --show-output --warmup 1 --export-markdown bench-sqlite-vl.md -n 'sqlite-main' './bench-main -resultsize 5000000 -runs 2 -backend sqlite -timeout 240s' -n 'sqlite-pr' './bench-pr -resultsize 5000000 -runs 2 -backend sqlite -timeout 240s'
99+
hyperfine --show-output --warmup 1 --export-markdown bench-redis-vl.md -n 'redis-main' './bench-main -resultsize 5000000 -runs 2 -backend redis -timeout 240s' -n 'redis-pr' './bench-pr -resultsize 5000000 -runs 2 -backend redis -timeout 240s'
100+
cat bench-mysql-vl.md >> benchmark.md
101+
echo $'\n' >> benchmark.md
102+
cat bench-sqlite-vl.md >> benchmark.md
103+
echo $'\n' >> benchmark.md
104+
cat bench-redis-vl.md >> benchmark.md
106105
107106
- name: Write a new comment
108107
uses: peter-evans/create-or-update-comment@v2

.github/workflows/go.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
3636
3737
- name: Test Summary
38-
uses: test-summary/action@v1
38+
uses: test-summary/action@v2
3939
with:
4040
paths: |
4141
${{ github.workspace }}/report.xml
@@ -69,7 +69,7 @@ jobs:
6969
go test -timeout 120s -race -count 1 -v github.com/cschleiden/go-workflows/backend/redis 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
7070
7171
- name: Test Summary
72-
uses: test-summary/action@v1
72+
uses: test-summary/action@v2
7373
with:
7474
paths: |
7575
${{ github.workspace }}/report.xml
@@ -95,7 +95,7 @@ jobs:
9595
go test -timeout 120s -race -count 1 -v github.com/cschleiden/go-workflows/backend/sqlite 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
9696
9797
- name: Test Summary
98-
uses: test-summary/action@v1
98+
uses: test-summary/action@v2
9999
with:
100100
paths: |
101101
${{ github.workspace }}/report.xml
@@ -124,7 +124,7 @@ jobs:
124124
go test -timeout 120s -race -count 1 -v github.com/cschleiden/go-workflows/backend/mysql 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
125125
126126
- name: Test Summary
127-
uses: test-summary/action@v1
127+
uses: test-summary/action@v2
128128
with:
129129
paths: |
130130
${{ github.workspace }}/report.xml

.vscode/settings.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
{
22
// Some integration tests take quite long to run, increase the overall limit for now
33
"go.testFlags": ["-timeout", "120s", "-race", "-count", "1"], // , "-short"],
4-
"workbench.colorCustomizations": {
5-
"titleBar.activeBackground": "#007fff",
6-
"titleBar.activeForeground": "#e7e7e7",
7-
"titleBar.inactiveBackground": "#007fff99",
8-
"titleBar.inactiveForeground": "#e7e7e799",
9-
},
10-
114
"files.exclude": {
125
"**/.git": true,
136
"**/.svn": true,
@@ -17,14 +10,9 @@
1710
"**/Thumbs.db": true,
1811
"**/vendor": true,
1912
},
20-
"gopls": {
21-
"ui.semanticTokens": true,
22-
},
2313
"github-actions.workflows.pinned.workflows": [
2414
".github/workflows/go.yml"
2515
],
2616
"go.testExplorer.showDynamicSubtestsInEditor": true,
2717
"go.lintTool": "golangci-lint",
28-
"todo-tree.tree.showBadges": true,
29-
"todo-tree.tree.disableCompactFolders": true
3018
}

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ For all backends, for now the initial schema is applied upon first usage. In the
125125

126126
#### Sqlite
127127

128-
The Sqlite backend implementation supports two different modes, in-memory and on-disk.
128+
The Sqlite backend implementation supports two different modes, in-memory and on-disk:
129129

130130
* In-memory:
131131
```go
@@ -136,12 +136,16 @@ The Sqlite backend implementation supports two different modes, in-memory and on
136136
b := sqlite.NewSqliteBackend("simple.sqlite")
137137
```
138138

139+
By default the schema is automatically created/migrations are automatically applied. Use `WithApplyMigrations(false)` to disable this behavior.
140+
139141
#### MySql
140142

141143
```go
142144
b := mysql.NewMysqlBackend("localhost", 3306, "root", "SqlPassw0rd", "simple")
143145
```
144146

147+
By default the schema is automatically created/migrations are automatically applied. Use `WithApplyMigrations(false)` to disable this behavior.
148+
145149
#### Redis
146150

147151
```go

backend/backend.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,7 @@ type Backend interface {
8383

8484
// ContextPropagators returns the configured context propagators for the backend
8585
ContextPropagators() []workflow.ContextPropagator
86+
87+
// Close closes any underlying resources
88+
Close() error
8689
}

backend/mock_Backend.go

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

backend/monoprocess/monoprocess_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/cschleiden/go-workflows/backend/history"
1010
"github.com/cschleiden/go-workflows/backend/sqlite"
1111
"github.com/cschleiden/go-workflows/backend/test"
12+
"github.com/stretchr/testify/require"
1213
)
1314

1415
func Test_MonoprocessBackend(t *testing.T) {
@@ -20,8 +21,10 @@ func Test_MonoprocessBackend(t *testing.T) {
2021
// Disable sticky workflow behavior for the test execution
2122
options = append(options, backend.WithStickyTimeout(0))
2223

23-
return NewMonoprocessBackend(sqlite.NewInMemoryBackend(options...))
24-
}, nil)
24+
return NewMonoprocessBackend(sqlite.NewInMemoryBackend(sqlite.WithBackendOptions(options...)))
25+
}, func(b test.TestBackend) {
26+
require.NoError(t, b.Close())
27+
})
2528
}
2629

2730
func Test_EndToEndMonoprocessBackend(t *testing.T) {
@@ -33,7 +36,7 @@ func Test_EndToEndMonoprocessBackend(t *testing.T) {
3336
// Disable sticky workflow behavior for the test execution
3437
options = append(options, backend.WithStickyTimeout(0))
3538

36-
return NewMonoprocessBackend(sqlite.NewInMemoryBackend(options...))
39+
return NewMonoprocessBackend(sqlite.NewInMemoryBackend(sqlite.WithBackendOptions(options...)))
3740
}, nil)
3841
}
3942

@@ -43,5 +46,6 @@ func (b *monoprocessBackend) GetFutureEvents(ctx context.Context) ([]*history.Ev
4346
if testBackend, ok := b.Backend.(test.TestBackend); ok {
4447
return testBackend.GetFutureEvents(ctx)
4548
}
49+
4650
return nil, errors.New("not implemented")
4751
}

backend/mysql/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Sqlite backend
2+
3+
## Adding a migration
4+
5+
1. Install [golang-migrate/migrate](https://www.github.com/golang-migrate/migrate)
6+
1. ```bash
7+
migrate create -ext sql -dir ./db/migrations -seq <name>
8+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DROP TABLE IF EXISTS `instances`;
2+
DROP TABLE IF EXISTS `pending_events`;
3+
DROP TABLE IF EXISTS `history`;
4+
DROP TABLE IF EXISTS `activities`;
File renamed without changes.

0 commit comments

Comments
 (0)