@@ -4,6 +4,7 @@ package cmd
44import (
55 "fmt"
66 "math/rand"
7+ "os"
78 "sort"
89 "strings"
910 "time"
@@ -23,6 +24,7 @@ import (
2324 "go-micro.dev/v5/debug/profile/pprof"
2425 "go-micro.dev/v5/debug/trace"
2526 "go-micro.dev/v5/logger"
27+ mprofile "go-micro.dev/v5/profile"
2628 "go-micro.dev/v5/registry"
2729 "go-micro.dev/v5/registry/consul"
2830 "go-micro.dev/v5/registry/etcd"
@@ -141,8 +143,8 @@ var (
141143 },
142144 & cli.StringFlag {
143145 Name : "profile" ,
144- Usage : "Debug profiler for cpu and memory stats " ,
145- EnvVars : []string {"MICRO_DEBUG_PROFILE " },
146+ Usage : "Plugin profile to use. (local, nats, etc) " ,
147+ EnvVars : []string {"MICRO_PROFILE " },
146148 },
147149 & cli.StringFlag {
148150 Name : "registry" ,
@@ -437,6 +439,40 @@ func (c *cmd) Before(ctx *cli.Context) error {
437439 }
438440 }
439441
442+ // --- Profile Grouping Extension ---
443+ // Check for new profile flag/env (not just debug profiler)
444+ profileName := ctx .String ("profile" )
445+ if profileName == "" {
446+ profileName = os .Getenv ("MICRO_PROFILE" )
447+ }
448+ if profileName != "" {
449+ switch profileName {
450+ case "local" :
451+ imported := mprofile .LocalProfile ()
452+ * c .opts .Registry = imported .Registry
453+ registry .DefaultRegistry = imported .Registry
454+ * c .opts .Broker = imported .Broker
455+ broker .DefaultBroker = imported .Broker
456+ * c .opts .Store = imported .Store
457+ store .DefaultStore = imported .Store
458+ * c .opts .Transport = imported .Transport
459+ transport .DefaultTransport = imported .Transport
460+ case "nats" :
461+ imported := mprofile .NatsProfile ()
462+ * c .opts .Registry = imported .Registry
463+ registry .DefaultRegistry = imported .Registry
464+ * c .opts .Broker = imported .Broker
465+ broker .DefaultBroker = imported .Broker
466+ * c .opts .Store = imported .Store
467+ store .DefaultStore = imported .Store
468+ * c .opts .Transport = imported .Transport
469+ transport .DefaultTransport = imported .Transport
470+ // Add more profiles as needed
471+ default :
472+ return fmt .Errorf ("unsupported profile: %s" , profileName )
473+ }
474+ }
475+
440476 // Set the profile
441477 if name := ctx .String ("profile" ); len (name ) > 0 {
442478 p , ok := c .opts .Profiles [name ]
0 commit comments