Harden Harness runtime, persistence and execution for Hand
This commit is contained in:
1 parent
09c30fe2d5
commit
0972eed3ea
164 files changed
+15912
-506
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (r *Runtime) startRunLifecycle(ctx context.Context) (err error) {
|
||||
if hook := r.AgentLoop.Hooks.OnRunStart; hook != nil {
|
||||
defer func() {
|
||||
if recovered := recover(); recovered != nil {
|
||||
err = recoveredPanicError("OnRunStart hook", recovered)
|
||||
}
|
||||
}()
|
||||
return hook(ctx)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (r *Runtime) finishRunLifecycle(parent context.Context, reason string) {
|
||||
if hook := r.AgentLoop.Hooks.OnRunFinish; hook != nil {
|
||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(parent), 2*time.Second)
|
||||
defer cancel()
|
||||
defer func() {
|
||||
if recovered := recover(); recovered != nil {
|
||||
_ = recoveredPanicError("OnRunFinish hook", recovered)
|
||||
}
|
||||
}()
|
||||
hook(ctx, reason)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user