mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-19 10:55:44 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
cb8898d20e | |||
a552d1c9f9 |
@ -20,8 +20,11 @@ import (
|
||||
// - ctx: The context for managing request lifecycle and cancellation.
|
||||
// - requestConfig: The configuration for the request, including timeout, proxies, and other settings.
|
||||
func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, error) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
if requestConfig.Duration > 0 {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, requestConfig.Duration)
|
||||
defer cancel()
|
||||
}
|
||||
|
||||
clients := getClients(
|
||||
ctx,
|
||||
@ -34,10 +37,6 @@ func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, e
|
||||
return nil, types.ErrInterrupt
|
||||
}
|
||||
|
||||
if requestConfig.Duration > 0 {
|
||||
time.AfterFunc(requestConfig.Duration, func() { cancel() })
|
||||
}
|
||||
|
||||
responses := releaseDodos(ctx, requestConfig, clients)
|
||||
if ctx.Err() != nil && len(responses) == 0 {
|
||||
return nil, types.ErrInterrupt
|
||||
|
Loading…
x
Reference in New Issue
Block a user