Skip to content

Commit

Permalink
Added example usage to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Borders authored Nov 1, 2018
1 parent 5edf668 commit eebf480
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,30 @@
Simple in-memory job queue for Golang using worker-based dispatching

Documentation here: https://godoc.org/github.com/mborders/job-queue

## Example Usage

```go
// 10 workers, 100 max in job queue
d := artifex.NewDispatcher(10, 100)
d.Run()

d.Dispatch(artifex.Job{Run: func() {
// do something
}})

err := d.DispatchIn(artifex.Job{Run: func() {
// do something in 500ms
}}, time.Millisecond*500)

// Returns a DispatchTicker
dt, err := d.DispatchEvery(artifex.Job{Run: func() {
// do something every 250ms
}}, time.Millisecond*250)

// Stop a given DispatchTicker
dt.Stop()

// Stop a dispatcher and all its workers
d.Stop()
```

0 comments on commit eebf480

Please sign in to comment.