GustavoKatel / go-retry

Retry operation executor with init and clean up functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-retry

GoDoc

Retry operation executor with init and clean up functions

Example

ctx := context.Background()

value := 5

Retry(
    ctx,
    func(_ context.Context, v interface{}) error {
        if &value != v {
            return fmt.Errorf("Value diff")
        }
        return nil
    },
    Init(func(ctx context.Context) (interface{}, error) {
        return &value, nil
    }),
    Clean(func(ctx context.Context, v interface{}, e error) error {
        if &value != v {
            return fmt.Errorf("Value diff")
        }
        return e
    }),
)

About

Retry operation executor with init and clean up functions

License:MIT License


Languages

Language:Go 100.0%