Add duration

This commit is contained in:
2025-03-24 16:54:09 +04:00
parent a170588574
commit 59f40ad825
10 changed files with 232 additions and 70 deletions

View File

@@ -7,6 +7,7 @@ import (
"os"
"os/signal"
"syscall"
"time"
"github.com/aykhans/dodo/config"
"github.com/aykhans/dodo/requests"
@@ -49,6 +50,10 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
go listenForTermination(func() { cancel() })
if requestConf.Duration > 0 {
time.AfterFunc(requestConf.Duration, func() { cancel() })
}
responses, err := requests.Run(ctx, requestConf)
if err != nil {
if err == types.ErrInterrupt {