Skip to content

Commit

Permalink
refactor: change argument name from line to data
Browse files Browse the repository at this point in the history
  • Loading branch information
WangYihang committed Jan 15, 2024
1 parent 79e80b0 commit 6cec21d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions example/complex-http-crawler/pkg/model/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions example/simple-http-crawler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion gojob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6cec21d

Please sign in to comment.