diff --git a/examples/complex-http-crawler/pkg/model/task.go b/examples/complex-http-crawler/pkg/model/task.go index 4c3b000..753239b 100644 --- a/examples/complex-http-crawler/pkg/model/task.go +++ b/examples/complex-http-crawler/pkg/model/task.go @@ -1,6 +1,7 @@ package model import ( + "context" "net/http" "time" ) @@ -18,7 +19,7 @@ func New(url string) *MyTask { } } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { transport := &http.Transport{ DisableCompression: true, } diff --git a/examples/metadata/main.go b/examples/metadata/main.go index 5af0517..a1bc24b 100644 --- a/examples/metadata/main.go +++ b/examples/metadata/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "math/rand" "time" @@ -15,7 +16,7 @@ func New() *MyTask { return &MyTask{} } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond) return nil } diff --git a/examples/nopper/main.go b/examples/nopper/main.go index 22f658f..6940ba2 100644 --- a/examples/nopper/main.go +++ b/examples/nopper/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "math/rand" "time" @@ -14,7 +15,7 @@ func New() *MyTask { return &MyTask{} } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) return nil } diff --git a/examples/prometheus/main.go b/examples/prometheus/main.go index 632ff89..0e140a0 100644 --- a/examples/prometheus/main.go +++ b/examples/prometheus/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "net/http" @@ -18,7 +19,7 @@ func New(url string) *MyTask { } } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { response, err := http.Get(t.Url) if err != nil { return err diff --git a/examples/random-error/main.go b/examples/random-error/main.go index 9b2ff96..6e87cac 100644 --- a/examples/random-error/main.go +++ b/examples/random-error/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "errors" "math/rand" "time" @@ -22,7 +23,7 @@ func New(index int, sleepSeconds int) *MyTask { } } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { time.Sleep(time.Duration(t.SleepSeconds) * time.Second) if rand.Float64() < t.ErrorProbability { return errors.New("an error occurred") diff --git a/examples/result-channel/main.go b/examples/result-channel/main.go index a806eac..2412c67 100644 --- a/examples/result-channel/main.go +++ b/examples/result-channel/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "encoding/json" "fmt" "log/slog" @@ -20,7 +21,7 @@ func New(url string) *MyTask { } } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { response, err := http.Get(t.Url) if err != nil { return err diff --git a/examples/simple-http-crawler/main.go b/examples/simple-http-crawler/main.go index 097baef..5023c42 100644 --- a/examples/simple-http-crawler/main.go +++ b/examples/simple-http-crawler/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "net/http" @@ -18,7 +19,7 @@ func New(url string) *MyTask { } } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { response, err := http.Get(t.Url) if err != nil { return err diff --git a/examples/sleeper/main.go b/examples/sleeper/main.go index 9803b65..925f543 100644 --- a/examples/sleeper/main.go +++ b/examples/sleeper/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "math/rand" "time" @@ -19,7 +20,7 @@ func New(index int, sleepSeconds int) *MyTask { } } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { time.Sleep(time.Duration(t.SleepSeconds) * time.Second) return nil } diff --git a/examples/tcp-port-scanner/task.go b/examples/tcp-port-scanner/task.go index ff5d3ce..94d2a7d 100644 --- a/examples/tcp-port-scanner/task.go +++ b/examples/tcp-port-scanner/task.go @@ -1,6 +1,9 @@ package main -import "net" +import ( + "context" + "net" +) type MyTask struct { IP string `json:"ip"` @@ -16,7 +19,7 @@ func New(ip string, port uint16) *MyTask { } } -func (t *MyTask) Do() error { +func (t *MyTask) Do(_ context.Context) error { conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{ IP: net.ParseIP(t.IP), Port: int(t.Port),