Skip to content

Commit

Permalink
Fix typos and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuravi committed Mar 9, 2017
1 parent 56cc486 commit 44c6c11
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
7 changes: 3 additions & 4 deletions modules/yarpc/yarpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (c *dispatcherController) Start(host service.Host, statsClient *statsClient

var cfg yarpc.Config
var err error
if cfg, err = c.createConfig(host.Name()); err != nil {
if cfg, err = c.mergeConfig(host.Name()); err != nil {
c.startError = err
return
}
Expand Down Expand Up @@ -336,9 +336,8 @@ func (c *dispatcherController) addDefaultMiddleware(host service.Host, statsClie
c.addConfig(cfg)
}

// Create the YARPC config : transports and middleware are going to be shared.
// The name comes from the first config in the collection and is the same among all configs.
func (c *dispatcherController) createConfig(advertiseName string) (conf yarpc.Config, err error) {
// Merge all YARPC config in the controller with the service name and middleware
func (c *dispatcherController) mergeConfig(advertiseName string) (conf yarpc.Config, err error) {
c.RLock()
defer c.RUnlock()

Expand Down
2 changes: 1 addition & 1 deletion modules/yarpc/yarpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestBindToBadPortReturnsError(t *testing.T) {
func TestMergeOfEmptyConfigCollectionReturnsError(t *testing.T) {
t.Parallel()
c := dispatcherController{}
_, err := c.createConfig("test")
_, err := c.mergeConfig("test")
assert.EqualError(t, err, "unable to merge empty configs")
host := service.NopHost()
assert.EqualError(t, c.Start(host, newStatsClient(host.Metrics())), err.Error())
Expand Down
16 changes: 10 additions & 6 deletions service/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,25 +385,29 @@ func (m *manager) startModules() []error {
// calls to return
wg.Add(len(m.moduleWrappers))
for _, mod := range m.moduleWrappers {
go func(modWrapper *moduleWrapper) {
if !modWrapper.IsRunning() {
go func(mw *moduleWrapper) {
if !mw.IsRunning() {
errC := make(chan error, 1)
go func() { errC <- modWrapper.Start() }()
go func() { errC <- mw.Start() }()
select {
case err := <-errC:
if err != nil {
zap.L().Error("Error received while starting module", zap.String("module", modWrapper.Name()), zap.Error(err))
zap.L().Error(
"Error received while starting module",
zap.String("module", mw.Name()),
zap.Error(err),
)
lock.Lock()
results = append(results, err)
lock.Unlock()
} else {
zap.L().Info("Module started up cleanly", zap.String("module", modWrapper.Name()))
zap.L().Info("Module started up cleanly", zap.String("module", mw.Name()))
}
case <-time.After(defaultStartupWait):
lock.Lock()
results = append(
results,
fmt.Errorf("module: %s didn't start after %v", modWrapper.Name(), defaultStartupWait),
fmt.Errorf("module: %s didn't start after %v", mw.Name(), defaultStartupWait),
)
lock.Unlock()
}
Expand Down
2 changes: 1 addition & 1 deletion service/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

// ModuleProvider provides Modules.
type ModuleProvider interface {
// DefaultName returns the module name
// DefaultName returns the default module name
DefaultName() string
// Create a new Module. The name of the Host and the scoping
// of associated functions on the Host will be done using a name
Expand Down

0 comments on commit 44c6c11

Please sign in to comment.