rename naming

pull/732/head
longXboy 4 years ago
parent 68e857746d
commit f984dc5c6d
  1. 14
      app.go
  2. 8
      options.go
  3. 12
      transport/grpc/client.go

@ -57,9 +57,9 @@ func (a *App) Server() []transport.Server {
return a.opts.servers
}
// Registry returns registry.
func (a *App) Registry() registry.Registrar {
return a.opts.registry
// Registrar returns registry.
func (a *App) Registrar() registry.Registrar {
return a.opts.registrar
}
// Run executes all OnStart hooks registered with the application's Lifecycle.
@ -80,8 +80,8 @@ func (a *App) Run() error {
return srv.Start()
})
}
if a.opts.registry != nil {
if err := a.opts.registry.Register(a.opts.ctx, a.instance); err != nil {
if a.opts.registrar != nil {
if err := a.opts.registrar.Register(a.opts.ctx, a.instance); err != nil {
return err
}
}
@ -105,8 +105,8 @@ func (a *App) Run() error {
// Stop gracefully stops the application.
func (a *App) Stop() error {
if a.opts.registry != nil {
if err := a.opts.registry.Deregister(a.opts.ctx, a.instance); err != nil {
if a.opts.registrar != nil {
if err := a.opts.registrar.Deregister(a.opts.ctx, a.instance); err != nil {
return err
}
}

@ -24,7 +24,7 @@ type options struct {
sigs []os.Signal
logger log.Logger
registry registry.Registrar
registrar registry.Registrar
servers []transport.Server
}
@ -69,9 +69,9 @@ func Logger(logger log.Logger) Option {
return func(o *options) { o.logger = logger }
}
// Registry with service registry.
func Registry(r registry.Registrar) Option {
return func(o *options) { o.registry = r }
// Registrar with service registry.
func Registrar(r registry.Registrar) Option {
return func(o *options) { o.registrar = r }
}
// Server with transport servers.

@ -38,10 +38,10 @@ func WithMiddleware(m middleware.Middleware) ClientOption {
}
}
// WithDiscovery with client registry.
func WithDiscovery(r registry.Discoverer) ClientOption {
// WithDiscoverer with client registry.
func WithDiscoverer(d registry.Discoverer) ClientOption {
return func(o *clientOptions) {
o.discovery = r
o.discoverer = d
}
}
@ -57,7 +57,7 @@ type clientOptions struct {
endpoint string
timeout time.Duration
middleware middleware.Middleware
discovery registry.Discoverer
discoverer registry.Discoverer
grpcOpts []grpc.DialOption
}
@ -86,8 +86,8 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien
grpc.WithTimeout(options.timeout),
grpc.WithUnaryInterceptor(UnaryClientInterceptor(options.middleware)),
}
if options.discovery != nil {
grpc.WithResolvers(discovery.NewBuilder(options.discovery))
if options.discoverer != nil {
grpc.WithResolvers(discovery.NewBuilder(options.discoverer))
}
if insecure {
grpcOpts = append(grpcOpts, grpc.WithInsecure())

Loading…
Cancel
Save