You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
621 B
32 lines
621 B
package di
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"{{.ModPrefix}}{{.Name}}/internal/service"
|
|
|
|
"github.com/go-kratos/kratos/pkg/log"
|
|
bm "github.com/go-kratos/kratos/pkg/net/http/blademaster"
|
|
)
|
|
|
|
//go:generate kratos tool wire
|
|
type App struct {
|
|
svc *service.Service
|
|
http *bm.Engine
|
|
}
|
|
|
|
func NewApp(svc *service.Service, h *bm.Engine) (app *App, closeFunc func(), err error){
|
|
app = &App{
|
|
svc: svc,
|
|
http: h,
|
|
}
|
|
closeFunc = func() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 35*time.Second)
|
|
if err := h.Shutdown(ctx); err != nil {
|
|
log.Error("httpSrv.Shutdown error(%v)", err)
|
|
}
|
|
cancel()
|
|
}
|
|
return
|
|
}
|
|
|