NATS is an OCLIB tool

This commit is contained in:
mr 2024-08-21 10:21:17 +02:00
parent 649a1098c3
commit b7ecea25eb
2 changed files with 8 additions and 12 deletions

View File

@ -139,7 +139,7 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delete bool) (int, error) {
var err error
nats := tools.NATSCaller{}
nats := tools.NewNATSCaller()
res, code, _ := wfa.LoadOne(id)
if code != 200 {
return 404, errors.New("could not load workflow")

View File

@ -31,21 +31,17 @@ func (d NATSMethod) String() string {
return [...]string{"remove", "create"}[d]
}
type NATSCaller struct {
natsUrl string
type natsCaller struct{}
func NewNATSCaller() *natsCaller {
return &natsCaller{}
}
func NewNATSCaller(url string) *NATSCaller {
return &NATSCaller{
natsUrl: url,
}
}
func (o *NATSCaller) SetNATSPub(dataName string, method NATSMethod, data interface{}) string {
if o.natsUrl == "" {
func (o *natsCaller) SetNATSPub(dataName string, method NATSMethod, data interface{}) string {
if GetConfig().NATSUrl == "" {
return " -> NATS_SERVER is not set"
}
nc, err := nats.Connect(o.natsUrl)
nc, err := nats.Connect(GetConfig().NATSUrl)
if err != nil {
return " -> Could not reach NATS server : " + err.Error()
}