Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pool_options.go « client - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc38132c1419ebced17e2491de3d64bd1d7445d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package client

import "google.golang.org/grpc"

type poolOptions struct {
	dialer      Dialer
	dialOptions []grpc.DialOption
}

//nolint:stylecheck // This is unintentionally missing documentation.
type PoolOption func(*poolOptions)

func applyPoolOptions(options []PoolOption) *poolOptions {
	opts := defaultPoolOptions()
	for _, opt := range options {
		opt(opts)
	}
	return opts
}

func defaultPoolOptions() *poolOptions {
	return &poolOptions{
		dialer: DialContext,
	}
}

// WithDialer sets the dialer that is called for each new gRPC connection the pool establishes.
func WithDialer(dialer Dialer) PoolOption {
	return func(options *poolOptions) {
		options.dialer = dialer
	}
}

// WithDialOptions sets gRPC options to use for the gRPC Dial call.
func WithDialOptions(dialOptions ...grpc.DialOption) PoolOption {
	return func(options *poolOptions) {
		options.dialOptions = dialOptions
	}
}