Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindiu authored and actions-user committed Oct 2, 2020
1 parent 275eeae commit f45dcf0
Show file tree
Hide file tree
Showing 2 changed files with 299 additions and 427 deletions.
28 changes: 24 additions & 4 deletions internal/db/nosql/cassandra/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,51 +295,71 @@ func WithRetryPolicyNumRetries(n int) Option {
}
}

// WithRetryPolicyMinDuration returns the option to set the retry min duration
func WithRetryPolicyMinDuration(minDuration string) Option {
return func(c *client) error {
if len(minDuration) == 0 {
return errors.NewErrInvalidOption("retryPolicyMinDuration", minDuration)
}
d, err := timeutil.Parse(minDuration)
if err != nil {
return err
return errors.NewErrCriticalOption("retryPolicyMinDuration", minDuration, err)
}
c.retryPolicy.minDuration = d
return nil
}
}

// WithRetryPolicyMaxDuration returns the option to set the retry max duration
func WithRetryPolicyMaxDuration(maxDuration string) Option {
return func(c *client) error {
if len(maxDuration) == 0 {
return errors.NewErrInvalidOption("retryPolicyMaxDuration", maxDuration)
}
d, err := timeutil.Parse(maxDuration)
if err != nil {
return err
return errors.NewErrCriticalOption("retryPolicyMaxDuration", maxDuration, err)
}
c.retryPolicy.maxDuration = d
return nil
}
}

// WithReconnectionPolicyInitialInterval returns the option to set the reconnect initial interval
func WithReconnectionPolicyInitialInterval(initialInterval string) Option {
return func(c *client) error {
if len(initialInterval) == 0 {
return errors.NewErrInvalidOption("reconnectionPolicyInitialInterval", initialInterval)
}
d, err := timeutil.Parse(initialInterval)
if err != nil {
return err
return errors.NewErrCriticalOption("reconnectionPolicyInitialInterval", initialInterval, err)
}
c.reconnectionPolicy.initialInterval = d
return nil
}
}

// WithReconnectionPolicyMaxRetries returns the option to set the reconnect max retries
func WithReconnectionPolicyMaxRetries(maxRetries int) Option {
return func(c *client) error {
if maxRetries < 0 {
return errors.NewErrInvalidOption("maxRetries", maxRetries)
}
c.reconnectionPolicy.maxRetries = maxRetries
return nil
}
}

// WithSocketKeepalive returns the option to set the socket keepalive time
func WithSocketKeepalive(socketKeepalive string) Option {
return func(c *client) error {
if len(socketKeepalive) == 0 {
return errors.NewErrInvalidOption("socketKeepalive", socketKeepalive)
}
d, err := timeutil.Parse(socketKeepalive)
if err != nil {
return err
return errors.NewErrCriticalOption("socketKeepalive", socketKeepalive, err)
}
c.socketKeepalive = d
return nil
Expand Down
Loading

0 comments on commit f45dcf0

Please sign in to comment.