simplify path reservation
This commit is contained in:
@@ -47,12 +47,12 @@ func (wfa *collaborativeAreaMongoAccessor) sharedWorkspace(shared *Collaborative
|
||||
if eld.Workspaces != nil { // update all your workspaces in the eldest by replacing shared ref by an empty string
|
||||
for _, v := range eld.Workspaces {
|
||||
accessor.UpdateOne(&workspace.Workspace{Shared: ""}, v)
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.WORKSPACE.String()] == nil {
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[tools.WORKSPACE] == nil {
|
||||
continue
|
||||
}
|
||||
paccess := (&peer.Peer{}) // send to all peers
|
||||
for _, p := range shared.Peers { // delete the collaborative area on the peer
|
||||
b, err := paccess.LaunchPeerExecution(p, v, utils.WORKSPACE, tools.DELETE, nil, wfa.Caller)
|
||||
b, err := paccess.LaunchPeerExecution(p, v, tools.WORKSPACE, tools.DELETE, nil, wfa.Caller)
|
||||
if err != nil && b == nil {
|
||||
wfa.Logger.Error().Msg("Could not send to peer " + p + ". Error: " + err.Error())
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func (wfa *collaborativeAreaMongoAccessor) sharedWorkspace(shared *Collaborative
|
||||
if shared.Workspaces != nil {
|
||||
for _, v := range shared.Workspaces { // update all the collaborative areas
|
||||
workspace, code, _ := accessor.UpdateOne(&workspace.Workspace{Shared: shared.UUID}, v) // add the shared ref to workspace
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.WORKSPACE.String()] == nil {
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[tools.WORKSPACE] == nil {
|
||||
continue
|
||||
}
|
||||
for _, p := range shared.Peers {
|
||||
@@ -73,7 +73,7 @@ func (wfa *collaborativeAreaMongoAccessor) sharedWorkspace(shared *Collaborative
|
||||
paccess := (&peer.Peer{}) // send to all peers, add the collaborative area on the peer
|
||||
s := workspace.Serialize()
|
||||
s["name"] = fmt.Sprintf("%v", s["name"]) + "_" + p
|
||||
b, err := paccess.LaunchPeerExecution(p, v, utils.WORKSPACE, tools.POST, s, wfa.Caller)
|
||||
b, err := paccess.LaunchPeerExecution(p, v, tools.WORKSPACE, tools.POST, s, wfa.Caller)
|
||||
if err != nil && b == nil {
|
||||
wfa.Logger.Error().Msg("Could not send to peer " + p + ". Error: " + err.Error())
|
||||
}
|
||||
@@ -104,12 +104,12 @@ func (wfa *collaborativeAreaMongoAccessor) sharedWorkflow(shared *CollaborativeA
|
||||
n := &w.Workflow{}
|
||||
n.Shared = new
|
||||
accessor.UpdateOne(n, v)
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.WORKFLOW.String()] == nil {
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[tools.WORKFLOW] == nil {
|
||||
continue
|
||||
}
|
||||
paccess := (&peer.Peer{}) // send to all peers
|
||||
for _, p := range shared.Peers { // delete the shared workflow on the peer
|
||||
b, err := paccess.LaunchPeerExecution(p, v, utils.WORKFLOW, tools.DELETE, nil, wfa.Caller)
|
||||
b, err := paccess.LaunchPeerExecution(p, v, tools.WORKFLOW, tools.DELETE, nil, wfa.Caller)
|
||||
if err != nil && b == nil {
|
||||
wfa.Logger.Error().Msg("Could not send to peer " + p + ". Error: " + err.Error())
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func (wfa *collaborativeAreaMongoAccessor) sharedWorkflow(shared *CollaborativeA
|
||||
if !slices.Contains(s.Shared, id) {
|
||||
s.Shared = append(s.Shared, id)
|
||||
workflow, code, _ := accessor.UpdateOne(s, v)
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.WORKFLOW.String()] == nil {
|
||||
if wfa.Caller != nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[tools.WORKFLOW] == nil {
|
||||
continue
|
||||
}
|
||||
paccess := (&peer.Peer{})
|
||||
@@ -134,7 +134,7 @@ func (wfa *collaborativeAreaMongoAccessor) sharedWorkflow(shared *CollaborativeA
|
||||
if code == 200 {
|
||||
s := workflow.Serialize() // add the shared workflow on the peer
|
||||
s["name"] = fmt.Sprintf("%v", s["name"]) + "_" + p
|
||||
b, err := paccess.LaunchPeerExecution(p, shared.UUID, utils.WORKFLOW, tools.POST, s, wfa.Caller)
|
||||
b, err := paccess.LaunchPeerExecution(p, shared.UUID, tools.WORKFLOW, tools.POST, s, wfa.Caller)
|
||||
if err != nil && b == nil {
|
||||
wfa.Logger.Error().Msg("Could not send to peer " + p + ". Error: " + err.Error())
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func (wfa *collaborativeAreaMongoAccessor) sharedWorkflow(shared *CollaborativeA
|
||||
|
||||
// sharedWorkspace is a function that shares the collaborative area to the peers
|
||||
func (wfa *collaborativeAreaMongoAccessor) deleteToPeer(shared *CollaborativeArea) {
|
||||
if wfa.Caller == nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.COLLABORATIVE_AREA.String()] == nil {
|
||||
if wfa.Caller == nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[tools.COLLABORATIVE_AREA] == nil {
|
||||
return
|
||||
}
|
||||
paccess := (&peer.Peer{})
|
||||
@@ -158,7 +158,7 @@ func (wfa *collaborativeAreaMongoAccessor) deleteToPeer(shared *CollaborativeAre
|
||||
if (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: v}}).IsMySelf() {
|
||||
continue
|
||||
}
|
||||
b, err := paccess.LaunchPeerExecution(v, shared.UUID, utils.COLLABORATIVE_AREA, tools.DELETE, nil, wfa.Caller)
|
||||
b, err := paccess.LaunchPeerExecution(v, shared.UUID, tools.COLLABORATIVE_AREA, tools.DELETE, nil, wfa.Caller)
|
||||
if err != nil && b == nil {
|
||||
wfa.Logger.Error().Msg("Could not send to peer " + v + ". Error: " + err.Error())
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (wfa *collaborativeAreaMongoAccessor) deleteToPeer(shared *CollaborativeAre
|
||||
|
||||
// sharedWorkspace is a function that shares the collaborative area to the peers
|
||||
func (wfa *collaborativeAreaMongoAccessor) sendToPeer(shared *CollaborativeArea) {
|
||||
if wfa.Caller == nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[utils.COLLABORATIVE_AREA.String()] == nil {
|
||||
if wfa.Caller == nil || wfa.Caller.URLS == nil || wfa.Caller.URLS[tools.COLLABORATIVE_AREA] == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ func (wfa *collaborativeAreaMongoAccessor) sendToPeer(shared *CollaborativeArea)
|
||||
continue
|
||||
}
|
||||
shared.IsSent = true
|
||||
b, err := paccess.LaunchPeerExecution(v, v, utils.COLLABORATIVE_AREA, tools.POST, shared.Serialize(), wfa.Caller)
|
||||
b, err := paccess.LaunchPeerExecution(v, v, tools.COLLABORATIVE_AREA, tools.POST, shared.Serialize(), wfa.Caller)
|
||||
if err != nil && b == nil {
|
||||
wfa.Logger.Error().Msg("Could not send to peer " + v + ". Error: " + err.Error())
|
||||
}
|
||||
|
@@ -221,9 +221,9 @@ func (wfa *workspaceMongoAccessor) share(realData *Workspace, delete bool, calle
|
||||
continue
|
||||
}
|
||||
if delete { // If the workspace is deleted, share the deletion
|
||||
_, err = paccess.LaunchPeerExecution(p, res.GetID(), utils.WORKSPACE, tools.DELETE, map[string]interface{}{}, caller)
|
||||
_, err = paccess.LaunchPeerExecution(p, res.GetID(), tools.WORKSPACE, tools.DELETE, map[string]interface{}{}, caller)
|
||||
} else { // If the workspace is updated, share the update
|
||||
_, err = paccess.LaunchPeerExecution(p, res.GetID(), utils.WORKSPACE, tools.PUT, res.Serialize(), caller)
|
||||
_, err = paccess.LaunchPeerExecution(p, res.GetID(), tools.WORKSPACE, tools.PUT, res.Serialize(), caller)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user