Documentation ¶
Overview ¶
Package gorion is a Go client library for Iron.io (http://www.iron.io/) services. It provides interfaces (see the mq.Client for example) for use in your code and in-memory "stubs" for each interface that you can use in your code's unit tests.
Additionally, all interface funcs take a net.Context (http://godoc.org/golang.org/x/net/context) which your code can use to control timeouts, cancellation and more. See https://blog.golang.org/context for more information on how to use Contexts.
Gorion currently supports a small subset of the IronMQ API. See the mq package for more usage details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCancelled is returned immediately when a func returns a net.Context that is // already cancelled. ErrCancelled = errors.New("cancelled") )
Functions ¶
func HTTPDo ¶
func HTTPDo(ctx context.Context, client *http.Client, transport *http.Transport, req *http.Request, f func(*http.Response, error) error) error
HTTPDo runs the HTTP request in a goroutine and passes the response to f in that same goroutine. After the goroutine finishes, returns the result of f. If ctx.Done() receives before f returns, calls transport.CancelRequest(req) before before returning. Even though HTTPDo executes f in another goroutine, you can treat it as a synchronous call to f. Also, since HTTPDo uses client to run requests and transport to cancel them, client.Transport should be transport in most cases.
Example Usage:
type Resp struct { Num int `json:"num"` } var resp *Resp err := HttpDo(ctx, client, transport, req, func(resp *http.Response, err error) error { if err != nil { return err } defer resp.Body.Close() if err := json.NewDecoder(resp.Body).Decode(resp); err != nil { return err } return nil }) if err != nil { return err } // do something with resp...
This func was stolen/adapted from https://blog.golang.org/context
Types ¶
This section is empty.