# README

Retry - Hyperf jet middleware

Retry middleware for Hyperf jet.

Usage Example

package main

import (
	"context"
	"errors"
	"log"
	"time"

	"github.com/go-kratos-ecosystem/components/v2/hyperf/jet"
	"github.com/go-kratos-ecosystem/components/v2/hyperf/jet/middleware/retry"
)

var customErr = errors.New("custom error")

func main() {
	client, err := jet.NewClient(
		jet.WithTransporter(nil),
		jet.WithService("Example/User/MoneyService"),
	)
	if err != nil {
		log.Fatal(err)
	}

	// base usage
	client.Use(retry.New())

	// with options
	client.Use(retry.New(
		// allow retry when custom error
		retry.Allow(func(err error) bool {
			return errors.Is(err, customErr)
		}),

		// or: allow retry with OrAllowFuncs
		retry.Allow(retry.OrAllowFuncs(
			retry.DefaultAllow,
			func(err error) bool {
				return errors.Is(err, customErr)
			}),
		// ... more allow
		),

		// retry 3 times
		retry.Attempts(3),

		// retry with backoff
		retry.Backoff(retry.LinearBackoff(100*time.Second)),
		// or: retry with NoBackoff
		retry.Backoff(retry.NoBackoff()),
		// or: retry with ExponentialBackoff
		retry.Backoff(retry.ExponentialBackoff(100*time.Second)),
		// or: retry with ConstantBackoff
		retry.Backoff(retry.ConstantBackoff(100*time.Second)),
	))

	// call service
	client.Invoke(context.Background(), "service", []any{"..."}, nil)
}

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
ConstantBackoff returns a backoff function that always returns the same delay.
ExponentialBackoff returns a backoff function that increases the delay exponentially.
No description provided by the author
LinearBackoff returns a backoff function that increases the delay linearly.
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
nolint:mnd.

# Structs

No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author