Skip to content

Commit a2080bb

Browse files
authored
WIP
1 parent a5217e1 commit a2080bb

21 files changed

+698
-16728
lines changed

backend/sqlite/diagnostics.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package sqlite
2+
3+
import (
4+
"context"
5+
"database/sql"
6+
"time"
7+
8+
"github.com/cschleiden/go-workflows/backend"
9+
"github.com/cschleiden/go-workflows/internal/core"
10+
"github.com/cschleiden/go-workflows/web"
11+
)
12+
13+
func (sb *sqliteBackend) GetWorkflowInstances(ctx context.Context, afterInstanceID string, count int) ([]*web.WorkflowInstanceRef, error) {
14+
tx, err := sb.db.BeginTx(ctx, nil)
15+
if err != nil {
16+
return nil, err
17+
}
18+
defer tx.Rollback()
19+
20+
rows, err := tx.QueryContext(
21+
ctx,
22+
"SELECT id, execution_id, created_at, completed_at FROM instances WHERE id > ? ORDER BY created_at DESC LIMIT ?",
23+
afterInstanceID,
24+
count,
25+
)
26+
if err != nil {
27+
return nil, err
28+
}
29+
30+
var instances []*web.WorkflowInstanceRef
31+
32+
for rows.Next() {
33+
var id, executionID string
34+
var createdAt time.Time
35+
var completedAt *time.Time
36+
err = rows.Scan(&id, &executionID, &createdAt, &completedAt)
37+
if err != nil {
38+
return nil, err
39+
}
40+
41+
var state backend.WorkflowState
42+
if completedAt != nil {
43+
state = backend.WorkflowStateFinished
44+
}
45+
46+
instances = append(instances, &web.WorkflowInstanceRef{
47+
Instance: core.NewWorkflowInstance(id, executionID),
48+
CreatedAt: createdAt,
49+
CompletedAt: completedAt,
50+
State: state,
51+
})
52+
}
53+
54+
return instances, nil
55+
}
56+
57+
func (sb *sqliteBackend) GetWorkflowInstance(ctx context.Context, instanceID string) (*web.WorkflowInstanceRef, error) {
58+
tx, err := sb.db.BeginTx(ctx, nil)
59+
if err != nil {
60+
return nil, err
61+
}
62+
defer tx.Rollback()
63+
64+
res := tx.QueryRowContext(ctx, "SELECT id, execution_id, created_at, completed_at FROM instances WHERE id = ?", instanceID)
65+
66+
var id, executionID string
67+
var createdAt time.Time
68+
var completedAt *time.Time
69+
70+
err = res.Scan(&id, &executionID, &createdAt, &completedAt)
71+
if err != nil {
72+
if err == sql.ErrNoRows {
73+
return nil, nil
74+
}
75+
76+
return nil, err
77+
}
78+
79+
var state backend.WorkflowState
80+
if completedAt != nil {
81+
state = backend.WorkflowStateFinished
82+
}
83+
84+
return &web.WorkflowInstanceRef{
85+
Instance: core.NewWorkflowInstance(id, executionID),
86+
CreatedAt: createdAt,
87+
CompletedAt: completedAt,
88+
State: state,
89+
}, nil
90+
}

backend/sqlite/web.go

Lines changed: 0 additions & 34 deletions
This file was deleted.

internal/history/history.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,25 @@ func (et EventType) String() string {
8686

8787
type Event struct {
8888
// ID is a unique identifier for this event
89-
ID string
89+
ID string `json:"id,omitempty"`
9090

9191
// SequenceID is a monotonically increasing sequence number this event. It's only set for events that have
9292
// been executed and are in the history
93-
SequenceID int64
93+
SequenceID int64 `json:"sid,omitempty"`
9494

95-
Type EventType
95+
Type EventType `json:"t,omitempty"`
9696

97-
Timestamp time.Time
97+
Timestamp time.Time `json:"ts,omitempty"`
9898

9999
// ScheduleEventID is used to correlate events belonging together
100100
// For example, if an activity is scheduled, ScheduleEventID of the schedule event and the
101101
// completion/failure event are the same.
102-
ScheduleEventID int64
102+
ScheduleEventID int64 `json:"seid,omitempty"`
103103

104104
// Attributes are event type specific attributes
105-
Attributes interface{}
105+
Attributes interface{} `json:"attr,omitempty"`
106106

107-
VisibleAt *time.Time
107+
VisibleAt *time.Time `json:"vat,omitempty"`
108108
}
109109

110110
func (e Event) String() string {

web/app/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/coverage
1010

1111
# production
12-
/build
12+
# /build
1313

1414
# misc
1515
.DS_Store

web/app/build/asset-manifest.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"files": {
3+
"main.css": "/static/css/main.8b0db0ad.css",
4+
"main.js": "/static/js/main.ca3c34f0.js",
5+
"index.html": "/index.html",
6+
"main.8b0db0ad.css.map": "/static/css/main.8b0db0ad.css.map",
7+
"main.ca3c34f0.js.map": "/static/js/main.ca3c34f0.js.map"
8+
},
9+
"entrypoints": [
10+
"static/css/main.8b0db0ad.css",
11+
"static/js/main.ca3c34f0.js"
12+
]
13+
}

web/app/build/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>go-workflows</title><script defer="defer" src="/static/js/main.ca3c34f0.js"></script><link href="/static/css/main.8b0db0ad.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

web/app/build/static/css/main.8b0db0ad.css

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

web/app/build/static/css/main.8b0db0ad.css.map

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

web/app/build/static/js/main.ca3c34f0.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*!
2+
Copyright (c) 2018 Jed Watson.
3+
Licensed under the MIT License (MIT), see
4+
http://jedwatson.github.io/classnames
5+
*/
6+
7+
/**
8+
* @license React
9+
* react-dom.production.min.js
10+
*
11+
* Copyright (c) Facebook, Inc. and its affiliates.
12+
*
13+
* This source code is licensed under the MIT license found in the
14+
* LICENSE file in the root directory of this source tree.
15+
*/
16+
17+
/**
18+
* @license React
19+
* react-jsx-runtime.production.min.js
20+
*
21+
* Copyright (c) Facebook, Inc. and its affiliates.
22+
*
23+
* This source code is licensed under the MIT license found in the
24+
* LICENSE file in the root directory of this source tree.
25+
*/
26+
27+
/**
28+
* @license React
29+
* react.production.min.js
30+
*
31+
* Copyright (c) Facebook, Inc. and its affiliates.
32+
*
33+
* This source code is licensed under the MIT license found in the
34+
* LICENSE file in the root directory of this source tree.
35+
*/
36+
37+
/**
38+
* @license React
39+
* scheduler.production.min.js
40+
*
41+
* Copyright (c) Facebook, Inc. and its affiliates.
42+
*
43+
* This source code is licensed under the MIT license found in the
44+
* LICENSE file in the root directory of this source tree.
45+
*/
46+
47+
/**
48+
* React Router DOM v6.3.0
49+
*
50+
* Copyright (c) Remix Software Inc.
51+
*
52+
* This source code is licensed under the MIT license found in the
53+
* LICENSE.md file in the root directory of this source tree.
54+
*
55+
* @license MIT
56+
*/

0 commit comments

Comments
 (0)