work in progress: matrix.connect()
This commit is contained in:
parent
e21499234b
commit
fbff96dcc0
5 changed files with 20 additions and 12 deletions
|
@ -40,7 +40,9 @@ func Select(ctx lib.Context, msg lib.Message) []lib.Action {
|
|||
}
|
||||
}
|
||||
}
|
||||
// if len(acts) == 0 { logging.Warn().... }
|
||||
if len(acts) == 0 {
|
||||
logging.WarnM(ctx, msg).Msg("action.Select: no match")
|
||||
}
|
||||
return acts
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func Step(ctx lib.Context) (loop bool) {
|
|||
|
||||
func HandleMessage(ctx lib.Context, msg lib.Message) (loop bool) {
|
||||
loop = true
|
||||
logging.Debug(ctx).Str("msg.action", msg.Action()).Msg("core.HandleMessage")
|
||||
logging.DebugM(ctx, msg).Msg("core.HandleMessage")
|
||||
for _, act := range action.Select(ctx, msg) {
|
||||
loop = act.Handle()
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func WithMessage(ctx lib.Context, msg lib.Message, e *Evt) *Evt {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
return WithContext(ctx, e).Str("action", msg.Action())
|
||||
return WithContext(ctx, e).Str("msg", msg.String())
|
||||
}
|
||||
|
||||
func DebugM(ctx lib.Context, msg lib.Message) *Evt {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
lib "git.sr.ht/~cco/go-scopes"
|
||||
"git.sr.ht/~cco/go-scopes/config"
|
||||
"git.sr.ht/~cco/go-scopes/core/action"
|
||||
"git.sr.ht/~cco/go-scopes/core/message"
|
||||
)
|
||||
|
||||
func DefaultConfig(name string) lib.Config {
|
||||
|
@ -14,11 +13,14 @@ func DefaultConfig(name string) lib.Config {
|
|||
}
|
||||
|
||||
func create(act lib.Action) bool {
|
||||
ctx := act.Context()
|
||||
spec := act.Spec()
|
||||
msg := act.Message()
|
||||
//spec := act.ActionSpec()
|
||||
cctx := createCell(act.Context())
|
||||
nmsg := message.New("matrix", "connect").WithSender(cctx)
|
||||
msg.Sender().Cell().Send(nmsg)
|
||||
cctx := createCell(ctx)
|
||||
//nmsg := message.New("matrix", "connect").WithSender(cctx)
|
||||
//msg.Sender().Cell().Send(nmsg)
|
||||
connect(ctx, cctx, spec, msg)
|
||||
connect(cctx, msg.Sender().Cell(), spec, msg)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -28,3 +30,6 @@ func createCell(ctx lib.Context) lib.Context {
|
|||
cfg.Starter()(cctx)
|
||||
return cctx
|
||||
}
|
||||
|
||||
func connect(src, tgt lib.Context, spec lib.ActionSpec, msg lib.Message) {
|
||||
}
|
||||
|
|
|
@ -16,15 +16,16 @@ func TestMatrixApp(tb *tbase.T) {
|
|||
t := testing.SetUpApp(tb, etc.ConfigMx())
|
||||
t.Run("app-matrix", MxTest)
|
||||
t.TearDownApp("matrix")
|
||||
t.AssertEqual(t.LogCheck(logfile, true), 8)
|
||||
t.AssertEqual(t.LogCheck(logfile, true), 7)
|
||||
}
|
||||
|
||||
func MxTest(t *testing.T) {
|
||||
ctx := t.Ctx
|
||||
t.AssertEqual(len(ctx.Services()), 3)
|
||||
rcvr := ctx.Services()["cell-0"]
|
||||
msg := message.SimpleMessage("create").WithSender(rcvr)
|
||||
rcvr.Send(msg)
|
||||
c0 := ctx.Services()["cell-0"]
|
||||
rcvr := ctx.Services()["test-receiver"]
|
||||
msg := message.New("matrix", "create").WithSender(rcvr)
|
||||
c0.Send(msg)
|
||||
}
|
||||
|
||||
// action handlers
|
||||
|
|
Loading…
Add table
Reference in a new issue