From 0cbe7ec00a968e8ca5a8e65bce2b1d0f003fdd32 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Fri, 18 Mar 2022 15:47:57 +0000 Subject: [PATCH 1/3] allow micro kill . --- client/cli/run/cli.go | 2 +- client/cli/run/service.go | 6 ++++++ client/cli/run/watcher.go | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/cli/run/cli.go b/client/cli/run/cli.go index 4b8e53fb..c224a165 100644 --- a/client/cli/run/cli.go +++ b/client/cli/run/cli.go @@ -52,7 +52,7 @@ var flags = []cli.Flag{ only watching *.go and *.proto files now`, }, &cli.IntFlag{ - Name: "watch_delay", + Name: "watch_delay", Usage: `Watching delay milliseconds for live-reloading, only valid when --watch=true. e.g. watch_delay=500 means watching delay time is 500ms.`, Value: 1000, diff --git a/client/cli/run/service.go b/client/cli/run/service.go index 6c04581e..ddcded1d 100644 --- a/client/cli/run/service.go +++ b/client/cli/run/service.go @@ -472,6 +472,12 @@ func killService(ctx *cli.Context) error { name = v } + // special case + if name == "." { + dir, _ := os.Getwd() + name = filepath.Base(dir) + } + var ref string if parts := strings.Split(name, "@"); len(parts) > 1 { name = parts[0] diff --git a/client/cli/run/watcher.go b/client/cli/run/watcher.go index 6b40b7ff..108234b3 100644 --- a/client/cli/run/watcher.go +++ b/client/cli/run/watcher.go @@ -37,7 +37,7 @@ func NewWatcher(root string, delay time.Duration, fn CallbackFunc) (*watcher, er fileWatcher: fileWatcher, eventsChan: make(chan string, 1000), callbackFunc: fn, - stopChan: make(chan struct{}), + stopChan: make(chan struct{}), }, nil } @@ -167,4 +167,4 @@ func (w *watcher) watchDirectory(dir string) error { // Stop the watching process func (w *watcher) Stop() { close(w.stopChan) -} \ No newline at end of file +} From 2cbc0a52e1b471544c2420faa87fe02a03a112af Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 20 Mar 2022 20:50:16 +0000 Subject: [PATCH 2/3] update main template generation --- client/cli/new/template/handler.go | 5 +++++ client/cli/new/template/main.go | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/cli/new/template/handler.go b/client/cli/new/template/handler.go index ffde1089..60c74f27 100644 --- a/client/cli/new/template/handler.go +++ b/client/cli/new/template/handler.go @@ -13,6 +13,11 @@ import ( type {{title .Alias}} struct{} +// Return a new handler +func New() *{{title .Alias}} { + return &{{title .Alias}}{} +} + // Call is a single request handler called via client.Call or the generated client code func (e *{{title .Alias}}) Call(ctx context.Context, req *{{dehyphen .Alias}}.Request, rsp *{{dehyphen .Alias}}.Response) error { log.Info("Received {{title .Alias}}.Call request") diff --git a/client/cli/new/template/main.go b/client/cli/new/template/main.go index b4f61917..e226c556 100644 --- a/client/cli/new/template/main.go +++ b/client/cli/new/template/main.go @@ -15,11 +15,10 @@ func main() { // Create service srv := service.New( service.Name("{{lower .Alias}}"), - service.Version("latest"), ) // Register handler - pb.Register{{title .Alias}}Handler(srv.Server(), new(handler.{{title .Alias}})) + pb.Register{{title .Alias}}Handler(srv.Server(), handler.New()) // Run service if err := srv.Run(); err != nil { From 84cb465cfd44b99699d7726f32d8803a4a92b7e5 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Mon, 21 Mar 2022 11:06:22 +0000 Subject: [PATCH 3/3] accept map[string]string as flag --- cmd/dynamic.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/dynamic.go b/cmd/dynamic.go index e0282c9e..beb7e019 100644 --- a/cmd/dynamic.go +++ b/cmd/dynamic.go @@ -369,6 +369,12 @@ func flagsToRequest(flags map[string][]string, req *registry.Value) (map[string] return ret, nil case "string": return value[0], nil + case "map[string]string": + var val map[string]string + if err := json.Unmarshal([]byte(value[0]), &val); err != nil { + return value[0], nil + } + return val, nil default: return value, nil }