NATS is an OCLIB tool
This commit is contained in:
parent
649a1098c3
commit
b7ecea25eb
@ -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")
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user