Skip to content

Commit 388aee6

Browse files
committed
[core] Expose call traits (including timeout) to called function
1 parent 616169b commit 388aee6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

core/workflow/callable/call.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package callable
2626

2727
import (
2828
"fmt"
29+
"strconv"
2930
texttemplate "text/template"
3031
"time"
3132

@@ -129,6 +130,13 @@ func (c *Call) Call() error {
129130
template.WrapPointer(&returnVar),
130131
}
131132
c.VarStack["environment_id"] = c.parentRole.GetEnvironmentId().String()
133+
c.VarStack["__call_func"] = c.Func
134+
c.VarStack["__call_timeout"] = c.Traits.Timeout
135+
c.VarStack["__call_trigger"] = c.Traits.Trigger
136+
c.VarStack["__call_await"] = c.Traits.Await
137+
c.VarStack["__call_critical"] = strconv.FormatBool(c.Traits.Critical)
138+
c.VarStack["__call_rolepath"] = c.GetParentRolePath()
139+
132140
objStack := integration.PluginsInstance().ObjectStack(c)
133141

134142
err := fields.Execute(apricot.Instance(), c.GetName(), c.VarStack, objStack, make(map[string]texttemplate.Template))
@@ -144,7 +152,7 @@ func (c *Call) Call() error {
144152
func (c *Call) Start() {
145153
c.await = make(chan error)
146154
go func() {
147-
callId := fmt.Sprintf("hook:%s", c.GetName())
155+
callId := fmt.Sprintf("hook:%s:%s", c.GetTraits().Trigger, c.GetName())
148156
log.Debugf("%s started", callId)
149157
defer utils.TimeTrack(time.Now(), callId, log.WithPrefix("callable"))
150158
c.await <- c.Call()

0 commit comments

Comments
 (0)