fix core.Start()

This commit is contained in:
Helmut Merz 2023-06-07 09:00:54 +02:00
parent a02061b6c5
commit 15eacddeed
4 changed files with 9 additions and 3 deletions

View file

@ -7,7 +7,8 @@ import (
) )
func Start(ctx lib.Context) { func Start(ctx lib.Context) {
Listen(ctx) fmt.Println("Start:", ctx.Config().Name())
lib.RunCtx(ctx, Listen)
} }
func Listen(ctx lib.Context) { func Listen(ctx lib.Context) {

View file

@ -40,7 +40,7 @@ func SimpleAddress(srv string) *address {
} }
} }
// base functions // public functions
func Send(ctx lib.Context, addr lib.Address, msg lib.Message) { func Send(ctx lib.Context, addr lib.Address, msg lib.Message) {
if srv, ok := ctx.Services()[addr.Service()]; ok { if srv, ok := ctx.Services()[addr.Service()]; ok {

View file

@ -21,6 +21,9 @@ func Config() lib.Config {
Base: b("config", config.Start), Base: b("config", config.Start),
ConfigFormat: "etc", ConfigFormat: "etc",
}) })
cfg.Add(config.Cfg{
Base: b("test-receiver", core.Start),
})
return &cfg return &cfg
} }

View file

@ -19,7 +19,7 @@ func TestConfig(tb *tbase.T) {
func AppTest(t *testing.T) { func AppTest(t *testing.T) {
ctx := t.Ctx ctx := t.Ctx
t.AssertEqual(len(ctx.Services()), 2) t.AssertEqual(len(ctx.Services()), 3)
} }
func ConfigTest(t *testing.T) { func ConfigTest(t *testing.T) {
@ -36,4 +36,6 @@ func SendTest(t *testing.T) {
rcvr := message.SimpleAddress("testing") rcvr := message.SimpleAddress("testing")
msg := message.StrMessage("demo") msg := message.StrMessage("demo")
rcvr.Send(ctx, msg) rcvr.Send(ctx, msg)
rcvr = message.SimpleAddress("test-receiver")
rcvr.Send(ctx, msg)
} }