client: add TLSConfig option

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-03-26 15:44:34 +03:00
parent 6189a1b980
commit 040fc4548f

View File

@ -2,6 +2,7 @@ package client
import ( import (
"context" "context"
"crypto/tls"
"time" "time"
"github.com/unistack-org/micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
@ -52,6 +53,8 @@ type Options struct {
PoolSize int PoolSize int
// PoolTTL connection pool ttl // PoolTTL connection pool ttl
PoolTTL time.Duration PoolTTL time.Duration
// TLSConfig specifies tls.Config for secure connection
TLSConfig *tls.Config
} }
// NewCallOptions creates new call options struct // NewCallOptions creates new call options struct
@ -312,6 +315,22 @@ func Lookup(l LookupFunc) Option {
} }
} }
// TLSConfig specifies a *tls.Config
func TLSConfig(t *tls.Config) Option {
return func(o *Options) {
// set the internal tls
o.TLSConfig = t
// set the default transport if one is not
// already set. Required for Init call below.
// set the transport tls
o.Transport.Init(
transport.TLSConfig(t),
)
}
}
// Retries sets the retry count when making the request. // Retries sets the retry count when making the request.
func Retries(i int) Option { func Retries(i int) Option {
return func(o *Options) { return func(o *Options) {