
Go SDK
The Ittybit Go library provides convenient access to the Ittybit API from Go.
Usage
Instantiate and use the client with the following:
Environments
You can choose between different environments by using the option.WithBaseURL
option. You can configure any arbitrary base
URL, which is particularly useful in test environments.
Errors
Structured error types are returned from API calls that return non-success status codes. These errors are compatible
with the errors.Is
and errors.As
APIs, so you can access the error like so:
Request Options
A variety of request options are included to adapt the behavior of the library, which includes configuring
authorization tokens, or providing your own instrumented *http.Client
.
These request options can either be specified on the client so that they're applied on every request, or for an individual request, like so:
Providing your own
*http.Client
is recommended. Otherwise, thehttp.DefaultClient
will be used, and your client will wait indefinitely for a response (unless the per-request, context-based timeout is used).
Advanced
Retries
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retryable when any of the following HTTP status codes is returned:
Use the option.WithMaxAttempts
option to configure this behavior for the entire client or an individual request:
Timeouts
Setting a timeout for each individual request is as simple as using the standard context library. Setting a one second timeout for an individual API call looks like the following:
Contributing
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!