add backend

Browse Source
main
git 2024-05-25 01:13:08 +08:00
parent 4132d48e71
commit 626d43ede8
Signed by: git
GPG Key ID: 3F65EFFA44207ADD
3 changed files with 8 additions and 5 deletions

View File

@ -20,11 +20,12 @@ type etcdBackend struct {
client *clientv3.Client client *clientv3.Client
} }
func New(ctx context.Context, cnf *config.Config) (iface.Backend, error) { func New(ctx context.Context, conf *config.Config) (iface.Backend, error) {
etcdConf := clientv3.Config{ etcdConf := clientv3.Config{
Endpoints: []string{cnf.ResultBackend}, Endpoints: []string{conf.ResultBackend},
Context: ctx, Context: ctx,
DialTimeout: time.Second * 5, DialTimeout: time.Second * 5,
TLS: conf.TLSConfig,
} }
client, err := clientv3.New(etcdConf) client, err := clientv3.New(etcdConf)
if err != nil { if err != nil {
@ -32,10 +33,10 @@ func New(ctx context.Context, cnf *config.Config) (iface.Backend, error) {
} }
backend := etcdBackend{ backend := etcdBackend{
Backend: common.NewBackend(cnf), Backend: common.NewBackend(conf),
ctx: ctx, ctx: ctx,
client: client, client: client,
conf: cnf, conf: conf,
} }
return &backend, nil return &backend, nil

View File

@ -59,9 +59,10 @@ type etcdBroker struct {
// New .. // New ..
func New(ctx context.Context, conf *config.Config) (iface.Broker, error) { func New(ctx context.Context, conf *config.Config) (iface.Broker, error) {
etcdConf := clientv3.Config{ etcdConf := clientv3.Config{
Endpoints: []string{conf.Broker}, Endpoints: []string{conf.Lock},
Context: ctx, Context: ctx,
DialTimeout: time.Second * 5, DialTimeout: time.Second * 5,
TLS: conf.TLSConfig,
} }
client, err := clientv3.New(etcdConf) client, err := clientv3.New(etcdConf)

View File

@ -31,6 +31,7 @@ func New(ctx context.Context, conf *config.Config, retries int) (iface.Lock, err
Endpoints: []string{conf.Lock}, Endpoints: []string{conf.Lock},
Context: ctx, Context: ctx,
DialTimeout: time.Second * 5, DialTimeout: time.Second * 5,
TLS: conf.TLSConfig,
} }
client, err := clientv3.New(etcdConf) client, err := clientv3.New(etcdConf)