tweak proxy scalability

This commit is contained in:
A.Unger
2021-03-09 22:58:18 +01:00
parent 5f9133386d
commit 90aea4f58d
4 changed files with 12 additions and 22 deletions

View File

@@ -5,6 +5,7 @@ import (
"log"
"net"
"net/rpc"
"os"
cli "github.com/micro/cli/v2"
@@ -38,7 +39,7 @@ func RunCommand(cfg *config.Config) *cli.Command {
var reply int
if err := client.Call("Service.Start", "settings", &reply); err != nil {
if err := client.Call("Service.Start", os.Args[2], &reply); err != nil {
log.Fatal(err)
}
fmt.Println(reply)

View File

@@ -169,7 +169,6 @@ func (s *Service) Start(name string, reply *int) error {
return nil
}
s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, s.cfg)))
//s.serviceToken["settings"] = append(s.serviceToken[name], s.Supervisor.Add(settings.NewSutureService(s.context, s.cfg)))
*reply = 0
return nil
}
@@ -183,12 +182,11 @@ func (s *Service) List(args struct{}, reply *string) error {
func (s *Service) Kill(name string, reply *int) error {
if len(s.serviceToken[name]) > 0 {
for i := range s.serviceToken[name] {
fmt.Printf("\n\n%s\n%+v\n\n", name, s.serviceToken[name])
if err := s.Supervisor.Remove(s.serviceToken[name][i]); err != nil {
return err
}
delete(s.serviceToken, name)
}
delete(s.serviceToken, name)
} else {
return fmt.Errorf("service %s not found", name)
}

View File

@@ -154,6 +154,10 @@ func Server(cfg *config.Config) *cli.Command {
Msg("Tracing is not enabled")
}
var (
m = metrics.New()
)
stop := make(chan os.Signal, 1)
gr := run.Group{}
ctx, cancel := func() (context.Context, context.CancelFunc) {
@@ -162,7 +166,6 @@ func Server(cfg *config.Config) *cli.Command {
}
return context.WithCancel(cfg.Context)
}()
m := metrics.New()
defer cancel()
@@ -179,7 +182,7 @@ func Server(cfg *config.Config) *cli.Command {
proxyHTTP.Logger(logger),
proxyHTTP.Context(ctx),
proxyHTTP.Config(cfg),
proxyHTTP.Metrics(m),
proxyHTTP.Metrics(metrics.New()),
proxyHTTP.Middlewares(loadMiddlewares(ctx, logger, cfg)),
)

View File

@@ -49,22 +49,10 @@ func New() *Metrics {
}, []string{"versions"}),
}
mustNotFail(prometheus.Register(
m.Counter,
))
mustNotFail(prometheus.Register(
m.Latency,
))
mustNotFail(prometheus.Register(
m.Duration,
))
mustNotFail(prometheus.Register(
m.BuildInfo,
))
prometheus.Register(m.Counter)
prometheus.Register(m.Latency)
prometheus.Register(m.Duration)
prometheus.Register(m.BuildInfo)
return m
}