Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backoff system implementation #1

Merged
merged 13 commits into from Oct 12, 2021
Merged

Add backoff system implementation #1

merged 13 commits into from Oct 12, 2021

Conversation

petar
Copy link
Contributor

@petar petar commented Mar 10, 2020

Highlights:

  • Abstract definition of a backoff strategy (which is more expressive than the one in go-libp2p-discovery), e.g. it allows handling backoff bursts
  • Add "backoff policy" which is a factory for backoff strategies. BackoffPolicy also offers a more idiomatic way of creating factories in Go, by utilizing the type system
  • Add implementation of hierarchical backoff timers
  • Add implementation of the shared backoffs interface (in go-libp2p-core/backoff). This is the entrypoint for all users of this library.

This PR depends on: libp2p/go-libp2p-core#127

go.mod Outdated
@@ -0,0 +1,11 @@
module github.com/libp2p/go-libp2p-backoff

replace github.com/libp2p/go-libp2p-core => /Users/petar/src/github.com/libp2p/go-libp2p-core

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove


var BackoffGCInterval = time.Minute

func (t *BackoffTreeTimer) StartGC() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a task like this should probably run within a context so that it can be completed on shutdown.

}
}

func TestTimerGC2(t *testing.T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test with two children subtimers active in different go-routines would be potentially useful to find races.

@marten-seemann marten-seemann merged commit d41119a into master Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants