Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
90b3ae07
Commit
90b3ae07
authored
3 years ago
by
Kaustubh Murumkar
Browse files
Options
Downloads
Patches
Plain Diff
Handle txn while calling service
parent
00f777af
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!252
staging branch is merged into devbranch.
,
!246
Transaction handle support added for call service.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routebuildermdl/serviceCachemdl.go
+52
-0
routebuildermdl/serviceCachemdl.go
with
52 additions
and
0 deletions
routebuildermdl/serviceCachemdl.go
+
52
−
0
View file @
90b3ae07
...
@@ -205,3 +205,55 @@ func CallServiceWithBranch(name, branch string, rs *gjson.Result, isRestricted b
...
@@ -205,3 +205,55 @@ func CallServiceWithBranch(name, branch string, rs *gjson.Result, isRestricted b
}
}
return
res
,
nil
return
res
,
nil
}
}
// CallServiceTXN - calls service with provided configuration, returns result and error from executed service
func
CallServiceTXN
(
name
string
,
rs
*
gjson
.
Result
,
isRestricted
bool
,
isRoleBased
bool
,
p
servicebuildermdl
.
Principal
)
(
interface
{},
*
servicebuildermdl
.
AbstractBusinessLogicHolder
,
error
)
{
return
CallServiceWithBranchHandleTXN
(
name
,
constantmdl
.
Branch_Main
,
rs
,
isRestricted
,
isRoleBased
,
p
)
}
// CallServiceWithBranchHandleTXN - calls service of given branch with provided configuration, returns result and error from executed service and handles transaction
func
CallServiceWithBranchHandleTXN
(
name
,
branch
string
,
rs
*
gjson
.
Result
,
isRestricted
bool
,
isRoleBased
bool
,
p
servicebuildermdl
.
Principal
)
(
interface
{},
*
servicebuildermdl
.
AbstractBusinessLogicHolder
,
error
)
{
var
found
bool
var
service
interface
{}
if
strings
.
TrimSpace
(
branch
)
==
""
{
loggermdl
.
LogError
(
"Branch is empty"
)
return
nil
,
nil
,
errormdl
.
Wrap
(
"Branch is empty"
)
}
activityName
:=
ConcatenateEntityWithBranch
(
name
,
branch
)
// if isRestricted {
// if isRoleBased {
// service, found = roleBasedServices.Get(activityName)
// } else {
// service, found = restrictedServices.Get(activityName)
// }
// } else {
// service, found = openServices.Get(activityName)
// }
switch
{
case
isRestricted
==
true
&&
isRoleBased
==
true
:
service
,
found
=
roleBasedServices
.
Get
(
activityName
)
case
isRestricted
==
true
&&
isRoleBased
==
false
:
service
,
found
=
restrictedServices
.
Get
(
activityName
)
case
isRestricted
==
false
:
service
,
found
=
openServices
.
Get
(
activityName
)
}
if
!
found
{
loggermdl
.
LogError
(
"Service Not Found: "
+
name
)
return
nil
,
nil
,
errormdl
.
Wrap
(
"Service Not Found: "
+
name
)
}
tmpSvcCache
,
ok
:=
service
.
(
ServiceCache
)
if
!
ok
{
loggermdl
.
LogError
(
"Unable to cast service object for "
,
name
)
return
nil
,
nil
,
errormdl
.
Wrap
(
"Service execution failed for "
+
name
)
}
serviceCache
:=
tmpSvcCache
res
,
ab
,
err
:=
serviceCache
.
Service
(
rs
,
p
)
if
err
!=
nil
{
loggermdl
.
LogError
(
"Service execution failed for "
,
name
,
" : "
,
err
)
return
nil
,
nil
,
err
}
return
res
,
ab
,
nil
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets