<!-- Code generated by gomarkdoc. DO NOT EDIT -->

```go
import "github.com/Azure/iot-operations-sdks/go/mqtt/retry"
```

## Index

- [type ExponentialBackoff](<#ExponentialBackoff>)
  - [func \(e \*ExponentialBackoff\) Start\(ctx context.Context, name string, task Task\) error](<#ExponentialBackoff.Start>)
- [type Policy](<#Policy>)
- [type Task](<#Task>)


<a name="ExponentialBackoff"></a>
## type [ExponentialBackoff](<https://github.com/Azure/iot-operations-sdks/blob/main/go/mqtt/retry/exponential_backoff.go#L18-L40>)

ExponentialBackoff implements a retry policy with exponential backoff and optional jitter.

```go
type ExponentialBackoff struct {
    // MaxAttempts sets the maximum number of attempts. The default value of 0
    // indicates unlimited attempts; setting this to 1 will disable retries.
    MaxAttempts uint64

    // MinInterval is the maximum interval between retries (before jitter).
    // Will be set to a default of 1/8s if unspecified.
    MinInterval time.Duration

    // MaxInterval is the maximum interval between retries (before jitter).
    // Will be set to a default of one minute if unspecified.
    MaxInterval time.Duration

    // Timeout is the total timeout for all retries.
    Timeout time.Duration

    // NoJitter removes the default jitter.
    NoJitter bool

    // Logger provides a logger which will be used to log retry attempts and
    // results.
    Logger *slog.Logger
}
```

<a name="ExponentialBackoff.Start"></a>
### func \(\*ExponentialBackoff\) [Start](<https://github.com/Azure/iot-operations-sdks/blob/main/go/mqtt/retry/exponential_backoff.go#L43-L47>)

```go
func (e *ExponentialBackoff) Start(ctx context.Context, name string, task Task) error
```

Start initiates the retry executions.

<a name="Policy"></a>
## type [Policy](<https://github.com/Azure/iot-operations-sdks/blob/main/go/mqtt/retry/types.go#L13-L15>)

Policy is the retry policy for task execution.

```go
type Policy interface {
    Start(ctx context.Context, name string, task Task) error
}
```

<a name="Task"></a>
## type [Task](<https://github.com/Azure/iot-operations-sdks/blob/main/go/mqtt/retry/types.go#L10>)

Task represents a function to retry. It should return a boolean indicating whether a retry should occur on the given error.

```go
type Task = func(context.Context) (retry bool, err error)
```

Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
