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 RedialDelay on client #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ type Client struct {
// Default value is DefaultRequestTimeout.
RequestTimeout time.Duration

// Time to wait for redial.
// Default value is DefaultRedialDelay.
RedialDelay time.Duration

// Disable data compression.
// By default data compression is enabled.
DisableCompression bool
Expand Down Expand Up @@ -135,6 +139,9 @@ func (c *Client) Start() {
if c.RequestTimeout <= 0 {
c.RequestTimeout = DefaultRequestTimeout
}
if c.RedialDelay <= 0 {
c.RedialDelay = DefaultRedialDelay
}
if c.SendBufferSize <= 0 {
c.SendBufferSize = DefaultBufferSize
}
Expand Down Expand Up @@ -665,7 +672,7 @@ func clientHandler(c *Client) {
select {
case <-c.clientStopChan:
return
case <-time.After(time.Second):
case <-time.After(c.RedialDelay):
}
continue
}
Expand Down
3 changes: 3 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const (
// DefaultRequestTimeout is the default timeout for client request.
DefaultRequestTimeout = 20 * time.Second

// DefaultRedialDelay is the default delay before trying to redial.
DefaultRedialDelay = 1 * time.Second

// DefaultPendingMessages is the default number of pending messages
// handled by Client and Server.
DefaultPendingMessages = 32 * 1024
Expand Down