Skip to content

Commit

Permalink
Merge branch 'v3' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Feb 16, 2019
2 parents fdc0bc8 + 0d8df3f commit cac6d1f
Show file tree
Hide file tree
Showing 404 changed files with 236 additions and 222,845 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
.github export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.goreleaser.yml export-ignore
.travis.yml export-ignore

/makes/ export-ignore
/Makefile export-ignore

*.md export-ignore
Expand Down
41 changes: 0 additions & 41 deletions .github/CHECKLIST.md

This file was deleted.

5 changes: 0 additions & 5 deletions .github/CODE_OF_CONDUCT.md

This file was deleted.

28 changes: 0 additions & 28 deletions .github/CONTRIBUTING.md

This file was deleted.

Empty file removed .github/ISSUE_TEMPLATE.md
Empty file.
Empty file removed .github/PULL_REQUEST_TEMPLATE.md
Empty file.
32 changes: 0 additions & 32 deletions .scrutinizer.yml

This file was deleted.

8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ language: go
go:
- master
- 1.x
- 1.9.x
- 1.10.x
- 1.11.x

matrix:
fast_finish: true

sudo: false

before_install:
- export GO111MODULE=on

script:
- make test ARGS='-timeout=1s'

Expand Down
44 changes: 25 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
OPEN_BROWSER =
SUPPORTED_VERSIONS = 1.9 1.10 1.11 latest
SHELL := /bin/bash -euo pipefail


include makes/env.mk
include makes/docker.mk
include makes/local.mk
include cmd/retry/Makefile
.PHONY: generate
generate:
go generate ./cmd/generate
mv ./cmd/generate/parser_gen.go ./cmd/retry/parser_gen.go


.PHONY: code-quality-check
code-quality-check: ARGS = \
--exclude=".*_test\.go:.*error return value not checked.*\(errcheck\)$$" \
--exclude="duplicate of.*_test.go.*\(dupl\)$$" \
--vendor --deadline=1m ./... | sort
code-quality-check: docker-tool-gometalinter
.PHONY: test
test: #| Runs tests with race.
go test -race ./...

.PHONY: code-quality-report
code-quality-report:
time make code-quality-check | tail +7 | tee report.out
.PHONY: test-check
test-check: #| Fast runs tests to check their compilation errors.
go test -run=^hack ./...

.PHONY: test-with-coverage
test-with-coverage: #| Runs tests with coverage.
go test -cover ./...

.PHONY: generate
generate:
go generate ./cmd/generate
mv ./cmd/generate/parser_gen.go ./cmd/retry/parser_gen.go
.PHONY: test-with-coverage-formatted
test-with-coverage-formatted: #| Runs tests with coverage and formats the result.
go test -cover ./... | column -t | sort -r

.PHONY: test-with-coverage-profile
test-with-coverage-profile: #| Runs tests with coverage and collects the result.
go test -covermode count -coverprofile cover.out ./...

.PHONY: test-example
test-example: #| Runs example tests with coverage and collects the result.
go test -covermode count -coverprofile -run=Example -v example.out ./...
79 changes: 46 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
> # ♻️ retry [![Tweet][icon_twitter]][twitter_publish]
> [![Analytics][analytics_pixel]][page_promo]
> # ♻️ retry
>
> Functional mechanism based on channels to perform actions repetitively until successful.
[![Awesome][icon_awesome]](https://github.com/avelino/awesome-go#utilities)
[![Patreon][icon_patreon]](https://www.patreon.com/octolab)
[![Build Status][icon_build]][page_build]
[![Code Coverage][icon_coverage]][page_quality]
[![Code Quality][icon_quality]][page_quality]
[![GoDoc][icon_docs]][page_docs]
[![Research][icon_research]][page_research]
[![License][icon_license]](LICENSE)
[![Awesome][icon_awesome]][awesome]
[![Patreon][icon_patreon]][support]
[![Build Status][icon_build]][build]
[![Code Coverage][icon_coverage]][quality]
[![Code Quality][icon_quality]][quality]
[![GoDoc][icon_docs]][docs]
[![Research][icon_research]][research]
[![License][icon_license]][license]

## Important news

The **master** is a feature frozen branch for versions _3.3.x_ and no longer maintained.
The **[master][legacy]** is a feature frozen branch for versions _3.3.x_ and no longer maintained.

```bash
$ dep ensure -add github.com/kamilsk/[email protected].1
$ dep ensure -add github.com/kamilsk/[email protected].2
```

The **[v3][]** branch is a continuation of the **master** branch for versions _v3.4.y_
to better integration with [Go Modules][gomod].

```bash
$ go get -u github.com/kamilsk/retry/[email protected].2
$ go get -u github.com/kamilsk/retry/[email protected].3
```

The **[v4][]** branch is an actual development branch with many [features][v4_features].
The **v4** branch is an actual development branch with many [features][v4_features].

```bash
$ go get -u github.com/kamilsk/retry/v4
Expand Down Expand Up @@ -171,43 +171,56 @@ $ # or use mirror
$ egg bitbucket.org/kamilsk/retry
```

> [egg](https://github.com/kamilsk/egg)<sup id="anchor-egg">[1](#egg)</sup> is an `extended go get`.
> [egg][]<sup id="anchor-egg">[1](#egg)</sup> is an `extended go get`.
## Update

This library is using [SemVer](http://semver.org) for versioning, and it is not
This library is using [SemVer](https://semver.org/) for versioning, and it is not
[BC](https://en.wikipedia.org/wiki/Backward_compatibility)-safe. Therefore, do not use `go get -u` to update it,
use [dep](https://github.com/golang/dep) or something similar for this purpose.
use **dep**, **glide** or something similar for this purpose.

<sup id="egg">1</sup> The project is still in prototyping. [](#anchor-egg)

---

[![Gitter][icon_gitter]](https://gitter.im/kamilsk/retry)
[![@kamilsk][icon_tw_author]](https://twitter.com/ikamilsk)
[![@octolab][icon_tw_sponsor]](https://twitter.com/octolab_inc)
[![Gitter][icon_gitter]][gitter]
[![@kamilsk][icon_tw_author]][author]
[![@octolab][icon_tw_sponsor]][sponsor]

made with ❤️ by [OctoLab](https://www.octolab.org/)
made with ❤️ by [OctoLab][octolab]

[analytics_pixel]: https://ga-beacon.appspot.com/UA-109817251-1/retry/dev?pixel
[awesome]: https://github.com/avelino/awesome-go#utilities
[build]: https://travis-ci.org/kamilsk/retry
[docs]: https://godoc.org/github.com/kamilsk/retry
[gitter]: https://gitter.im/kamilsk/retry
[license]: LICENSE
[promo]: https://github.com/kamilsk/retry
[quality]: https://scrutinizer-ci.com/g/kamilsk/retry/?branch=v4
[research]: https://github.com/kamilsk/go-research/tree/master/projects/retry
[legacy]: https://github.com/kamilsk/retry/tree/master
[v3]: https://github.com/kamilsk/retry/tree/v3
[v4_features]: https://github.com/kamilsk/retry/projects/4

[egg]: https://github.com/kamilsk/egg
[gomod]: https://github.com/golang/go/wiki/Modules

[author]: https://twitter.com/ikamilsk
[octolab]: https://www.octolab.org/
[sponsor]: https://twitter.com/octolab_inc
[support]: https://www.patreon.com/octolab

[analytics]: https://ga-beacon.appspot.com/UA-109817251-1/retry/v4?pixel
[tweet]: https://twitter.com/intent/tweet?text=Functional%20mechanism%20based%20on%20channels%20to%20perform%20actions%20repetitively%20until%20successful&url=https://github.com/kamilsk/retry&via=ikamilsk&hashtags=go,repeat,retry,backoff,jitter

[icon_awesome]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
[icon_build]: https://travis-ci.org/kamilsk/retry.svg?branch=dev
[icon_coverage]: https://scrutinizer-ci.com/g/kamilsk/retry/badges/coverage.png?b=dev
[icon_build]: https://travis-ci.org/kamilsk/retry.svg?branch=v4
[icon_coverage]: https://scrutinizer-ci.com/g/kamilsk/retry/badges/coverage.png?b=v4
[icon_docs]: https://godoc.org/github.com/kamilsk/retry?status.svg
[icon_gitter]: https://badges.gitter.im/Join%20Chat.svg
[icon_license]: https://img.shields.io/badge/license-MIT-blue.svg
[icon_patreon]: https://img.shields.io/badge/patreon-donate-orange.svg
[icon_quality]: https://scrutinizer-ci.com/g/kamilsk/retry/badges/quality-score.png?b=dev
[icon_quality]: https://scrutinizer-ci.com/g/kamilsk/retry/badges/quality-score.png?b=v4
[icon_research]: https://img.shields.io/badge/research-in%20progress-yellow.svg
[icon_tw_author]: https://img.shields.io/badge/author-%40kamilsk-blue.svg
[icon_tw_sponsor]: https://img.shields.io/badge/sponsor-%40octolab-blue.svg
[icon_twitter]: https://img.shields.io/twitter/url/http/shields.io.svg?style=social

[page_build]: https://travis-ci.org/kamilsk/retry
[page_docs]: https://godoc.org/github.com/kamilsk/retry
[page_promo]: https://github.com/kamilsk/retry
[page_research]: https://github.com/kamilsk/go-research/tree/master/projects/retry
[page_quality]: https://scrutinizer-ci.com/g/kamilsk/retry/?branch=dev

[twitter_publish]: https://twitter.com/intent/tweet?text=Functional%20mechanism%20based%20on%20channels%20to%20perform%20actions%20repetitively%20until%20successful&url=https://github.com/kamilsk/retry&via=ikamilsk&hashtags=go,repeat,retry,backoff,jitter
12 changes: 6 additions & 6 deletions backoff/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"testing"
"time"

"github.com/kamilsk/retry/v4/backoff"
. "github.com/kamilsk/retry/v4/backoff"
)

func TestIncremental(t *testing.T) {
const duration = time.Millisecond
const increment = time.Nanosecond

algorithm := backoff.Incremental(duration, increment)
algorithm := Incremental(duration, increment)

for i := uint(0); i < 10; i++ {
result := algorithm(i)
Expand All @@ -27,7 +27,7 @@ func TestIncremental(t *testing.T) {
func TestLinear(t *testing.T) {
const duration = time.Millisecond

algorithm := backoff.Linear(duration)
algorithm := Linear(duration)

for i := uint(0); i < 10; i++ {
result := algorithm(i)
Expand All @@ -43,7 +43,7 @@ func TestExponential(t *testing.T) {
const duration = time.Second
const base = 3

algorithm := backoff.Exponential(duration, base)
algorithm := Exponential(duration, base)

for i := uint(0); i < 10; i++ {
result := algorithm(i)
Expand All @@ -58,7 +58,7 @@ func TestExponential(t *testing.T) {
func TestBinaryExponential(t *testing.T) {
const duration = time.Second

algorithm := backoff.BinaryExponential(duration)
algorithm := BinaryExponential(duration)

for i := uint(0); i < 10; i++ {
result := algorithm(i)
Expand All @@ -74,7 +74,7 @@ func TestFibonacci(t *testing.T) {
const duration = time.Millisecond
sequence := []uint{0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233}

algorithm := backoff.Fibonacci(duration)
algorithm := Fibonacci(duration)

for i := uint(0); i < 10; i++ {
result := algorithm(i)
Expand Down
2 changes: 1 addition & 1 deletion channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func WithDeadline(deadline time.Time) <-chan struct{} {
return ch
}
go func() {
<-time.After(deadline.Sub(time.Now()))
<-time.After(time.Until(deadline))
close(ch)
}()
return ch
Expand Down
Loading

0 comments on commit cac6d1f

Please sign in to comment.