Esempio n. 1
0
func newAsyncWorker(
	id int,
	client mode.AsyncProtocolClient,
	ctx context,
	waitRetry, maxWaitRetry time.Duration,
) *asyncWorker {
	return &asyncWorker{
		id:      id,
		client:  client,
		backoff: common.NewBackoff(ctx.done, waitRetry, maxWaitRetry),
		ctx:     ctx,
	}
}
Esempio n. 2
0
// New creates a new single connection mode using exactly one
// ProtocolClient connection.
func New(
	client mode.ProtocolClient,
	maxAttempts int,
	waitRetry, timeout, maxWaitRetry time.Duration,
) (*Mode, error) {
	s := &Mode{
		conn: client,

		timeout:     timeout,
		backoff:     common.NewBackoff(nil, waitRetry, maxWaitRetry),
		maxAttempts: maxAttempts,
	}

	return s, nil
}