[CRE-2082] Execution Timestamp support in Engine#21319
Conversation
|
I see you updated files related to
|
|
✅ No conflicts with other open PRs targeting |
f5713d9 to
3207e66
Compare
| func GenerateExecutionID(workflowID, triggerEventID string) (string, error) { | ||
| s := sha256.New() | ||
| _, err := s.Write([]byte(workflowID)) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| _, err = s.Write([]byte(triggerEventID)) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| return hex.EncodeToString(s.Sum(nil)), nil | ||
| } | ||
|
|
||
| func GenerateExecutionIDWithTriggerIndex(workflowID, triggerEventID string, triggerIndex int) (string, error) { | ||
| s := sha256.New() | ||
| _, err := s.Write([]byte(workflowID)) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| _, err = s.Write([]byte(triggerEventID)) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| _, err = s.Write([]byte(strconv.Itoa(triggerIndex))) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| return hex.EncodeToString(s.Sum(nil)), nil | ||
| } |
There was a problem hiding this comment.
Let's just have one function that hashes everything (it is 1-1 compatible with the previous one)
| } | |
| func GenerateExecutionID(args ...any) (string, error) { | |
| s := sha256.New() | |
| _, err := s.Write([]byte(fmt.Sprint(args...))) | |
| if err != nil { | |
| return "", err | |
| } | |
| return hex.EncodeToString(s.Sum(nil)), nil | |
| } |
There was a problem hiding this comment.
I was planning to remove the old one once the feature is rolled out but that's OK too, thank.
There was a problem hiding this comment.
On second thoughts, I think it's safer to have named arguments. Otherwise it's easy to make a mistake and call it with different order or with missing params.
There was a problem hiding this comment.
Sure, you can still have named arguments but implementation can be made concise using fmt.Sprint
35a7586 to
17d6ce7
Compare
| return | ||
| } | ||
|
|
||
| // Fetch organization ID for this execution |
There was a problem hiding this comment.
@patrickhuie19 can we do this once on Engine init instead of on every execution?
17d6ce7 to
195c9de
Compare
|




No description provided.