-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
387 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: All Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -timeout 300s -race -coverprofile=coverage.xml -covermode=atomic -v ./... | ||
#- uses: actions/checkout@master | ||
- uses: codecov/codecov-action@v1 | ||
with: | ||
files: ./coverage.xml | ||
flags: unittests # optional | ||
name: codecov-umbrella # optional | ||
fail_ci_if_error: true # optional (default = false) | ||
verbose: true # optional (default = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
.DS_Store | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Retry | ||
|
||
An essential retry-operation related library for Golang to build fault-tolerant system. | ||
|
||
## Usages: | ||
|
||
```go | ||
import("github.com/rbrahul/retry") | ||
``` | ||
|
||
### Retry the operation maximum 10 times in 3 seconds delay in between | ||
```go | ||
|
||
err := retry.Retry(func() bool { | ||
err := doesHeavyLifting() | ||
if err != nil { | ||
return true // retry operation | ||
} | ||
return false // No need to retry | ||
}, 10, 3*time.Second) | ||
|
||
if err != nil { | ||
fmt.Error("Maxium retry exceeded") | ||
} | ||
``` | ||
|
||
### Retry failed operations with a deadline of 1 minute and with a random interval of 2 to 10 seconds. | ||
|
||
```go | ||
err := retry.Retry(func() bool { | ||
err := doesHeavyLifting() | ||
if err != nil { | ||
return true // retry operation | ||
} | ||
return false // No need to retry | ||
}, 1 * time.Minute(), retry.RandomBackoff(2, 10)) | ||
|
||
if err == retry.ErrDeadlineExceeded { | ||
fmt.Error("Retry deadline exceeded") | ||
} | ||
|
||
``` | ||
### Retry failed operations with a maximum 10 retries and with an Custom Backoff function. | ||
|
||
```go | ||
err := retry.Retry(func() bool { | ||
err := doesHeavyLifting() | ||
if err != nil { | ||
return true // retry operation | ||
} | ||
return false // No need to retry | ||
}, 10, func(previousDelay uint64) uint64 { | ||
return previousDelay * 1.5 | ||
}) | ||
|
||
if err == retry.ErrMaximumRetryExceeded { | ||
fmt.Error("Maxium retry exceeded") | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.