jpillora / backoff Goto Github PK
View Code? Open in Web Editor NEWSimple backoff algorithm in Go (golang)
License: MIT License
Simple backoff algorithm in Go (golang)
License: MIT License
I just observed the circle ci is still enabled for this project.
Can this be disabled?
So dep can use it.
Describe the bug
Run time.Sleep(ws.backoff.Duration()) \\ ws.backoff != nil
in arm v7 get a runtime error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11e34]
goroutine 51 [running]:
runtime/internal/atomic.goXadd64(0x3db8bcc, 0x1, 0x0, 0x3ea8000, 0x3e9a5e8)
/usr/local/go/src/runtime/internal/atomic/atomic_arm.go:103 +0x1c
github.com/jpillora/backoff.(*Backoff).Duration(0x3db8bcc, 0xf20220, 0x1cbc5c8)
/go/pkg/mod/github.com/jpillora/[email protected]/backoff.go:30 +0x30
Environment:
Analyze:
See: #5 (comment)
@DrTall I'm yet to see a use-case where a concurrent backoff timer is required. Do you have a particular case in mind?
Currently in the circle ci i am unable to view the pipeline for this project. Also from what i observed in pr #18 the ci is not running for PR
I propose to use github actions for CI
I love examples of small, focused tools like this. Great work!
I was wondering if it wouldn't make sense to add a MaxTries:
property to indicate that the caller should give up and return an error. Here's a strawman example:
b := &backoff.Backoff{
Max: 5 * time.Minute,
MaxTries: 100,
}
for {
conn, err := net.Dial("tcp", "example.com:5309")
if err != nil {
if b.AtMaxTries() {
fmt.Printf("%s, giving up after %s tries.", err, b.MaxTries)
return errors.New("Connection Failed")
}
d := b.Duration()
fmt.Printf("%s, reconnecting in %s", err, d)
time.Sleep(d)
continue
}
//connected
b.Reset()
conn.Write([]byte("hello world!"))
// ... Read ... Write ... etc
conn.Close()
//disconnected
}
This could also be done by returning err, duration
from b.Duration
, where an error indicates that the max number of attempts have occurred, but that would muddy the interface for times when there is no maximum.
In my opinion this repo would attract a lot if new contributors if you can add "hacktoberfest" topic to this repository
More info - https://hacktoberfest.com/participation/#pr-mr-details
Hi !
Do you mind if I include the backoff.go file in one of my libraries? Obviously, I'll credit the authors and provide links to the original repo. My library is also MIT licensed.
It's fine if you don't allow that, I'll have to look for another library, but I really love this one because it's so small and easy to understand and just 1 file. I don't want to use a huge, bloated library.
Thank you !
Great library. Could benefit from the use of a LICENSE file in the root of the repo.
https://github.com/blog/1530-choosing-an-open-source-license
When we use the library, if we don't call Reset() forever, numeric overflow is generated
In ForAttempt(), "durf" variable is float64.
durf := minf * math.Pow(factor, attempt)
but, "dur" variable is int64
dur := time.Duration(durf)
so, if the range of "durf" over the range of "dur", "dur" variable is overflowed.
I see tests as a behavior documentation of the method under test. Currently i see tests of the name Test1
, Test2
,Test3
etc the intent of which is only understood upon reading the test itself.
I propose refactoring the test names to better describe the scenario that is being tested.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.