Merge branch 'feat/47-G-fix11-a3h' into feat/47-G-join11
This commit is contained in:
@@ -29,6 +29,13 @@ func (c *Conn) EmitSeat(seat, event string, body any, opts ...stdio.EmitOptions)
|
||||
return c.emitOn("mesh.seat."+seat+".event."+event, body, opts)
|
||||
}
|
||||
|
||||
// Accept sends the seat's holder an accepted kind (design 47 G §677, lead answer A-273): one call, publishing on
|
||||
// mesh.seat.<seat>.accept.<kind>.<caller>, the caller being this process's module, with the same envelope, headers and
|
||||
// message id as Emit. The grants part grants every user of a seat the publish of its accept subjects that name it.
|
||||
func (c *Conn) Accept(seat, kind string, body any, opts ...stdio.EmitOptions) error {
|
||||
return c.emitOn("mesh.seat."+seat+".accept."+kind+"."+c.account.Module, body, opts)
|
||||
}
|
||||
|
||||
// emitOn publishes body on subject with the SDK's envelope.
|
||||
func (c *Conn) emitOn(subject string, body any, opts []stdio.EmitOptions) error {
|
||||
data, err := json.Marshal(body)
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestEmitTwiceWithTheSameIDIsKeptToOneWithTheSDKsHeaders(t *testing.T) {
|
||||
account.Node = "novox"
|
||||
_, adminJetStream := adminJS(t, url)
|
||||
stream, err := adminJetStream.CreateStream(ctxFor(t), jetstream.StreamConfig{
|
||||
Name: "MAIL_EVENTS", Subjects: []string{"mesh.mod.mesh-mail.event.>", "mesh.seat.mail-sender.event.>"}, Duplicates: time.Minute,
|
||||
Name: "MAIL_EVENTS", Subjects: []string{"mesh.mod.mesh-mail.event.>", "mesh.seat.mail-sender.event.>", "mesh.seat.mail-sender.accept.>"}, Duplicates: time.Minute,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("the admin could not make the events stream: %v", err)
|
||||
@@ -45,12 +45,20 @@ func TestEmitTwiceWithTheSameIDIsKeptToOneWithTheSDKsHeaders(t *testing.T) {
|
||||
t.Fatalf("the seat's event: %v, %v", m, err)
|
||||
}
|
||||
|
||||
// An accepted kind goes on mesh.seat.<seat>.accept.<kind>.<caller>, the caller this process's module (A-273).
|
||||
if err := conn.Accept("mail-sender", "send", map[string]any{"send": "s2"}, stdio.EmitOptions{MessageID: "accept-s2"}); err != nil {
|
||||
t.Fatalf("Accept: %v", err)
|
||||
}
|
||||
if m, err := stream.GetLastMsgForSubject(ctxFor(t), "mesh.seat.mail-sender.accept.send.mesh-mail"); err != nil || m.Header.Get("x-event-id") != "accept-s2" || m.Header.Get("x-source") != "mesh-mail" {
|
||||
t.Fatalf("the accepted kind: %v, %v", m, err)
|
||||
}
|
||||
|
||||
info, err := stream.Info(ctxFor(t))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if info.State.Msgs != 2 {
|
||||
t.Fatalf("the stream holds %d messages, want 2: one of the doubled publish, one of the seat's event", info.State.Msgs)
|
||||
if info.State.Msgs != 3 {
|
||||
t.Fatalf("the stream holds %d messages, want 3: one of the doubled publish, one of the seat's event, one accepted", info.State.Msgs)
|
||||
}
|
||||
|
||||
msg, err := stream.GetMsg(ctxFor(t), 1)
|
||||
|
||||
@@ -39,7 +39,8 @@ var sendGrants = []string{
|
||||
"mesh.mod.mesh-mail.event.mail.send.failed",
|
||||
"mesh.mod.mesh-mail.event.mail.send.sent",
|
||||
"mesh.mod.mesh-mail.event.states",
|
||||
"mesh.seat.mail-sender.event.sent", // a held seat's event, said through Conn.EmitSeat (design 47 G A-10)
|
||||
"mesh.seat.mail-sender.event.sent", // a held seat's event, said through Conn.EmitSeat (design 47 G A-10)
|
||||
"mesh.seat.mail-sender.accept.send.mesh-mail", // a kind accepted by a seat, sent through Conn.Accept (A-273)
|
||||
"mesh.seat.operator-channel.call.tell.*.novox~mesh-mail~send",
|
||||
"mesh.seat.operator-channel.call.tell.novox~mesh-mail~send",
|
||||
"mesh.seat.operator-channel.tool.tell",
|
||||
|
||||
Reference in New Issue
Block a user