parent
334117d67f
commit
792c7be92a
|
|
@ -44,6 +44,14 @@ func NewContext(ctx context.Context, store istore.Store, task *types.Task, curre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// updateExecutionTime update task and step execution time when update operation
|
||||||
|
func (c *Context) updateExecutionTime() {
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
c.task.SetExecutionTime(c.task.Start, now)
|
||||||
|
c.currentStep.SetExecutionTime(c.currentStep.Start, now)
|
||||||
|
}
|
||||||
|
|
||||||
// Context returns the step's context
|
// Context returns the step's context
|
||||||
func (c *Context) Context() context.Context {
|
func (c *Context) Context() context.Context {
|
||||||
return c.ctx
|
return c.ctx
|
||||||
|
|
@ -92,6 +100,8 @@ func (c *Context) GetCommonParam(key string) (string, bool) {
|
||||||
// AddCommonParam add task common param and save to store
|
// AddCommonParam add task common param and save to store
|
||||||
func (c *Context) AddCommonParam(k, v string) error {
|
func (c *Context) AddCommonParam(k, v string) error {
|
||||||
_ = c.task.AddCommonParam(k, v)
|
_ = c.task.AddCommonParam(k, v)
|
||||||
|
c.updateExecutionTime()
|
||||||
|
|
||||||
return c.store.UpdateTask(c.ctx, c.task)
|
return c.store.UpdateTask(c.ctx, c.task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,6 +115,7 @@ func (c *Context) SetCommonPayload(obj any) error {
|
||||||
if err := c.task.SetCommonPayload(obj); err != nil {
|
if err := c.task.SetCommonPayload(obj); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
c.updateExecutionTime()
|
||||||
|
|
||||||
return c.store.UpdateTask(c.ctx, c.task)
|
return c.store.UpdateTask(c.ctx, c.task)
|
||||||
}
|
}
|
||||||
|
|
@ -132,6 +143,8 @@ func (c *Context) GetParam(key string) (string, bool) {
|
||||||
// AddParam set step param by key,value and save to store
|
// AddParam set step param by key,value and save to store
|
||||||
func (c *Context) AddParam(key string, value string) error {
|
func (c *Context) AddParam(key string, value string) error {
|
||||||
_ = c.currentStep.AddParam(key, value)
|
_ = c.currentStep.AddParam(key, value)
|
||||||
|
c.updateExecutionTime()
|
||||||
|
|
||||||
return c.store.UpdateTask(c.ctx, c.task)
|
return c.store.UpdateTask(c.ctx, c.task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,6 +156,8 @@ func (c *Context) GetParams() map[string]string {
|
||||||
// SetParams set all step params and save to store
|
// SetParams set all step params and save to store
|
||||||
func (c *Context) SetParams(params map[string]string) error {
|
func (c *Context) SetParams(params map[string]string) error {
|
||||||
c.currentStep.SetParams(params)
|
c.currentStep.SetParams(params)
|
||||||
|
c.updateExecutionTime()
|
||||||
|
|
||||||
return c.store.UpdateTask(c.ctx, c.task)
|
return c.store.UpdateTask(c.ctx, c.task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,6 +176,7 @@ func (c *Context) SetPayload(obj any) error {
|
||||||
if err := c.currentStep.SetPayload(obj); err != nil {
|
if err := c.currentStep.SetPayload(obj); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
c.updateExecutionTime()
|
||||||
|
|
||||||
return c.store.UpdateTask(c.ctx, c.task)
|
return c.store.UpdateTask(c.ctx, c.task)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue