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

node, sdk/node: add options to configure reconnection backoff #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lithdew
Copy link
Owner

@lithdew lithdew commented Jul 4, 2020

Fixes #10.

@lithdew lithdew added the enhancement New feature or request label Jul 4, 2020
@lithdew lithdew self-assigned this Jul 4, 2020
Copy link

@didip didip left a comment

Choose a reason for hiding this comment

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

Can 0 be no reconnect and -1 be forever retry?

Services map[string]flatend.Handler

// Total number of attempts to reconnect to a peer we reached that disconnected.
// Default is 8 attempts, set to a negative integer to not attempt to reconnect at all.
Copy link

Choose a reason for hiding this comment

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

Can 0 be no reconnect and -1 be forever retry?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I tried to figure a way to do that, though I wonder how we could force the default value for NumReconnectAttempts to be 8 in that case. The only idiomatic way I could think of is to switch to functional options, or to encapsulate options into a separate Options struct with sensible defaults, though might you have any suggestions?

Copy link

Choose a reason for hiding this comment

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

When I do services in Go, typically I create some kind of config object which can be use by main.go. So the main program is the one that is setting the defaults. User can then set parameters on main.go to override the defaults.

Copy link

Choose a reason for hiding this comment

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

@lithdew Why did you choose 8 as default?

README.md Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
3 participants