Skip to main content

Configuration

With the module initialised, the StatusCake provider can be configured.

Authentication

The StatusCake Terraform provider requires that an API bearer token be included in the provider configuration block. You can view and manage your API tokens from the StatusCake account panel.

note

API tokens must be kept private. In the event that one is exposed a new one should be generated.

Create a Client
package mainimport (  "github.com/StatusCakeDev/statuscake-go"  "github.com/StatusCakeDev/statuscake-go/credentials")func main() {  bearer := credentials.NewBearerWithStaticToken("my-api-token")  client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer))}

Request Retries

When a request results in a transient error - an error that will resolve itself, i.e. connection error, or rate limit being hit - it may be desirable to retry the request in the future. For this the SDKs allow for each request to be retired up to some maximum number of times to give thea greater chance for success.

Retry Attempts
package mainimport (  "github.com/StatusCakeDev/statuscake-go"  "github.com/StatusCakeDev/statuscake-go/credentials")func main() {  bearer := credentials.NewBearerWithStaticToken("my-api-token")  client := statuscake.NewClient(    statuscake.WithRequestCredentials(bearer),    statuscake.WithMaxRetries(3),  )}

Backoff

By default request retry attempts are made using a constant backoff strategy with a backoff period of 1 second. This may be configured to support alternate backoff periods.

Constant Backoff
package mainimport (  "time"  "github.com/StatusCakeDev/statuscake-go"  "github.com/StatusCakeDev/statuscake-go/backoff"  "github.com/StatusCakeDev/statuscake-go/credentials")func main() {  bearer := credentials.NewBearerWithStaticToken("my-api-token")  client := statuscake.NewClient(    statuscake.WithRequestCredentials(bearer),    statuscake.WithBackoff(backoff.Constant{      BaseDelay: time.Duration(5) * time.Second,    }),  )}

The SDKs support other backoff strategies. These are detailed further in the backoff strategies guide.

Disable Retries

Request retries can be disabled entirely for applications that do not require it.

Disbale Retries
package mainimport (  "github.com/StatusCakeDev/statuscake-go"  "github.com/StatusCakeDev/statuscake-go/credentials")func main() {  bearer := credentials.NewBearerWithStaticToken("my-api-token")  client := statuscake.NewClient(    statuscake.WithRequestCredentials(bearer),    statuscake.WithDisableRetry(),  )}

Next Steps

Next learn about the different request retry backoff strategies the SDKs support.