All Projects → thedevsaddam → retry

thedevsaddam / retry

Licence: MIT license
Simple and easy retry mechanism package for Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to retry

Rehttp
Package rehttp implements a Go HTTP transport that handles retries.
Stars: ✭ 170 (+214.81%)
Mutual labels:  retry
retries
Forget about your retry boilerplate
Stars: ✭ 14 (-74.07%)
Mutual labels:  retry
java-sdk
一些常用的java sdk和工具类(日期工具类,分布式锁,redis缓存,二叉树,反射工具类,线程池,对称/非对称/分段加解密,json序列化,http工具,雪花算法,字符串相似度,集合操作工具,xml解析,重试Retry工具类,Jvm监控等)
Stars: ✭ 26 (-51.85%)
Mutual labels:  retry
Loadmorewrapper
📦 make recyclerView supports load more and customize the footer view, without changes to the original adater of recyclerView. 在不改动 RecyclerView 原有的 adapter 的情况下,使 RecyclerView 滑动到底部的时候能够加载更多和自定义底部视图。
Stars: ✭ 179 (+231.48%)
Mutual labels:  retry
Toxy
Hackable HTTP proxy for resiliency testing and simulated network conditions
Stars: ✭ 2,698 (+4896.3%)
Mutual labels:  retry
request-on-steroids
An HTTP client ✨ with retry, circuit-breaker and tor support 📦 out-of-the-box
Stars: ✭ 19 (-64.81%)
Mutual labels:  retry
Safely
Safely is a Clojure's circuit-breaker library for handling retries in an elegant declarative way.
Stars: ✭ 152 (+181.48%)
Mutual labels:  retry
HTMLTestRunner cn
HTMLTestRunner 汉化版,同时支持python 2和3,增加截图展示功能,失败重试
Stars: ✭ 191 (+253.7%)
Mutual labels:  retry
esa-httpclient
An asynchronous event-driven HTTP client based on netty.
Stars: ✭ 82 (+51.85%)
Mutual labels:  retry
typescript-retry-decorator
lightweight typescript retry decorator with 0 dependency.
Stars: ✭ 50 (-7.41%)
Mutual labels:  retry
Retry4j
Lightweight Java library for retrying unreliable logic
Stars: ✭ 179 (+231.48%)
Mutual labels:  retry
Mug
A small Java 8 util library, complementary to Guava (BiStream, Substring, MoreStreams, Parallelizer).
Stars: ✭ 236 (+337.04%)
Mutual labels:  retry
jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (-33.33%)
Mutual labels:  retry
Resilient.js
Fault tolerant and reactive HTTP client for node.js and browsers
Stars: ✭ 172 (+218.52%)
Mutual labels:  retry
retrygroup
Package retrygroup provides synchronization, Context cancelation for groups of retry goroutines working on subtasks of a common task.
Stars: ✭ 18 (-66.67%)
Mutual labels:  retry
Kotlin Retry
A higher-order function for retrying operations that may fail.
Stars: ✭ 159 (+194.44%)
Mutual labels:  retry
View-Load-ReTry
这个加载框架有点不一样,针对View进行加载,加载页面还保持了原View的属性,侧重点在灵活,哪里需要加载哪里,加载状态页面完全自定义,无任何限制,针对加载结果可以按需配置对应页面,LeakCanary检测无内存泄漏
Stars: ✭ 116 (+114.81%)
Mutual labels:  retry
backoff
PHP library providing retry functionality with multiple backoff strategies and jitter support
Stars: ✭ 132 (+144.44%)
Mutual labels:  retry
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (-61.11%)
Mutual labels:  retry
php-backoff
Simple back off / retry functionality
Stars: ✭ 24 (-55.56%)
Mutual labels:  retry

Retry

Build Status Project status Go Report Card Coverage Status GoDoc License

Simple and easy retry mechanism package for Go

Installation

Install the package using

$ go get github.com/thedevsaddam/retry

Usage

To use the package import it in your *.go code

import "github.com/thedevsaddam/retry"

Example

Simply retry a function to execute for max 10 times with interval of 1 second

package main

import (
	"fmt"
	"time"

	"github.com/thedevsaddam/retry"
)

func main() {
	i := 1 // lets assume we expect i to be a value of 8
	err := retry.DoFunc(10, 1*time.Second, func() error {
		fmt.Printf("trying for: %dth time\n", i)
		i++
		if i > 7 {
			return nil
		}
		return fmt.Errorf("i = %d is still low value", i)
	})

	if err != nil {
		panic(err)
	}

	fmt.Println("Got our expected result: ", i)
}

We can execute function from other package with arguments and return values

package main

import (
	"errors"
	"log"
	"time"

	"github.com/thedevsaddam/retry"
)

func div(a, b float64) (float64, error) {
	if b == 0 {
		return 0, errors.New("Can not divide by zero")
	}
	return a / b, nil
}

func main() {
	a := 20.6
	b := 3.7 // if we assign 0.0 to b, it will cause an error and will retry for 3 times
	res, err := retry.Do(3, 5*time.Second, div, a, b)
	if err != nil {
		panic(err)
	}
	log.Println(res)
}

Contribution

If you are interested to make the package better please send pull requests or create an issue so that others can fix. Read the contribution guide here.

License

The retry is an open-source software licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].