services

package
v0.42.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package services provides common functionality to be reused by service implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorRetryable added in v0.42.0

func ErrorRetryable(err error) error

ErrorRetryable gets the underlying error of a retryable error. If the given error err is not retryable, it is returned.

func IsRetryable

func IsRetryable(err error) bool

IsRetryable indicates whether the operation causing the error may be retried with a backoff potentially. For example, a retryable error may be caused by an operation that times out or due to a temporary unavailability.

IsRetryable returns false if the error is nil or if the error is caused by an operation that cannot be retried due to failed preconditions, invalid arguments, or on any other grounds. Otherwise, true is returned.

func NewRetryableError

func NewRetryableError(err error) error

NewRetryableError creates and returns a new error from the given error indicating that it is retryable. Returns nil if the given error is nil.

Use the function IsRetryable(error) to check whether a given error is retryable or not.

func RetryWithBackoff added in v0.42.0

func RetryWithBackoff(ctx context.Context, b Backoff, op func(cnt int) error) error

RetryWithBackoff synchronously retries the given operation according to the given backoff strategy as long as as it yields a retryable error.

RetryWithBackoff returns nil if the operation succeeds eventually, a non-retryable error if it fails eventually (also due to cancelation of given context) or a retryable error to indicate that the maximum number of retry attempts has been reached.

The given operation is passed a counter that, starting with 1, sums up the number of invocations, including the current one.

func RetryableErrorf

func RetryableErrorf(format string, a ...any) error

RetryableErrorf returns a retryable error that formats according to the given format specifier.

Use the function IsRetryable(error) to check whether a given error is retryable or not.

Types

type Backoff added in v0.42.0

type Backoff struct {
	Base time.Duration // base delay of the first retry attempt
	Cap  time.Duration // if nonzero, maximum delay between retry attempts
	Max  int           // if nonzero, maximum number of retry attempts
}

Backoff represents a capped exponential backoff strategy for an operation that yields a retryable error (see RetryWithBackoff).

Note that you can also define a linear backoff strategy by setting Cap to the same value as Base.

Directories

Path Synopsis
com
Package com provides a factory function that creates a specific communication binding from a given communication protocol.
Package com provides a factory function that creates a specific communication binding from a given communication protocol.
api
Package api provides the communication API for data-centric message-driven communication among decoupled DDAs.
Package api provides the communication API for data-centric message-driven communication among decoupled DDAs.
mqtt5
Package mqtt5 provides a communication protocol binding implementation using the [MQTT v5] pub-sub messaging protocol.
Package mqtt5 provides a communication protocol binding implementation using the [MQTT v5] pub-sub messaging protocol.
Package state provides a factory function that creates a specific state synchronization binding from a given consensus protocol.
Package state provides a factory function that creates a specific state synchronization binding from a given consensus protocol.
api
Package api provides the distributed state synchronization API.
Package api provides the distributed state synchronization API.
raft
Package raft exports [MessagePack] codec functionality to serialize log entries, LogStore items, and FSM snaphosts.
Package raft exports [MessagePack] codec functionality to serialize log entries, LogStore items, and FSM snaphosts.
Package store provides a factory function that creates a specific storage binding from a given storage engine.
Package store provides a factory function that creates a specific storage binding from a given storage engine.
api
Package api provides the local storage API for a single DDA sidecar or instance.
Package api provides the local storage API for a single DDA sidecar or instance.
pebble
Package pebble provides a storage binding implementation using the [Pebble] storage engine.
Package pebble provides a storage binding implementation using the [Pebble] storage engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL