forked from TrueCloudLab/frostfs-http-gw
app: drop unused Worker/jobDone
This commit is contained in:
parent
491ae13190
commit
ed27e28a30
2 changed files with 1 additions and 14 deletions
14
app.go
14
app.go
|
@ -24,13 +24,11 @@ type (
|
|||
cfg *viper.Viper
|
||||
auxiliaryLog logger.Logger
|
||||
webServer *fasthttp.Server
|
||||
jobDone chan struct{}
|
||||
webDone chan struct{}
|
||||
}
|
||||
|
||||
App interface {
|
||||
Wait()
|
||||
Worker(context.Context)
|
||||
Serve(context.Context)
|
||||
}
|
||||
|
||||
|
@ -65,7 +63,6 @@ func newApp(ctx context.Context, opt ...Option) App {
|
|||
log: zap.L(),
|
||||
cfg: viper.GetViper(),
|
||||
webServer: new(fasthttp.Server),
|
||||
jobDone: make(chan struct{}),
|
||||
webDone: make(chan struct{}),
|
||||
}
|
||||
for i := range opt {
|
||||
|
@ -134,16 +131,7 @@ func newApp(ctx context.Context, opt ...Option) App {
|
|||
|
||||
func (a *app) Wait() {
|
||||
a.log.Info("starting application")
|
||||
select {
|
||||
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)
|
||||
<-a.webDone // wait for web-server to be stopped
|
||||
}
|
||||
|
||||
func (a *app) Serve(ctx context.Context) {
|
||||
|
|
1
main.go
1
main.go
|
@ -15,7 +15,6 @@ func main() {
|
|||
globalContext := global.Context()
|
||||
app := newApp(globalContext, WithLogger(l), WithConfig(v))
|
||||
go app.Serve(globalContext)
|
||||
go app.Worker(globalContext)
|
||||
app.Wait()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue