@@ -149,6 +149,11 @@ var (
149149 Usage : "Plugin profile to use. (local, nats, etc)" ,
150150 EnvVars : []string {"MICRO_PROFILE" },
151151 },
152+ & cli.StringFlag {
153+ Name : "debug-profile" ,
154+ Usage : "Debug Plugin profile to use." ,
155+ EnvVars : []string {"MICRO_DEBUG_PROFILE" },
156+ },
152157 & cli.StringFlag {
153158 Name : "registry" ,
154159 EnvVars : []string {"MICRO_REGISTRY" },
@@ -243,9 +248,9 @@ var (
243248 }
244249
245250 DefaultBrokers = map [string ]func (... broker.Option ) broker.Broker {
246- "memory" : broker .NewMemoryBroker ,
247- "http" : broker .NewHttpBroker ,
248- "nats" : nbroker .NewNatsBroker ,
251+ "memory" : broker .NewMemoryBroker ,
252+ "http" : broker .NewHttpBroker ,
253+ "nats" : nbroker .NewNatsBroker ,
249254 "rabbitmq" : rabbit .NewBroker ,
250255 }
251256
@@ -268,8 +273,8 @@ var (
268273 }
269274
270275 DefaultStores = map [string ]func (... store.Option ) store.Store {
271- "memory" : store .NewMemoryStore ,
272- "mysql" : mysql .NewMysqlStore ,
276+ "memory" : store .NewMemoryStore ,
277+ "mysql" : mysql .NewMysqlStore ,
273278 "natsjskv" : natsjskv .NewStore ,
274279 "postgres" : postgres .NewStore ,
275280 }
@@ -296,31 +301,31 @@ func init() {
296301
297302func newCmd (opts ... Option ) Cmd {
298303 options := Options {
299- Auth : & auth .DefaultAuth ,
300- Broker : & broker .DefaultBroker ,
301- Client : & client .DefaultClient ,
302- Registry : & registry .DefaultRegistry ,
303- Server : & server .DefaultServer ,
304- Selector : & selector .DefaultSelector ,
305- Transport : & transport .DefaultTransport ,
306- Store : & store .DefaultStore ,
307- Tracer : & trace .DefaultTracer ,
308- Profile : & profile .DefaultProfile ,
309- Config : & config .DefaultConfig ,
310- Cache : & cache .DefaultCache ,
311-
312- Brokers : DefaultBrokers ,
313- Clients : DefaultClients ,
314- Registries : DefaultRegistries ,
315- Selectors : DefaultSelectors ,
316- Servers : DefaultServers ,
317- Transports : DefaultTransports ,
318- Stores : DefaultStores ,
319- Tracers : DefaultTracers ,
320- Auths : DefaultAuths ,
321- Profiles : DefaultProfiles ,
322- Configs : DefaultConfigs ,
323- Caches : DefaultCaches ,
304+ Auth : & auth .DefaultAuth ,
305+ Broker : & broker .DefaultBroker ,
306+ Client : & client .DefaultClient ,
307+ Registry : & registry .DefaultRegistry ,
308+ Server : & server .DefaultServer ,
309+ Selector : & selector .DefaultSelector ,
310+ Transport : & transport .DefaultTransport ,
311+ Store : & store .DefaultStore ,
312+ Tracer : & trace .DefaultTracer ,
313+ DebugProfile : & profile .DefaultProfile ,
314+ Config : & config .DefaultConfig ,
315+ Cache : & cache .DefaultCache ,
316+
317+ Brokers : DefaultBrokers ,
318+ Clients : DefaultClients ,
319+ Registries : DefaultRegistries ,
320+ Selectors : DefaultSelectors ,
321+ Servers : DefaultServers ,
322+ Transports : DefaultTransports ,
323+ Stores : DefaultStores ,
324+ Tracers : DefaultTracers ,
325+ Auths : DefaultAuths ,
326+ DebugProfiles : DefaultProfiles ,
327+ Configs : DefaultConfigs ,
328+ Caches : DefaultCaches ,
324329 }
325330
326331 for _ , o := range opts {
@@ -359,10 +364,54 @@ func (c *cmd) Options() Options {
359364}
360365
361366func (c * cmd ) Before (ctx * cli.Context ) error {
367+ fmt .Println ("cmd.Before" )
362368 // If flags are set then use them otherwise do nothing
363369 var serverOpts []server.Option
364370 var clientOpts []client.Option
371+ // --- Profile Grouping Extension ---
372+ // Check for new profile flag/env (not just debug profiler)
373+ profileName := ctx .String ("profile" )
374+ if profileName == "" {
375+ profileName = os .Getenv ("MICRO_PROFILE" )
376+ }
377+ if profileName != "" {
378+ switch profileName {
379+ case "local" :
380+ imported := mprofile .LocalProfile ()
381+ * c .opts .Registry = imported .Registry
382+ registry .DefaultRegistry = imported .Registry
383+ * c .opts .Broker = imported .Broker
384+ broker .DefaultBroker = imported .Broker
385+ * c .opts .Store = imported .Store
386+ store .DefaultStore = imported .Store
387+ * c .opts .Transport = imported .Transport
388+ transport .DefaultTransport = imported .Transport
389+ case "nats" :
390+ imported := mprofile .NatsProfile ()
391+ * c .opts .Registry = imported .Registry
392+ // these need to move out to a function so they can be merged with below ctx.String("Registry")
393+ serverOpts = append (serverOpts , server .Registry (* c .opts .Registry ))
394+ clientOpts = append (clientOpts , client .Registry (* c .opts .Registry ))
395+ registry .DefaultRegistry = imported .Registry
396+
397+ * c .opts .Broker = imported .Broker
398+ broker .DefaultBroker = imported .Broker
399+ serverOpts = append (serverOpts , server .Broker (* c .opts .Broker ))
400+ clientOpts = append (clientOpts , client .Broker (* c .opts .Broker ))
401+
402+ * c .opts .Store = imported .Store
403+ store .DefaultStore = imported .Store
404+ * c .opts .Transport = imported .Transport
405+
406+ transport .DefaultTransport = imported .Transport
407+ serverOpts = append (serverOpts , server .Transport (* c .opts .Transport ))
408+ clientOpts = append (clientOpts , client .Transport (* c .opts .Transport ))
365409
410+ // Add more profiles as needed
411+ default :
412+ return fmt .Errorf ("unsupported profile: %s" , profileName )
413+ }
414+ }
366415 // Set the client
367416 if name := ctx .String ("client" ); len (name ) > 0 {
368417 // only change if we have the client and type differs
@@ -453,49 +502,14 @@ func (c *cmd) Before(ctx *cli.Context) error {
453502 registry .DefaultRegistry = * c .opts .Registry
454503 }
455504
456- // --- Profile Grouping Extension ---
457- // Check for new profile flag/env (not just debug profiler)
458- profileName := ctx .String ("profile" )
459- if profileName == "" {
460- profileName = os .Getenv ("MICRO_PROFILE" )
461- }
462- if profileName != "" {
463- switch profileName {
464- case "local" :
465- imported := mprofile .LocalProfile ()
466- * c .opts .Registry = imported .Registry
467- registry .DefaultRegistry = imported .Registry
468- * c .opts .Broker = imported .Broker
469- broker .DefaultBroker = imported .Broker
470- * c .opts .Store = imported .Store
471- store .DefaultStore = imported .Store
472- * c .opts .Transport = imported .Transport
473- transport .DefaultTransport = imported .Transport
474- case "nats" :
475- imported := mprofile .NatsProfile ()
476- * c .opts .Registry = imported .Registry
477- registry .DefaultRegistry = imported .Registry
478- * c .opts .Broker = imported .Broker
479- broker .DefaultBroker = imported .Broker
480- * c .opts .Store = imported .Store
481- store .DefaultStore = imported .Store
482- * c .opts .Transport = imported .Transport
483- transport .DefaultTransport = imported .Transport
484- // Add more profiles as needed
485- default :
486- return fmt .Errorf ("unsupported profile: %s" , profileName )
487- }
488- }
489-
490- // Set the profile
491- if name := ctx .String ("profile" ); len (name ) > 0 {
492- p , ok := c .opts .Profiles [name ]
505+ // Set the debug profile
506+ if name := ctx .String ("debug-profile" ); len (name ) > 0 {
507+ p , ok := c .opts .DebugProfiles [name ]
493508 if ! ok {
494509 return fmt .Errorf ("unsupported profile: %s" , name )
495510 }
496-
497- * c .opts .Profile = p ()
498- profile .DefaultProfile = * c .opts .Profile
511+ * c .opts .DebugProfile = p ()
512+ profile .DefaultProfile = * c .opts .DebugProfile
499513 }
500514
501515 // Set the broker
@@ -678,7 +692,6 @@ func (c *cmd) Before(ctx *cli.Context) error {
678692 config .DefaultConfig = * c .opts .Config
679693 }
680694 }
681-
682695 return nil
683696}
684697
0 commit comments