update micro/cli to urfave/cli/v2 and fix go-micro

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-01-25 13:41:25 +03:00
parent 1d00f2f771
commit e6a34bcbe7
14 changed files with 183 additions and 176 deletions

View File

@@ -6,7 +6,7 @@ import (
"net/http"
"time"
"github.com/micro/cli"
"github.com/micro/cli/v2"
"github.com/micro/go-micro"
"github.com/micro/go-micro/registry"
)

View File

@@ -14,7 +14,6 @@ import (
"syscall"
"time"
"github.com/micro/cli"
"github.com/micro/go-micro"
"github.com/micro/go-micro/registry"
maddr "github.com/micro/go-micro/util/addr"
@@ -22,6 +21,7 @@ import (
"github.com/micro/go-micro/util/log"
mnet "github.com/micro/go-micro/util/net"
mls "github.com/micro/go-micro/util/tls"
"github.com/micro/cli/v2"
)
type service struct {
@@ -327,7 +327,7 @@ func (s *service) Init(opts ...Option) error {
serviceOpts = append(serviceOpts, micro.Registry(s.opts.Registry))
}
serviceOpts = append(serviceOpts, micro.Action(func(ctx *cli.Context) {
serviceOpts = append(serviceOpts, micro.Action(func(ctx *cli.Context) error {
if ttl := ctx.Int("register_ttl"); ttl > 0 {
s.opts.RegisterTTL = time.Duration(ttl) * time.Second
}
@@ -359,6 +359,8 @@ func (s *service) Init(opts ...Option) error {
if s.opts.Action != nil {
s.opts.Action(ctx)
}
return nil
}))
s.opts.Service.Init(serviceOpts...)