@@ -149,6 +149,11 @@ var (
149
149
Usage : "Plugin profile to use. (local, nats, etc)" ,
150
150
EnvVars : []string {"MICRO_PROFILE" },
151
151
},
152
+ & cli.StringFlag {
153
+ Name : "debug-profile" ,
154
+ Usage : "Debug Plugin profile to use." ,
155
+ EnvVars : []string {"MICRO_DEBUG_PROFILE" },
156
+ },
152
157
& cli.StringFlag {
153
158
Name : "registry" ,
154
159
EnvVars : []string {"MICRO_REGISTRY" },
@@ -243,9 +248,9 @@ var (
243
248
}
244
249
245
250
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 ,
249
254
"rabbitmq" : rabbit .NewBroker ,
250
255
}
251
256
@@ -268,8 +273,8 @@ var (
268
273
}
269
274
270
275
DefaultStores = map [string ]func (... store.Option ) store.Store {
271
- "memory" : store .NewMemoryStore ,
272
- "mysql" : mysql .NewMysqlStore ,
276
+ "memory" : store .NewMemoryStore ,
277
+ "mysql" : mysql .NewMysqlStore ,
273
278
"natsjskv" : natsjskv .NewStore ,
274
279
"postgres" : postgres .NewStore ,
275
280
}
@@ -296,31 +301,31 @@ func init() {
296
301
297
302
func newCmd (opts ... Option ) Cmd {
298
303
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 ,
324
329
}
325
330
326
331
for _ , o := range opts {
@@ -359,10 +364,54 @@ func (c *cmd) Options() Options {
359
364
}
360
365
361
366
func (c * cmd ) Before (ctx * cli.Context ) error {
367
+ fmt .Println ("cmd.Before" )
362
368
// If flags are set then use them otherwise do nothing
363
369
var serverOpts []server.Option
364
370
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 ))
365
409
410
+ // Add more profiles as needed
411
+ default :
412
+ return fmt .Errorf ("unsupported profile: %s" , profileName )
413
+ }
414
+ }
366
415
// Set the client
367
416
if name := ctx .String ("client" ); len (name ) > 0 {
368
417
// only change if we have the client and type differs
@@ -453,49 +502,14 @@ func (c *cmd) Before(ctx *cli.Context) error {
453
502
registry .DefaultRegistry = * c .opts .Registry
454
503
}
455
504
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 ]
493
508
if ! ok {
494
509
return fmt .Errorf ("unsupported profile: %s" , name )
495
510
}
496
-
497
- * c .opts .Profile = p ()
498
- profile .DefaultProfile = * c .opts .Profile
511
+ * c .opts .DebugProfile = p ()
512
+ profile .DefaultProfile = * c .opts .DebugProfile
499
513
}
500
514
501
515
// Set the broker
@@ -678,7 +692,6 @@ func (c *cmd) Before(ctx *cli.Context) error {
678
692
config .DefaultConfig = * c .opts .Config
679
693
}
680
694
}
681
-
682
695
return nil
683
696
}
684
697
0 commit comments