containerd/docs
Brian Goff 026896ac4c Make Wait() async
In all of the examples, its recommended to call `Wait()` before starting
a process/task.
Since `Wait()` is a blocking call, this means it must be called from a
goroutine like so:

```go
statusC := make(chan uint32)
go func() {
  status, err := task.Wait(ctx)
  if err != nil {
    // handle async err
  }

  statusC <- status
}()

task.Start(ctx)
<-statusC
```

This means there is a race here where there is no guarentee when the
goroutine is going to be scheduled, and even a bit more since this
requires an RPC call to be made.
In addition, this code is very messy and a common pattern for any caller
using Wait+Start.

Instead, this changes `Wait()` to use an async model having `Wait()`
return a channel instead of the code itself.
This ensures that when `Wait()` returns that the client has a handle on
the event stream (already made the RPC request) before returning and
reduces any sort of race to how the stream is handled by grpc since we
can't guarentee that we have a goroutine running and blocked on
`Recv()`.

Making `Wait()` async also cleans up the code in the caller drastically:

```go
statusC, err := task.Wait(ctx)
if err != nil {
  return err
}

task.Start(ctx)

status := <-statusC
if status.Err != nil {
  return err
}
```

No more spinning up goroutines and more natural error
handling for the caller.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-08-22 09:33:07 -04:00
..
_includes retrying pr for website to satify cncf guidelines 2017-06-16 14:30:31 -07:00
_layouts added website code for containerd.io 2017-03-15 13:14:10 -07:00
hooks added website code for containerd.io 2017-03-15 13:14:10 -07:00
images retrying pr for website to satify cncf guidelines 2017-06-16 14:30:31 -07:00
style added website code for containerd.io 2017-03-15 13:14:10 -07:00
_config.yml added website code for containerd.io 2017-03-15 13:14:10 -07:00
.dockerignore added website code for containerd.io 2017-03-15 13:14:10 -07:00
.gitignore added website code for containerd.io 2017-03-15 13:14:10 -07:00
client-opts.md Add doc for extending client opts 2017-08-08 15:39:59 -04:00
dockercon-summit.md Update dockercon-summit.md 2017-04-20 01:31:00 -05:00
Dockerfile added website code for containerd.io 2017-03-15 13:14:10 -07:00
getting-started.md Make Wait() async 2017-08-22 09:33:07 -04:00
index.md retrying pr for website to satify cncf guidelines 2017-06-16 14:30:31 -07:00
namespaces.md Minor updates to the namespaces doc 2017-08-10 11:08:03 -04:00
ops.md Add section for state dir 2017-08-11 16:54:42 -04:00
README.md retrying pr for website to satify cncf guidelines 2017-06-16 14:30:31 -07:00

Containerd website

The containerd website is built using Jekyll and published to Github pages.

In order to build and test locally:

docker run -it -v "$PWD":/usr/src/app -p "4000:4000" starefossen/github-pages

Then browser to localhost:4000 to see the rendered site. The site autorefreshes when you modify files locally.