Skip to content

Commit

Permalink
Drop var errors error
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav committed Apr 1, 2017
1 parent f3c69ff commit 21d80d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
23 changes: 10 additions & 13 deletions x/config/configurator.go
Expand Up @@ -195,32 +195,29 @@ func (c *Configurator) NewDispatcher(serviceName string, data interface{}) (*yar
return yarpc.NewDispatcher(cfg), nil
}

func (c *Configurator) load(serviceName string, cfg *yarpcConfig) (yarpc.Config, error) {
var (
errors error
b = newBuilder(serviceName, &Kit{name: serviceName, c: c})
)
func (c *Configurator) load(serviceName string, cfg *yarpcConfig) (_ yarpc.Config, err error) {
b := newBuilder(serviceName, &Kit{name: serviceName, c: c})

for _, inbound := range cfg.Inbounds {
if err := c.loadInboundInto(b, inbound); err != nil {
errors = multierr.Append(errors, err)
if e := c.loadInboundInto(b, inbound); e != nil {
err = multierr.Append(err, e)
}
}

for name, outboundConfig := range cfg.Outbounds {
if err := c.loadOutboundInto(b, name, outboundConfig); err != nil {
errors = multierr.Append(errors, err)
if e := c.loadOutboundInto(b, name, outboundConfig); e != nil {
err = multierr.Append(err, e)
}
}

for name, attrs := range cfg.Transports {
if err := c.loadTransportInto(b, name, attrs); err != nil {
errors = multierr.Append(errors, err)
if e := c.loadTransportInto(b, name, attrs); e != nil {
err = multierr.Append(err, e)
}
}

if errors != nil {
return yarpc.Config{}, errors
if err != nil {
return yarpc.Config{}, err
}

return b.Build()
Expand Down
10 changes: 5 additions & 5 deletions x/config/spec.go
Expand Up @@ -281,7 +281,7 @@ func (s *compiledTransportSpec) SupportsOnewayOutbound() bool {
return s.OnewayOutbound != nil
}

func compileTransportSpec(spec *TransportSpec) (_ *compiledTransportSpec, err error) {
func compileTransportSpec(spec *TransportSpec) (*compiledTransportSpec, error) {
out := compiledTransportSpec{Name: spec.Name}

if spec.Name == "" {
Expand All @@ -297,11 +297,11 @@ func compileTransportSpec(spec *TransportSpec) (_ *compiledTransportSpec, err er
return nil, errors.New("BuildTransport is required")
}

var errors error
var err error

// Helper to chain together the compile calls
appendError := func(cs *configSpec, err error) *configSpec {
errors = multierr.Append(errors, err)
appendError := func(cs *configSpec, e error) *configSpec {
err = multierr.Append(err, e)
return cs
}

Expand All @@ -315,7 +315,7 @@ func compileTransportSpec(spec *TransportSpec) (_ *compiledTransportSpec, err er
if spec.BuildOnewayOutbound != nil {
out.OnewayOutbound = appendError(compileOnewayOutboundConfig(spec.BuildOnewayOutbound))
}
return &out, errors
return &out, err
}

func compileTransportConfig(build interface{}) (*configSpec, error) {
Expand Down

0 comments on commit 21d80d5

Please sign in to comment.