shared peer conn
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
|
||||
@@ -55,11 +56,18 @@ func (wfa *Workflow) CheckBooking(subPath string) (bool, error) {
|
||||
continue
|
||||
}
|
||||
// CHECK BOOKING
|
||||
url := dc.(*datacenter.DatacenterResource).SourceUrl
|
||||
caller := tools.NewHTTPCaller("", "", "", "")
|
||||
peerID := dc.(*datacenter.DatacenterResource).PeerID
|
||||
if peerID == "" {
|
||||
return false, errors.New("no peer id")
|
||||
}
|
||||
p, code, err := (&peer.Peer{}).GetAccessor(nil).LoadOne(peerID)
|
||||
if code != 200 {
|
||||
return false, err
|
||||
}
|
||||
caller := tools.NewHTTPCaller(map[string]map[tools.METHOD]string{})
|
||||
subPath = strings.ReplaceAll(subPath, ":start_date", wfa.getFormat(wfa.Schedule.Start))
|
||||
subPath = strings.ReplaceAll(subPath, ":end_date", wfa.getFormat(&e))
|
||||
resp, err := caller.CallGet(url, subPath)
|
||||
resp, err := caller.CallGet(p.(*peer.Peer).Url, subPath)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@@ -8,11 +8,13 @@ import (
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workspace"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
cron "github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
@@ -82,9 +84,13 @@ func (wfa *workflowMongoAccessor) DeleteOne(id string) (utils.DBObject, int, err
|
||||
}
|
||||
|
||||
func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*workflow_execution.WorkflowExecution) error {
|
||||
if wfa.Caller == nil {
|
||||
if wfa.Caller == nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.WORKFLOW_EXECUTION.String()] == nil {
|
||||
return errors.New("no caller defined")
|
||||
}
|
||||
methods := wfa.Caller.URLS[utils.WORKFLOW_EXECUTION.String()]
|
||||
if _, ok := methods[tools.POST]; !ok {
|
||||
return errors.New("no path found")
|
||||
}
|
||||
if realData.Schedule == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -103,8 +109,15 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
|
||||
continue
|
||||
}
|
||||
// CHECK BOOKING
|
||||
url := dc.(*datacenter.DatacenterResource).SourceUrl
|
||||
resp, err := wfa.Caller.CallPost(url, wfa.Caller.DestSubPath, (&workflow_execution.WorkflowExecutions{
|
||||
peerID := dc.(*datacenter.DatacenterResource).PeerID
|
||||
if peerID == "" {
|
||||
continue
|
||||
}
|
||||
p, code, _ := (&peer.Peer{}).GetAccessor(nil).LoadOne(peerID)
|
||||
if code != 200 {
|
||||
continue
|
||||
}
|
||||
resp, err := wfa.Caller.CallPost(p.(*peer.Peer).Url, methods[tools.POST], (&workflow_execution.WorkflowExecutions{
|
||||
Executions: execs,
|
||||
}).Serialize())
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user