Skip to content

yandex-cloud/go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yandex.Cloud Go SDK

GoDoc CircleCI

Go SDK for Yandex.Cloud services.

NOTE: SDK is under development, and may make backwards-incompatible changes.

Installation

go get github.com/yandex-cloud/go-sdk

Example usages

Initializing SDK

sdk, err := ycsdk.Build(ctx, ycsdk.Config{
	Credentials: ycsdk.OAuthToken(token),
})
if err != nil {
	log.Fatal(err)
}

Retries

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

More examples can be found in examples dir.