fix core.Start()
This commit is contained in:
		
							parent
							
								
									a02061b6c5
								
							
						
					
					
						commit
						15eacddeed
					
				
					 4 changed files with 9 additions and 3 deletions
				
			
		|  | @ -7,7 +7,8 @@ import ( | |||
| ) | ||||
| 
 | ||||
| func Start(ctx lib.Context) { | ||||
| 	Listen(ctx) | ||||
| 	fmt.Println("Start:", ctx.Config().Name()) | ||||
| 	lib.RunCtx(ctx, Listen) | ||||
| } | ||||
| 
 | ||||
| func Listen(ctx lib.Context) { | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ func SimpleAddress(srv string) *address { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| // base functions | ||||
| // public functions | ||||
| 
 | ||||
| func Send(ctx lib.Context, addr lib.Address, msg lib.Message) { | ||||
| 	if srv, ok := ctx.Services()[addr.Service()]; ok { | ||||
|  |  | |||
|  | @ -21,6 +21,9 @@ func Config() lib.Config { | |||
| 		Base:         b("config", config.Start), | ||||
| 		ConfigFormat: "etc", | ||||
| 	}) | ||||
| 	cfg.Add(config.Cfg{ | ||||
| 		Base: b("test-receiver", core.Start), | ||||
| 	}) | ||||
| 	return &cfg | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ func TestConfig(tb *tbase.T) { | |||
| 
 | ||||
| func AppTest(t *testing.T) { | ||||
| 	ctx := t.Ctx | ||||
| 	t.AssertEqual(len(ctx.Services()), 2) | ||||
| 	t.AssertEqual(len(ctx.Services()), 3) | ||||
| } | ||||
| 
 | ||||
| func ConfigTest(t *testing.T) { | ||||
|  | @ -36,4 +36,6 @@ func SendTest(t *testing.T) { | |||
| 	rcvr := message.SimpleAddress("testing") | ||||
| 	msg := message.StrMessage("demo") | ||||
| 	rcvr.Send(ctx, msg) | ||||
| 	rcvr = message.SimpleAddress("test-receiver") | ||||
| 	rcvr.Send(ctx, msg) | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue