コード例 #1
0
ファイル: modeutil.go プロジェクト: ChongFeng/beats
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
ファイル: modeutil.go プロジェクト: YaSuenag/hsbeat
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)
}