1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-24 08:02:32 +02:00

add tls option for sync etcd plugin (#2440)

This commit is contained in:
AlkaidChen 2022-02-24 17:07:14 +08:00 committed by GitHub
parent 69b4b5d1c6
commit 4154ed6a80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -165,6 +165,7 @@ func NewSync(opts ...sync.Option) sync.Sync {
// TODO: parse addresses
c, err := clientv3.New(clientv3.Config{
Endpoints: endpoints,
TLS: options.TLSConfig,
})
if err != nil {
log.Fatal(err)

View File

@ -1,6 +1,7 @@
package sync
import (
"crypto/tls"
"time"
)
@ -31,3 +32,10 @@ func LockWait(t time.Duration) LockOption {
o.Wait = t
}
}
// WithTLS sets the TLS config
func WithTLS(t *tls.Config) Option {
return func(o *Options) {
o.TLSConfig = t
}
}

View File

@ -2,6 +2,7 @@
package sync
import (
"crypto/tls"
"errors"
"time"
)
@ -35,8 +36,9 @@ type Leader interface {
}
type Options struct {
Nodes []string
Prefix string
Nodes []string
Prefix string
TLSConfig *tls.Config
}
type Option func(o *Options)