Skip to content

Commit

Permalink
update readme and rename config
Browse files Browse the repository at this point in the history
  • Loading branch information
falmar committed May 5, 2023
1 parent 4763e15 commit ab6319b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ import (
"context"
"fmt"
"github.com/falmar/krun"
"os"
"time"
)

func main() {
cfg := krun.NewWorkerQueueConfig{
queue := krun.New(krun.NewConfig{
Size: 5, // number of workers
WaitSleep: time.Millisecond * 10,
}

queue := krun.NewWorkerQueue(cfg)
})

job := func(ctx context.Context) (interface{}, error) {
time.Sleep(time.Millisecond * 100)
Expand All @@ -45,9 +44,10 @@ func main() {
res := <-resChan
if res.Error != nil {
fmt.Println("Error:", res.Error)
} else {
fmt.Println("Result:", res.Data)
os.Exit(1)
}

fmt.Println("Result:", res.Data)
}
```

Expand Down
4 changes: 2 additions & 2 deletions krun.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ type worker struct {
result chan *Result
}

type NewKrunConfig struct {
type NewConfig struct {
Size int
WaitSleep time.Duration
}

func New(cfg NewKrunConfig) Krun {
func New(cfg NewConfig) Krun {
k := &krun{
n: cfg.Size,
workers: make(chan *worker, cfg.Size),
Expand Down

0 comments on commit ab6319b

Please sign in to comment.