feat(dependencies): 更新 go.mod 和 go.sum 文件,添加新依赖并优化现有依赖版本
在 go.mod 中添加了多个新依赖,包括用于微服务架构、数据库支持、缓存和消息队列的库。同时,更新了 go.sum 文件以反映这些更改。README.md 文件也进行了相应的更新,增加了微服务架构的描述和功能模块的详细信息,确保文档与代码保持一致。
This commit is contained in:
@@ -43,6 +43,7 @@ func New(srv *grpc.Server, opts *Options) *Service {
|
||||
return &Service{GrpcSrv: srv, Opts: opts}
|
||||
}
|
||||
|
||||
// Addr formats ip and port into host:port.
|
||||
func Addr(ip string, port int) string {
|
||||
return net.JoinHostPort(ip, strconv.Itoa(port))
|
||||
}
|
||||
@@ -57,13 +58,13 @@ func (s *Service) Start() {
|
||||
os.Exit(1)
|
||||
}
|
||||
printer.Info("[BSM - %s] Registering Service to Etcd ...", vars.ServiceKey)
|
||||
// get methods
|
||||
// get methods for gateway/router discovery
|
||||
methods := FoundGrpcMethods(s.GrpcSrv)
|
||||
|
||||
// set router key
|
||||
routerKey := vars.ServiceRootPrefix + "Router/" + env.Runtime.Workspace + "/" + strings.ToLower(vars.ServiceKey) + "/" + s.Opts.Addr
|
||||
|
||||
// register to etcd
|
||||
// register to etcd with lease
|
||||
register, err := RegisterService(s.Opts.EtcdClient, routerKey, methods, vars.ServiceLease)
|
||||
if err != nil {
|
||||
log.Panicf("[ERROR] %s Service Register:%s \n", vars.ServiceKey, err.Error())
|
||||
@@ -105,7 +106,10 @@ func (s *Service) Gateway(grpcAddr string, httpAddr string) {
|
||||
_, cancel := context.WithCancel(s.Opts.GatewayCtx)
|
||||
defer cancel()
|
||||
|
||||
http.ListenAndServe(httpAddr, s.Opts.GatewayMux)
|
||||
// 不因 HTTP 启动失败而导致 panic
|
||||
if err := http.ListenAndServe(httpAddr, s.Opts.GatewayMux); err != nil {
|
||||
printer.Error("[BSM - %s] Http Serve Error: %v", vars.ServiceKey, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) Use(initFunc func() error) {
|
||||
|
||||
Reference in New Issue
Block a user