From 6cec21dcf5901bf7729549ca95720cc76d30f514 Mon Sep 17 00:00:00 2001 From: Yihang Wang Date: Mon, 15 Jan 2024 13:33:01 +0800 Subject: [PATCH] refactor: change argument name from line to data --- README.md | 4 ++-- example/complex-http-crawler/pkg/model/task.go | 4 ++-- example/simple-http-crawler/main.go | 4 ++-- gojob.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d7e95ee..631bf7f 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Create a job scheduler with a worker pool of size 32. To do this, you need to im ```go type Task interface { - Parse(line []byte) (err error) + Parse(data []byte) (err error) Start() Bytes() ([]byte, error) } @@ -48,7 +48,7 @@ func NewTask(line []byte) *MyTask { return t } -func (t *MyTask) Parse(line []byte) (err error) { +func (t *MyTask) Parse(data []byte) (err error) { t.Url = string(bytes.TrimSpace(line)) return } diff --git a/example/complex-http-crawler/pkg/model/task.go b/example/complex-http-crawler/pkg/model/task.go index 838e840..e6bf247 100644 --- a/example/complex-http-crawler/pkg/model/task.go +++ b/example/complex-http-crawler/pkg/model/task.go @@ -21,8 +21,8 @@ func NewTask(line []byte) *MyTask { return t } -func (t *MyTask) Parse(line []byte) (err error) { - t.Url = string(bytes.TrimSpace(line)) +func (t *MyTask) Parse(data []byte) (err error) { + t.Url = string(bytes.TrimSpace(data)) return } diff --git a/example/simple-http-crawler/main.go b/example/simple-http-crawler/main.go index 4bc56e5..bfbbf04 100644 --- a/example/simple-http-crawler/main.go +++ b/example/simple-http-crawler/main.go @@ -23,8 +23,8 @@ func NewTask(line []byte) *MyTask { return t } -func (t *MyTask) Parse(line []byte) (err error) { - t.Url = string(bytes.TrimSpace(line)) +func (t *MyTask) Parse(data []byte) (err error) { + t.Url = string(bytes.TrimSpace(data)) return } diff --git a/gojob.go b/gojob.go index d3b44ed..b11ebb7 100644 --- a/gojob.go +++ b/gojob.go @@ -140,7 +140,7 @@ func Reduce[T interface{}](in chan T, f func(T, T) T) T { type Task interface { // Parse unserializes a task from a byte array, returns an error if the task is invalid // For example, a task can be unserialized from a line of a file - Parse(line []byte) (err error) + Parse(data []byte) (err error) // Start starts the task Start() // Bytes serializes a task to a byte array, returns an error if the task is invalid