package service import ( "fmt" "path/filepath" "git.apinb.com/bsm-sdk/engine/cmd" "git.apinb.com/bsm-sdk/engine/configure" "git.apinb.com/bsm-sdk/engine/encipher" "git.apinb.com/bsm-sdk/engine/env" "git.apinb.com/bsm-sdk/engine/print" "git.apinb.com/bsm-sdk/engine/vars" "github.com/zeromicro/go-zero/core/prometheus" "github.com/zeromicro/go-zero/core/trace" ) func Register(srvKey string, cfg any) { vars.ServiceKey = srvKey // get os env. env.NewEnv() // open side cmd. cmd.NewCmd() encipher.New() print.Info("[Blocks Service] %s Starting...", vars.ServiceKey) // set config args. args := map[string]string{ "ServiceKey": srvKey, "Workspace": env.MeshEnv.Workspace, "RuntimeMode": env.MeshEnv.RuntimeMode, } // get config file. cf := fmt.Sprintf("%s_%s.yaml", srvKey, env.MeshEnv.RuntimeMode) cf = filepath.Join(env.MeshEnv.Prefix, "etc", cf) configure.LoadYamlFile(cf, args, cfg) return } func Start(addr string) { print.Info("[Blocks Service] %s Workspace: %s", vars.ServiceKey, env.MeshEnv.Workspace) print.Info("[Blocks Service] %s Listen Addr: %s", vars.ServiceKey, addr) print.Info("[Blocks Service] %s Runtime Mode: %s", vars.ServiceKey, env.MeshEnv.RuntimeMode) } func Done(p *prometheus.Config, t *trace.Config) { if p != nil && p.Host != "" { print.Info("[Blocks Service] %s Prometheus Addr: http://%s:%d%s", vars.ServiceKey, p.Host, p.Port, p.Path) } if t != nil && t.Endpoint != "" { print.Info("[Blocks Service] %s Telemetry Endpoint: %s", vars.ServiceKey, t.Endpoint) } print.Info("[Blocks Service] %s Service Build: Version %s, Go Version %s By %s", vars.ServiceKey, vars.VERSION, vars.GO_VERSION, vars.BUILD_TIME) print.Success("[Blocks Service] %s Service Grpc Register & Runing Success . ", vars.ServiceKey) }