Skip to content

Commit

Permalink
add consul config center
Browse files Browse the repository at this point in the history
  • Loading branch information
dobyte committed Nov 6, 2023
1 parent c905327 commit b9b9e35
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
28 changes: 14 additions & 14 deletions cluster/master/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package master

import (
"context"
"github.com/dobyte/due/v2/config/configurator"
"github.com/dobyte/due/v2/config"
"github.com/dobyte/due/v2/crypto"
"github.com/dobyte/due/v2/encoding"
"github.com/dobyte/due/v2/etc"
Expand All @@ -29,17 +29,17 @@ const (
type Option func(o *options)

type options struct {
id string // 实例ID
name string // 实例名称
ctx context.Context // 上下文
codec encoding.Codec // 编解码器
timeout time.Duration // RPC调用超时时间
locator locate.Locator // 用户定位器
registry registry.Registry // 服务注册器
transporter transport.Transporter // 消息传输器
encryptor crypto.Encryptor // 消息加密器
configSource configurator.Source // 配置源
configurator configurator.Configurator // 配置器
id string // 实例ID
name string // 实例名称
ctx context.Context // 上下文
codec encoding.Codec // 编解码器
timeout time.Duration // RPC调用超时时间
locator locate.Locator // 用户定位器
registry registry.Registry // 服务注册器
transporter transport.Transporter // 消息传输器
encryptor crypto.Encryptor // 消息加密器
configSource config.Source // 配置源
configurator config.Configurator // 配置器
}

func defaultOptions() *options {
Expand Down Expand Up @@ -118,8 +118,8 @@ func WithEncryptor(encryptor crypto.Encryptor) Option {
}

// WithConfigSource 设置配置源
func WithConfigSource(configSource configurator.Source) Option {
func WithConfigSource(source config.Source) Option {
return func(o *options) {
o.configSource, o.configurator = configSource, configurator.NewConfigurator(configurator.WithSources(configSource))
o.configSource, o.configurator = source, config.NewConfigurator(config.WithSources(source))
}
}
4 changes: 2 additions & 2 deletions cluster/master/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package master
import (
"context"
"github.com/dobyte/due/v2/cluster"
"github.com/dobyte/due/v2/config/configurator"
"github.com/dobyte/due/v2/config"
"github.com/dobyte/due/v2/errors"
"github.com/dobyte/due/v2/internal/link"
"github.com/dobyte/due/v2/registry"
Expand Down Expand Up @@ -45,7 +45,7 @@ func (p *Proxy) GetMasterName() string {
}

// LoadConfig 加载配置
func (p *Proxy) LoadConfig(ctx context.Context, file string) ([]*configurator.Configuration, error) {
func (p *Proxy) LoadConfig(ctx context.Context, file string) ([]*config.Configuration, error) {
if p.master.opts.configurator != nil {
return p.master.opts.configurator.Load(ctx, p.master.opts.configSource.Name(), file)
}
Expand Down
2 changes: 2 additions & 0 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func (c *Container) Serve() {
log.Errorf("eventbus close failed: %v", err)
}

eventbus.Close()

task.Release()

config.Close()
Expand Down
7 changes: 4 additions & 3 deletions internal/link/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ func (l *Link) LocateGate(ctx context.Context, uid int64) (string, error) {
}

if gid == "" {
l.gateSource.Delete(uid)

return "", errors.ErrNotFoundUserLocation
}

Expand Down Expand Up @@ -606,7 +604,10 @@ func (l *Link) Deliver(ctx context.Context, args *DeliverArgs) error {
miss, err := client.Deliver(ctx, arguments)
return miss, nil, err
})
return err
if err != nil && err != errors.ErrNotFoundUserLocation {
return err
}
return nil
}
}

Expand Down

0 comments on commit b9b9e35

Please sign in to comment.