Skip to content

Commit

Permalink
feat(*): remove uuid (#7)
Browse files Browse the repository at this point in the history
Signed-off-by: Soren Yang <lsytj0413@gmail.com>
  • Loading branch information
lsytj0413 authored Jan 17, 2024
1 parent 85157d9 commit 197f627
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 36 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/fornext-io/fornext
go 1.21

require (
github.com/cockroachdb/pebble v1.0.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2
github.com/lsytj0413/ena v0.1.1
github.com/ohler55/ojg v1.20.3
Expand All @@ -21,7 +21,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/pebble v1.0.0 // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down
16 changes: 12 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4=
github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877 h1:1MLK4YpFtIEo3ZtMA5C795Wtv5VuUnrXX7mQG+aHg6o=
github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM=
github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y=
github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac=
Expand All @@ -82,6 +84,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
Expand All @@ -102,6 +105,7 @@ github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -191,8 +195,6 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
Expand Down Expand Up @@ -241,7 +243,6 @@ github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgo
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
Expand Down Expand Up @@ -283,6 +284,7 @@ github.com/ohler55/ojg v1.20.3 h1:Z+fnElsA/GbI5oiT726qJaG4Ca9q5l7UO68Qd0PtkD4=
github.com/ohler55/ojg v1.20.3/go.mod h1:uHcD1ErbErC27Zhb5Df2jUjbseLLcmOCo6oxSr3jZxo=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.13.0 h1:M76yO2HkZASFjXL0HSoZJ1AYEmQxNJmY41Jx1zNUq1Y=
github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0=
github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
Expand All @@ -291,11 +293,13 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.27.5 h1:T/X6I0RNFw/kTqgfkZPcQ5KU6vCnWNBGdtrIx2dpGeQ=
github.com/onsi/gomega v1.27.5/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
Expand Down Expand Up @@ -342,6 +346,8 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
Expand Down Expand Up @@ -463,6 +469,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -663,8 +671,8 @@ google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cn
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
Expand Down
2 changes: 2 additions & 0 deletions pkg/executor/activity_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ type ActivityContext struct {
// /{tenant}/{namespace}/execution/{id}/activity/{id}
ID string

ExecutionID string

StateName string
Input []byte

Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/choice_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/fornext-io/fornext/pkg/fsl"
"github.com/google/uuid"
"github.com/ohler55/ojg/jp"
)

Expand Down Expand Up @@ -352,7 +351,8 @@ func (p *choiceStateProcessor) CompleteState(ctx context.Context, cmd *CompleteS
}

e.ev <- &StartStateCommand{
ActivityID: uuid.NewString(), // TODO: add executionid in context
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
ExecutionID: at.ExecutionID,
StateName: next,
ParentBranchID: at.ParentBranchID,
ParentIterationID: at.ParentIterationID,
Expand Down
3 changes: 3 additions & 0 deletions pkg/executor/create_task_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ type CreateTaskCommand struct {
// ActivityID is the identify of activity which this task belongs.
ActivityID string

// ExecutionID is the identify of execution which this task belong to.
ExecutionID string

// Resource is the task's reference resource definitions.
Resource string

Expand Down
25 changes: 13 additions & 12 deletions pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/fornext-io/fornext/pkg/fsl"
"github.com/fornext-io/fornext/pkg/utils"
"github.com/google/uuid"
)

type stateContextHolder struct {
Expand Down Expand Up @@ -50,7 +49,6 @@ type Executor struct {
sm *fsl.StateMachine
ctx *ExecutionContext

// iterationContextes map[string]*IterationContext
store *Storage

done chan interface{}
Expand All @@ -68,10 +66,9 @@ func NewExecutor(sm *fsl.StateMachine, handlers map[string]func(*CreateTaskComma
}

v := &Executor{
sm: sm,
done: make(chan interface{}),
ev: make(chan interface{}, 100),
// iterationContextes: map[string]*IterationContext{},
sm: sm,
done: make(chan interface{}),
ev: make(chan interface{}, 100),
store: store,
c: newHybridLogicalClock(),
taskHandlers: map[string]func(*CreateTaskCommand) []byte{},
Expand Down Expand Up @@ -170,10 +167,11 @@ func (e *Executor) run() {
}
t := e.c.Next()
e.ev <- &StartStateCommand{
ActivityID: evv.ID + "/" + t.AsString(),
StateName: e.sm.StartAt,
Input: evv.Input,
Timestamp: t.AsUint64(),
ActivityID: evv.ID + "/" + t.AsString(),
ExecutionID: evv.ID,
StateName: e.sm.StartAt,
Input: evv.Input,
Timestamp: t.AsUint64(),
}
case *StartStateCommand:
e.processStartStateCommand(evv)
Expand Down Expand Up @@ -210,6 +208,7 @@ func (e *Executor) processStartStateCommand(cmd *StartStateCommand) {

err := Set(context.Background(), e.store, cmd.ActivityID, &ActivityContext{
ID: cmd.ActivityID,
ExecutionID: cmd.ExecutionID,
StateName: cmd.StateName,
ParentBranchID: cmd.ParentBranchID,
ParentIterationID: cmd.ParentIterationID,
Expand Down Expand Up @@ -402,7 +401,8 @@ func (e *Executor) processStartBranchCommand(cmd *StartBranchCommand) {
state := findState(e.sm, at.StateName).(*fsl.ParallelState)
e.ev <- &StartStateCommand{
StateName: state.Branches[cmd.Index].StartAt,
ActivityID: uuid.NewString(),
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
ExecutionID: at.ExecutionID,
ParentBranchID: &cmd.BranchID,
ParentIterationID: nil,
Input: cmd.Input,
Expand Down Expand Up @@ -470,7 +470,8 @@ func (e *Executor) processStartIterationCommand(cmd *StartIterationCommand) {
state := findState(e.sm, at.StateName).(*fsl.MapState)
e.ev <- &StartStateCommand{
StateName: state.ItemProcessor.StartAt,
ActivityID: uuid.NewString(),
ExecutionID: at.ExecutionID,
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
ParentBranchID: nil,
ParentIterationID: &cmd.IterationID,
Input: cmd.Input,
Expand Down
8 changes: 5 additions & 3 deletions pkg/executor/map_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package executor
import (
"context"
"encoding/json"
"fmt"
"log/slog"

"github.com/fornext-io/fornext/pkg/fsl"
"github.com/google/uuid"
)

type mapStateProcessor struct {
Expand Down Expand Up @@ -55,8 +55,9 @@ func (p *mapStateProcessor) StartState(ctx context.Context, cmd *StartStateComma
}

e.ev <- &StartIterationCommand{
IterationID: uuid.NewString(),
IterationID: fmt.Sprintf("%s/i%v", cmd.ActivityID, i),
ActivityID: cmd.ActivityID,
ExecutionID: cmd.ExecutionID,
Index: i,
Input: data,
}
Expand Down Expand Up @@ -107,8 +108,9 @@ func (p *mapStateProcessor) CompleteState(ctx context.Context, cmd *CompleteStat
}

e.ev <- &StartStateCommand{
ActivityID: uuid.NewString(),
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
StateName: s.Next,
ExecutionID: at.ExecutionID,
ParentBranchID: at.ParentBranchID,
ParentIterationID: at.ParentIterationID,
Input: output,
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/paas_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log/slog"

"github.com/fornext-io/fornext/pkg/fsl"
"github.com/google/uuid"
)

type paasStateProcessor struct {
Expand Down Expand Up @@ -76,7 +75,8 @@ func (p *paasStateProcessor) CompleteState(ctx context.Context, cmd *CompleteSta
}

e.ev <- &StartStateCommand{
ActivityID: uuid.NewString(), // TODO: add executionid in context
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
ExecutionID: at.ExecutionID,
StateName: s.Next,
ParentBranchID: at.ParentBranchID,
ParentIterationID: at.ParentIterationID,
Expand Down
14 changes: 8 additions & 6 deletions pkg/executor/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package executor

import (
"context"
"fmt"
"log/slog"

"github.com/fornext-io/fornext/pkg/fsl"
"github.com/google/uuid"
)

type parallelStateProcessor struct {
Expand Down Expand Up @@ -41,10 +41,11 @@ func (p *parallelStateProcessor) StartState(ctx context.Context, cmd *StartState

for i := range s.Branches {
e.ev <- &StartBranchCommand{
BranchID: uuid.NewString(),
ActivityID: cmd.ActivityID,
Index: i,
Input: input,
BranchID: fmt.Sprintf("%s/b%v", cmd.ActivityID, i),
ActivityID: cmd.ActivityID,
ExecutionID: cmd.ExecutionID,
Index: i,
Input: input,
}
}

Expand Down Expand Up @@ -92,8 +93,9 @@ func (p *parallelStateProcessor) CompleteState(ctx context.Context, cmd *Complet
}

e.ev <- &StartStateCommand{
ActivityID: uuid.NewString(),
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
StateName: s.Next,
ExecutionID: at.ExecutionID,
ParentBranchID: at.ParentBranchID,
ParentIterationID: at.ParentIterationID,
Input: output,
Expand Down
2 changes: 2 additions & 0 deletions pkg/executor/start_branch_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type StartBranchCommand struct {
// 2. {id}: is the branch index of current branch, begin with 0
BranchID string

ExecutionID string

// Index is serial of this branch in ParallelState.
Index int

Expand Down
3 changes: 2 additions & 1 deletion pkg/executor/start_iteration_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package executor
// StartIterationCommand is triggered when an MapState is started,
// and this command will been replicated from leader to followers.
type StartIterationCommand struct {
// /{tenant}/{namespace}/execution/{id}/activity/{id}/iteration/{id}
// IterationID is the identify of this iteration, it formated as
// `/{ActivityID}/i{id}`
// in which:
// 1. {ActivityID}: is the referenced activity
// 2. {id}: is the iteration index of current iteration, begin with 0
IterationID string

ExecutionID string

// Index is serial of this iteration in MapState.
Index int

Expand Down
3 changes: 3 additions & 0 deletions pkg/executor/start_state_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type StartStateCommand struct {
// An execution's all activity have the same prefix, and will in same partition.
ActivityID string

// ExecutionID is the identify of execution which this state belong to.
ExecutionID string

// StateName is current state's name which ready for execution, and because all state's
// name must be unique (include in each nest state), so only name is enough.
StateName string
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/task_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log/slog"

"github.com/fornext-io/fornext/pkg/fsl"
"github.com/google/uuid"
)

type taskStateProcessor struct {
Expand Down Expand Up @@ -78,8 +77,9 @@ func (p *taskStateProcessor) CompleteState(ctx context.Context, cmd *CompleteSta
}

e.ev <- &StartStateCommand{
ActivityID: uuid.NewString(), // TODO: add executionid in context
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
StateName: s.Next,
ExecutionID: at.ExecutionID,
ParentBranchID: at.ParentBranchID,
ParentIterationID: at.ParentIterationID,
Input: output,
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/wait_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log/slog"

"github.com/fornext-io/fornext/pkg/fsl"
"github.com/google/uuid"
)

type waitStateProcessor struct {
Expand Down Expand Up @@ -78,7 +77,8 @@ func (p *waitStateProcessor) CompleteState(ctx context.Context, cmd *CompleteSta
}

e.ev <- &StartStateCommand{
ActivityID: uuid.NewString(), // TODO: add executionid in context
ActivityID: at.ExecutionID + "/" + e.c.Next().AsString(),
ExecutionID: at.ExecutionID,
StateName: s.Next,
ParentBranchID: at.ParentBranchID,
ParentIterationID: at.ParentIterationID,
Expand Down

0 comments on commit 197f627

Please sign in to comment.