Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cohix committed Jan 21, 2021
1 parent 50976ac commit 8a2a8dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (g generic) Run(job hive.Job, ctx *hive.Ctx) (interface{}, error) {

// OnChange is called when Hive starts or stops a worker to handle jobs,
// and allows the Runnable to set up before receiving jobs or tear down if needed.
func (g generic) OnChange(change ChangeEvent) error {
func (g generic) OnChange(change hive.ChangeEvent) error {
return nil
}
```
Expand Down
8 changes: 7 additions & 1 deletion docs/getstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (r recursive) Run(job hive.Job, ctx *hive.Ctx) (interface{}, error) {
return fmt.Sprintf("finished %s", job.String()), nil
}

func (r recursive) OnChange(change ChangeEvent) error {
func (r recursive) OnChange(change hive.ChangeEvent) error {
return nil
}
```
Expand Down Expand Up @@ -129,6 +129,12 @@ doBad := h.Handle("badRunner", badRunner{}, hive.RetrySeconds(1), hive.MaxRetrie
```
Any error from a failed worker will be returned to the first job that is attempted for that Runnable.

### Pre-warming
When a Runnable is mounted, it is simply registered as available to receive work. The Runnable is not actually invoked until the first job of the given type is received. For basic Runnables, this is normally fine, but for Runnables who use the `OnChange` method to provision resources, this can cause the first job to be slow. The `PreWarm` option is available to allow Runnables to be started as soon as they are mounted, rather than waiting for the first job. This mitigates cold-starts when anything expensive is needed at startup.
```
doExpensive := h.Handle("expensive", expensiveRunnable{}, hive.PreWarm())
```

### Shortcuts

There are also some shortcuts to make working with Hive a bit easier:
Expand Down

0 comments on commit 8a2a8dd

Please sign in to comment.