Skip to content

Commit

Permalink
patch: fix linter
Browse files Browse the repository at this point in the history
- removing these errors and defers since we're getting rid of our centralize lifecycle functions in main soon
  • Loading branch information
denopink committed May 17, 2024
1 parent 60904f0 commit 760be3e
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions cmd/xmidt-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ package main

import (
"context"
"errors"
"fmt"
"os"
"runtime/debug"
"time"

"github.com/alecthomas/kong"
Expand All @@ -30,12 +28,6 @@ const (
applicationName = "xmidt-agent"
)

var (
ErrLifecycleStartPanic = errors.New("panic occured during fx's lifecycle Start")
ErrLifecycleStopPanic = errors.New("panic occured during fx's lifecycle Stop")
ErrLifecycleShutdownPanic = errors.New("panic occured during fx's lifecycle Shutdown")
)

// These match what goreleaser provides.
var (
commit = "undefined"
Expand Down Expand Up @@ -235,14 +227,6 @@ func onStart(cred *credentials.Credentials, ws *websocket.Websocket, libParodus
logger = logger.Named("on_start")

return func(ctx context.Context) (err error) {
// err is set during a panic recovery in order to allow fx to rolling back
defer func() {
if r := recover(); nil != r {
err = ErrLifecycleStartPanic
logger.Error("stacktrace from panic", zap.String("stacktrace", string(debug.Stack())), zap.Any("panic", r), zap.Error(err))
}
}()

if err = ctx.Err(); err != nil {
return err
}
Expand Down Expand Up @@ -272,20 +256,6 @@ func onStop(ws *websocket.Websocket, libParodus *libparodus.Adapter, qos *qos.Ha
logger = logger.Named("on_stop")

return func(context.Context) (err error) {
// err is set during a panic recovery in order to manually trigger
// the shutdown of the application by sending a signal to all open Done channels
defer func() {
if r := recover(); nil != r {
err = ErrLifecycleStopPanic
logger.Error("stacktrace from panic", zap.String("stacktrace", string(debug.Stack())), zap.Any("panic", r), zap.Error(err))
}

if err2 := shutdowner.Shutdown(); err2 != nil {
err = errors.Join(err, err2, ErrLifecycleShutdownPanic)
logger.Error("encountered error trying to shutdown app: ", zap.Error(err))
}
}()

if ws == nil {
logger.Debug("websocket disabled")
return nil
Expand Down

0 comments on commit 760be3e

Please sign in to comment.