MCPcopy Create free account
hub / github.com/astercloud/aster / ExecuteBatch

Method ExecuteBatch

pkg/tools/executor.go:101–115  ·  view source on GitHub ↗

ExecuteBatch 批量执行工具

(ctx context.Context, requests []*ExecuteRequest)

Source from the content-addressed store, hash-verified

99
100// ExecuteBatch 批量执行工具
101func (e *Executor) ExecuteBatch(ctx context.Context, requests []*ExecuteRequest) []*ExecuteResult {
102 results := make([]*ExecuteResult, len(requests))
103 var wg sync.WaitGroup
104
105 for i, req := range requests {
106 wg.Add(1)
107 go func(idx int, r *ExecuteRequest) {
108 defer wg.Done()
109 results[idx] = e.Execute(ctx, r)
110 }(i, req)
111 }
112
113 wg.Wait()
114 return results
115}
116
117// Wait 等待所有执行完成
118func (e *Executor) Wait() {

Callers

nothing calls this directly

Calls 3

ExecuteMethod · 0.95
WaitMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected