@@ -4,6 +4,7 @@ package cmd
4
4
import (
5
5
"fmt"
6
6
"math/rand"
7
+ "os"
7
8
"sort"
8
9
"strings"
9
10
"time"
@@ -23,6 +24,7 @@ import (
23
24
"go-micro.dev/v5/debug/profile/pprof"
24
25
"go-micro.dev/v5/debug/trace"
25
26
"go-micro.dev/v5/logger"
27
+ mprofile "go-micro.dev/v5/profile"
26
28
"go-micro.dev/v5/registry"
27
29
"go-micro.dev/v5/registry/consul"
28
30
"go-micro.dev/v5/registry/etcd"
@@ -141,8 +143,8 @@ var (
141
143
},
142
144
& cli.StringFlag {
143
145
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 " },
146
148
},
147
149
& cli.StringFlag {
148
150
Name : "registry" ,
@@ -437,6 +439,40 @@ func (c *cmd) Before(ctx *cli.Context) error {
437
439
}
438
440
}
439
441
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
+
440
476
// Set the profile
441
477
if name := ctx .String ("profile" ); len (name ) > 0 {
442
478
p , ok := c .opts .Profiles [name ]
0 commit comments