Add random string to the workflow id
This commit is contained in:
+10
@@ -3,6 +3,7 @@ package ersteller
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
mathRand "math/rand"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
@@ -35,3 +36,12 @@ func InlineTemplate(templateString string, data any) string {
|
|||||||
}
|
}
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RandomString(n int) string {
|
||||||
|
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
|
b := make([]byte, n)
|
||||||
|
for i := range b {
|
||||||
|
b[i] = letters[int(mathRand.Int63()%int64(len(letters)))]
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func (w *Workflow) Execute(ctx context.Context, payload map[string]any) error {
|
|||||||
|
|
||||||
func (w *Workflow) GenerateId() string {
|
func (w *Workflow) GenerateId() string {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
return w.Identifier + "_" + now.Format("20060102150405")
|
return w.Identifier + "_" + now.Format("20060102150405") + "_" + ersteller.RandomString(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCronTrigger(ctx context.Context, workflow *Workflow, d time.Duration) {
|
func NewCronTrigger(ctx context.Context, workflow *Workflow, d time.Duration) {
|
||||||
|
|||||||
Reference in New Issue
Block a user