Categorygithub.com/code-hex/retrygroup
modulepackage
0.0.0-20170220142141-c8e8bf103c51
Repository: https://github.com/code-hex/retrygroup.git
Documentation: pkg.go.dev

# README

retrygroup

GoDoc
Package retrygroup provides synchronization, Context cancelation for groups of retry goroutines working on subtasks of a common task.

Synopsis

package main

import (
	"context"
	"errors"
	"fmt"
	"time"

	"github.com/Code-Hex/retrygroup"
)

func main() {
	ctx, cancel := context.WithCancel(context.Background())
	g, _ := retrygroup.WithContext(ctx)
	g.EnableBackoff()

	go func() {
		<-time.After(16 * time.Second)
		if cancel != nil {
			fmt.Println("Finish!!")
			cancel()
		}
	}()

	g.RetryGo(3, func(i int) error {
		fmt.Printf("Hello: %d\n", i)
		return errors.New("Try error")
	})

	g.RetryGo(-1, func(i int) error {
		fmt.Println("Never!!")
		return errors.New("Try never error")
	})

	g.Wait()
}

See eg

# Packages

No description provided by the author

# Functions

WithContext returns a new Group and an associated Context derived from ctx.

# Structs

A Group is a collection of goroutines working on subtasks that are part of the same overall task.