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) {
|
func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delete bool) (int, error) {
|
||||||
var err error
|
var err error
|
||||||
nats := tools.NATSCaller{}
|
nats := tools.NewNATSCaller()
|
||||||
res, code, _ := wfa.LoadOne(id)
|
res, code, _ := wfa.LoadOne(id)
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
return 404, errors.New("could not load workflow")
|
return 404, errors.New("could not load workflow")
|
||||||
|
@ -31,21 +31,17 @@ func (d NATSMethod) String() string {
|
|||||||
return [...]string{"remove", "create"}[d]
|
return [...]string{"remove", "create"}[d]
|
||||||
}
|
}
|
||||||
|
|
||||||
type NATSCaller struct {
|
type natsCaller struct{}
|
||||||
natsUrl string
|
|
||||||
|
func NewNATSCaller() *natsCaller {
|
||||||
|
return &natsCaller{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNATSCaller(url string) *NATSCaller {
|
func (o *natsCaller) SetNATSPub(dataName string, method NATSMethod, data interface{}) string {
|
||||||
return &NATSCaller{
|
if GetConfig().NATSUrl == "" {
|
||||||
natsUrl: url,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *NATSCaller) SetNATSPub(dataName string, method NATSMethod, data interface{}) string {
|
|
||||||
if o.natsUrl == "" {
|
|
||||||
return " -> NATS_SERVER is not set"
|
return " -> NATS_SERVER is not set"
|
||||||
}
|
}
|
||||||
nc, err := nats.Connect(o.natsUrl)
|
nc, err := nats.Connect(GetConfig().NATSUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return " -> Could not reach NATS server : " + err.Error()
|
return " -> Could not reach NATS server : " + err.Error()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user