Пример #1
0
func NewConnectionMode(
	clients []mode.ProtocolClient,
	failover bool,
	maxAttempts int,
	waitRetry, timeout, maxWaitRetry time.Duration,
) (mode.ConnectionMode, error) {
	if failover {
		clients = NewFailoverClient(clients)
	}

	if len(clients) == 1 {
		return single.New(clients[0], maxAttempts, waitRetry, timeout, maxWaitRetry)
	}
	return lb.NewSync(clients, maxAttempts, waitRetry, timeout, maxWaitRetry)
}
Пример #2
0
func NewConnectionMode(
	clients []mode.ProtocolClient,
	s Settings,
) (mode.ConnectionMode, error) {
	if s.Failover {
		clients = NewFailoverClient(clients)
	}

	maxSend := s.MaxAttempts
	wait := s.WaitRetry
	maxWait := s.MaxWaitRetry
	to := s.Timeout

	if len(clients) == 1 {
		return single.New(clients[0], maxSend, wait, to, maxWait)
	}
	return lb.NewSync(clients, maxSend, wait, to, maxWait)
}