-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for reading from and writing to gzip files
The code changes include adding a new example file `write-to-gzip-file/main.go` that demonstrates how to write to a gzip file. It also includes modifications to the `read-from-gzip-file/main.go` file, removing the `gojob.WithNumShards(4)` and `gojob.WithShard(0)` options. Additionally, the `go.mod` and `go.sum` files were updated to bump the `github.com/WangYihang/uio` dependency to version `v0.0.0-20240905152743-19ba2df5e6a6`. Please remove any meta information and format the commit message according to the repository's guidelines.
- Loading branch information
1 parent
07cbd3d
commit 36da724
Showing
4 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
"time" | ||
|
||
"github.com/WangYihang/gojob" | ||
) | ||
|
||
type MyTask struct { | ||
Line string | ||
} | ||
|
||
func New(line string) *MyTask { | ||
return &MyTask{ | ||
Line: line, | ||
} | ||
} | ||
|
||
func (t *MyTask) Do() error { | ||
time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) | ||
fmt.Println(t.Line) | ||
return nil | ||
} | ||
|
||
func main() { | ||
scheduler := gojob.New( | ||
gojob.WithNumWorkers(1), | ||
gojob.WithMaxRetries(4), | ||
gojob.WithMaxRuntimePerTaskSeconds(16), | ||
gojob.WithResultFilePath("result.txt.gz"), | ||
gojob.WithStatusFilePath("status.json"), | ||
gojob.WithMetadataFilePath("status.json"), | ||
). | ||
Start() | ||
for line := range 16 { | ||
scheduler.Submit(New(fmt.Sprintf("line-%d", line))) | ||
} | ||
scheduler.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters