Go SDK for Yandex.Cloud services.
NOTE: SDK is under development, and may make backwards-incompatible changes.
go get github.com/yandex-cloud/go-sdk
sdk, err := ycsdk.Build(ctx, ycsdk.Config{
Credentials: ycsdk.OAuthToken(token),
})
if err != nil {
log.Fatal(err)
}
SDK provide built-in retry policy, that supports exponential backoff and jitter, and also retry budget. It's necessary to avoid retry amplification.
import (
...
ycsdk "github.com/yandex-cloud/go-sdk"
"github.com/yandex-cloud/go-sdk/pkg/retry/v1"
)
...
retriesDialOption, err := retry.DefaultRetryDialOption()
if err != nil {
log.Fatal(err)
}
_, err = ycsdk.Build(
ctx,
ycsdk.Config{
Credentials: ycsdk.OAuthToken(*token),
},
retriesDialOption,
)
SDK provide different modes for retry throttling policy:
persistent
is suitable when you use SDK in any long-lived application, when SDK instance will live long enough for manage budget;temporary
is suitable when you use SDK in any short-lived application, e.g. scripts or CI/CD.
By default, SDK will use temporary mode, but you can change it through functional option.
More examples can be found in examples dir.