Skip to content

Commit

Permalink
Merge branch 'master' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Feb 16, 2019
2 parents dab0997 + a977c7f commit 3d37643
Show file tree
Hide file tree
Showing 31 changed files with 171 additions and 1,253 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
.github export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.goreleaser.yml 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.

9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ go:
- 1.8.x
- 1.9.x
- 1.10.x

matrix:
allow_failures:
- go: master
fast_finish: true
- 1.11.x

sudo: false

before_install:
- export GO15VENDOREXPERIMENT=1
- export GO111MODULE=on

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

after_success:
- echo $TRAVIS_GO_VERSION ":" $TRAVIS_TAG
- if [[ $TRAVIS_GO_VERSION == 1.10* ]] && [ -n "$TRAVIS_TAG" ]; then curl -sL https://git.io/goreleaser | bash; fi
- if [[ $TRAVIS_GO_VERSION == 1.11* ]] && [ -n "$TRAVIS_TAG" ]; then curl -sL https://git.io/goreleaser | bash; fi

notifications:
slack: octolab:1eMS7IqOArBipiu31jYVd0cN
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 OctoLab, https://www.octolab.org/ <[email protected]>
Copyright (c) 2019 OctoLab, https://www.octolab.org/ <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
68 changes: 53 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,58 @@
OPEN_BROWSER =
SUPPORTED_VERSIONS = 1.5 1.6 1.7 1.8 1.9 1.10 latest
PACKAGES := go list ./... | grep -v vendor | grep -v ^_
SHELL ?= /bin/bash -euo pipefail


include makes/env.mk
include makes/docker.mk
include makes/local.mk
include cmd/retry/Makefile
.PHONY: test
test: #| Runs tests with race.
#| Accepts: ARGS.
#| Uses: PACKAGES.
$(PACKAGES) | xargs go test -race $(strip $(ARGS))

.PHONY: test-check
test-check: #| Fast runs tests to check their compilation errors.
#| Accepts: ARGS.
#| Uses: PACKAGES.
$(PACKAGES) | xargs go test -run=^hack $(strip $(ARGS))

.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-with-coverage
test-with-coverage: #| Runs tests with coverage.
#| Accepts: ARGS.
#| Uses: PACKAGES.
$(PACKAGES) | xargs go test -cover $(strip $(ARGS))

.PHONY: code-quality-report
code-quality-report:
time make code-quality-check | tail +7 | tee report.out
.PHONY: test-with-coverage-formatted
test-with-coverage-formatted: #| Runs tests with coverage and formats the result.
#| Accepts: ARGS.
#| Uses: PACKAGES.
$(PACKAGES) | xargs go test -cover $(strip $(ARGS)) | column -t | sort -r

.PHONY: test-with-coverage-profile
test-with-coverage-profile: #| Runs tests with coverage and collects the result.
#| Accepts: ARGS.
#| Uses: PACKAGES.
echo 'mode: count' > cover.out
for package in $$($(PACKAGES)); do \
go test -covermode count \
-coverprofile "coverage_$${package##*/}.out" \
$(strip $(ARGS)) "$${package}"; \
if [ -f "coverage_$${package##*/}.out" ]; then \
sed 1d "coverage_$${package##*/}.out" >> cover.out; \
rm "coverage_$${package##*/}.out"; \
fi \
done

.PHONY: test-example
test-example: #| Runs example tests with coverage and collects the result.
#| Accepts: ARGS.
#| Uses: PACKAGES.
echo 'mode: count' > coverage_example.out
for package in $$($(PACKAGES)); do \
go test -v -run=Example \
-covermode count \
-coverprofile "coverage_example_$${package##*/}.out" \
$(strip $(ARGS)) "$${package}"; \
if [ -f "coverage_$${package##*/}.out" ]; then \
sed 1d "coverage_example_$${package##*/}.out" >> coverage_example.out; \
rm "coverage_example_$${package##*/}.out"; \
fi \
done
82 changes: 43 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
> # ♻️ 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)

## Differences from [Rican7/retry](https://github.com/Rican7/retry)

- Fixed [bug](https://github.com/Rican7/retry/pull/2) with an unexpected infinite loop.
- Added a clear mechanism for this purpose as the Infinite [strategy](strategy/strategy.go#L24-L28).
- Added support of cancellation (based on simple channel, e.g. `context.Done`).
- Made honest Action execution.
- Added `error` transmission between attempts.
- Added `classifier` to handle them (see [classifier](classifier) package).
- Added CLI tool `retry` which provides functionality for repeating terminal commands (see [cmd/retry](cmd/retry)).
[![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]

## Usage

Expand Down Expand Up @@ -160,43 +150,57 @@ $ # 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][semver] 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/master?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=v3
[research]: https://github.com/kamilsk/go-research/tree/master/projects/retry
[v3]: https://github.com/kamilsk/retry/tree/v3
[v4]: https://github.com/kamilsk/retry/tree/v4
[v4_features]: https://github.com/kamilsk/retry/projects/4

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

[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/v3?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=master
[icon_coverage]: https://scrutinizer-ci.com/g/kamilsk/retry/badges/coverage.png?b=master
[icon_build]: https://travis-ci.org/kamilsk/retry.svg?branch=v3
[icon_coverage]: https://scrutinizer-ci.com/g/kamilsk/retry/badges/coverage.png?b=v3
[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=master
[icon_quality]: https://scrutinizer-ci.com/g/kamilsk/retry/badges/quality-score.png?b=v3
[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=master

[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
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(deadline.Sub(time.Now())) // nolint: gosimple
close(ch)
}()
return ch
Expand Down
21 changes: 21 additions & 0 deletions cmd/retry/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 OctoLab, https://www.octolab.org/ <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit 3d37643

Please sign in to comment.