app: drop unused Worker/jobDone

This commit is contained in:
Roman Khimov 2021-04-15 17:16:44 +03:00 committed by Roman Khimov
parent 491ae13190
commit ed27e28a30
2 changed files with 1 additions and 14 deletions

14
app.go
View file

@ -24,13 +24,11 @@ type (
cfg *viper.Viper cfg *viper.Viper
auxiliaryLog logger.Logger auxiliaryLog logger.Logger
webServer *fasthttp.Server webServer *fasthttp.Server
jobDone chan struct{}
webDone chan struct{} webDone chan struct{}
} }
App interface { App interface {
Wait() Wait()
Worker(context.Context)
Serve(context.Context) Serve(context.Context)
} }
@ -65,7 +63,6 @@ func newApp(ctx context.Context, opt ...Option) App {
log: zap.L(), log: zap.L(),
cfg: viper.GetViper(), cfg: viper.GetViper(),
webServer: new(fasthttp.Server), webServer: new(fasthttp.Server),
jobDone: make(chan struct{}),
webDone: make(chan struct{}), webDone: make(chan struct{}),
} }
for i := range opt { for i := range opt {
@ -134,16 +131,7 @@ func newApp(ctx context.Context, opt ...Option) App {
func (a *app) Wait() { func (a *app) Wait() {
a.log.Info("starting application") a.log.Info("starting application")
select { <-a.webDone // wait for web-server to be stopped
case <-a.jobDone: // wait for job is stopped
<-a.webDone
case <-a.webDone: // wait for web-server is stopped
<-a.jobDone
}
}
func (a *app) Worker(ctx context.Context) {
close(a.jobDone)
} }
func (a *app) Serve(ctx context.Context) { func (a *app) Serve(ctx context.Context) {

View file

@ -15,7 +15,6 @@ func main() {
globalContext := global.Context() globalContext := global.Context()
app := newApp(globalContext, WithLogger(l), WithConfig(v)) app := newApp(globalContext, WithLogger(l), WithConfig(v))
go app.Serve(globalContext) go app.Serve(globalContext)
go app.Worker(globalContext)
app.Wait() app.Wait()
} }