Skip to content

Commit

Permalink
Minimal timers and HTTP service docs; see #16
Browse files Browse the repository at this point in the history
  • Loading branch information
jsccast committed Jan 24, 2018
1 parent 549cc39 commit 037c0c0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cmd/mcrew/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,39 @@ message given to the WebSocket client has strings of the form
(`SHEEN_*`). This crude mechanism is used in the demo Home Assistant
machine to pass a password from the process's environment to Home
Assistant.

### Timers service

Messages like

```JSON
{"to":"timers","makeTimer":{"in":"1s","id":"1","message":{"to":"doubler","double":100}}}}}}
```

will create a timer. The duration (`"in":`) is expressed in Go
[`time.Duration` syntax](https://golang.org/pkg/time/#ParseDuration).

At the appointed time, the process will send the given message to the
crew.

The given `id` can be used to try to cancel the timer (assuming it
hasn't fired):

```JSON
{"to":"timers","deleteTimer":"1"}
```

### HTTP service

Messages like

```JSON
{"to":"http","request":{"url":"%s", ...},"replyTo":"machine42"}
```

will result in an asychronous HTTP request. For now, see
`HTTPRequest` in [`http.go`](http.go) for the supported request
structure. The response is submitted as a message to the crew or to
the `replyTo` machine given in the request. For now, see
`HTTPResponse` in [`http.go`](http.go) for the supported response
structure.

0 comments on commit 037c0c0

Please sign in to comment.