Skip to content

Commit

Permalink
Rename Start() to Run() since it's a blocking call (#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilebox committed Sep 16, 2020
1 parent 471c4a6 commit 397c8de
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## 🛑 Breaking changes 🛑
<<<<<<< HEAD

- Rename service.Start() to Run() since it's a blocking call
- Fix slice Append to accept by value the element in pdata
- Change CreateTraceProcessor and CreateMetricsProcessor to use the same parameter order as receivers/logs processor and exporters.

Expand Down
2 changes: 1 addition & 1 deletion cmd/otelcol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func runInteractive(params service.Parameters) error {
return fmt.Errorf("failed to construct the application: %w", err)
}

err = app.Start()
err = app.Run()
if err != nil {
return fmt.Errorf("application run finished with error: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ func (app *Application) execute(ctx context.Context, factory ConfigFactory) erro
return componenterror.CombineErrors(errs)
}

// Start starts the collector according to the command and configuration
// given by the user.
func (app *Application) Start() error {
// Run starts the collector according to the command and configuration
// given by the user, and waits for it to complete.
func (app *Application) Run() error {
// From this point on do not show usage in case of error.
app.rootCmd.SilenceUsage = true

Expand Down
10 changes: 5 additions & 5 deletions service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestApplication_Start(t *testing.T) {
appDone := make(chan struct{})
go func() {
defer close(appDone)
assert.NoError(t, app.Start())
assert.NoError(t, app.Run())
}()

assert.Equal(t, Starting, <-app.GetStateChannel())
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestApplication_ReportError(t *testing.T) {
appDone := make(chan struct{})
go func() {
defer close(appDone)
assert.EqualError(t, app.Start(), "failed to shutdown extensions: err1")
assert.EqualError(t, app.Run(), "failed to shutdown extensions: err1")
}()

assert.Equal(t, Starting, <-app.GetStateChannel())
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestApplication_StartAsGoRoutine(t *testing.T) {
appDone := make(chan struct{})
go func() {
defer close(appDone)
appErr := app.Start()
appErr := app.Run()
if appErr != nil {
err = appErr
}
Expand Down Expand Up @@ -449,7 +449,7 @@ func TestApplication_GetExtensions(t *testing.T) {
appDone := make(chan struct{})
go func() {
defer close(appDone)
assert.NoError(t, app.Start())
assert.NoError(t, app.Run())
}()

assert.Equal(t, Starting, <-app.GetStateChannel())
Expand Down Expand Up @@ -478,7 +478,7 @@ func TestApplication_GetExporters(t *testing.T) {
appDone := make(chan struct{})
go func() {
defer close(appDone)
assert.NoError(t, app.Start())
assert.NoError(t, app.Run())
}()

assert.Equal(t, Starting, <-app.GetStateChannel())
Expand Down
2 changes: 1 addition & 1 deletion service/service_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *WindowsService) start(elog *eventlog.Log, appErrorChannel chan error) e

// app.Start blocks until receiving a SIGTERM signal, so needs to be started
// asynchronously, but it will exit early if an error occurs on startup
go func() { appErrorChannel <- s.app.Start() }()
go func() { appErrorChannel <- s.app.Run() }()

// wait until the app is in the Running state
go func() {
Expand Down
2 changes: 1 addition & 1 deletion testbed/testbed/otelcol_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (ipp *InProcessCollector) Start(args StartParams) (receiverAddr string, err
ipp.appDone = make(chan struct{})
go func() {
defer close(ipp.appDone)
appErr := ipp.svc.Start()
appErr := ipp.svc.Run()
if appErr != nil {
err = appErr
}
Expand Down

0 comments on commit 397c8de

Please sign in to comment.