chore: stabilize lint and verify builds

This commit is contained in:
2026-02-06 11:51:32 +08:00
parent edede17880
commit 1782f64417
114 changed files with 3032 additions and 1345 deletions

View File

@@ -8,7 +8,7 @@ import (
"quyun/v2/providers/grpc"
"quyun/v2/providers/http"
log "github.com/sirupsen/logrus"
logrus "github.com/sirupsen/logrus"
"github.com/soheilhy/cmux"
"go.ipao.vip/atom/container"
"go.ipao.vip/atom/opt"
@@ -35,11 +35,12 @@ func (h *Config) Address() string {
if h.Host == nil {
return fmt.Sprintf(":%d", h.Port)
}
return fmt.Sprintf("%s:%d", *h.Host, h.Port)
}
type CMux struct {
Http *http.Service
HTTP *http.Service
Grpc *grpc.Grpc
Mux cmux.CMux
Base net.Listener
@@ -54,7 +55,7 @@ func (c *CMux) Serve() error {
if c.Base != nil && c.Base.Addr() != nil {
addr = c.Base.Addr().String()
}
log.WithFields(log.Fields{
logrus.WithFields(logrus.Fields{
"addr": addr,
}).Info("cmux starting")
@@ -70,24 +71,27 @@ func (c *CMux) Serve() error {
var eg errgroup.Group
eg.Go(func() error {
log.WithField("addr", addr).Info("grpc serving via cmux")
logrus.WithField("addr", addr).Info("grpc serving via cmux")
err := c.Grpc.ServeWithListener(grpcL)
if err != nil {
log.WithError(err).Error("grpc server exited with error")
logrus.WithError(err).Error("grpc server exited with error")
} else {
log.Info("grpc server exited")
logrus.Info("grpc server exited")
}
return err
})
eg.Go(func() error {
log.WithField("addr", addr).Info("http serving via cmux")
err := c.Http.Listener(httpL)
logrus.WithField("addr", addr).Info("http serving via cmux")
err := c.HTTP.Listener(httpL)
if err != nil {
log.WithError(err).Error("http server exited with error")
logrus.WithError(err).Error("http server exited with error")
} else {
log.Info("http server exited")
logrus.Info("http server exited")
}
return err
})
@@ -95,15 +99,17 @@ func (c *CMux) Serve() error {
eg.Go(func() error {
err := c.Mux.Serve()
if err != nil {
log.WithError(err).Error("cmux exited with error")
logrus.WithError(err).Error("cmux exited with error")
} else {
log.Info("cmux exited")
logrus.Info("cmux exited")
}
return err
})
err := eg.Wait()
if err == nil {
log.Info("cmux and sub-servers exited cleanly")
logrus.Info("cmux and sub-servers exited cleanly")
}
return err
}