28 lines
831 B
Go
28 lines
831 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/nats-io/nats.go/jetstream"
|
|
|
|
occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
|
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
|
)
|
|
|
|
// sayVia says a condition of the part on its own subject, as a module that uses the seat operator-channel may: the
|
|
// account consumers that differ, a grant missing, a user list held, a principal refused.
|
|
func sayVia(ctx context.Context, js jetstream.JetStream, module string) func(c oc.Condition) error {
|
|
return func(c oc.Condition) error {
|
|
subject, err := occ.ConditionSubject(module)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
data, err := occ.EncodeCondition(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = js.Publish(ctx, subject, data)
|
|
return err
|
|
}
|
|
}
|