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
3567a1ca
Commit
3567a1ca
authored
5 years ago
by
Ajit Jagtap
Browse files
Options
Downloads
Plain Diff
Merge branch 'ab_Add_ServiceCaller' into 'devbranch'
Add: Service caller See merge request
!72
parents
4e4e7947
23e4a451
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!72
Add: Service caller
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routebuildermdl/serviceCachemdl.go
+34
-0
routebuildermdl/serviceCachemdl.go
with
34 additions
and
0 deletions
routebuildermdl/serviceCachemdl.go
+
34
−
0
View file @
3567a1ca
...
...
@@ -4,6 +4,7 @@ import (
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/servicebuildermdl"
version
"github.com/hashicorp/go-version"
...
...
@@ -119,3 +120,36 @@ func SetAppVersion(appVersion, minSupportedVersion string) error {
isAppVersionEnabled
=
true
return
nil
}
// CallService - calls service with provided configuration, returns result and error from executed service
func
CallService
(
name
string
,
rs
*
gjson
.
Result
,
isRestricted
bool
,
isRoleBased
bool
,
p
servicebuildermdl
.
Principal
)
(
interface
{},
error
)
{
var
found
bool
var
service
interface
{}
if
isRestricted
{
if
isRoleBased
{
service
,
found
=
roleBasedServices
.
Get
(
name
)
}
else
{
service
,
found
=
restrictedServices
.
Get
(
name
)
}
}
else
{
service
,
found
=
openServices
.
Get
(
name
)
}
if
!
found
{
loggermdl
.
LogError
(
"Service Not Found: "
+
name
)
return
nil
,
errormdl
.
Wrap
(
"Service Not Found: "
+
name
)
}
tmpSvcCache
,
ok
:=
service
.
(
ServiceCache
)
if
!
ok
{
loggermdl
.
LogError
(
"Unable to cast service object for "
,
name
)
return
nil
,
errormdl
.
Wrap
(
"Service execution failed for "
+
name
)
}
serviceCache
:=
tmpSvcCache
res
,
_
,
err
:=
serviceCache
.
Service
(
rs
,
p
)
if
err
!=
nil
{
loggermdl
.
LogError
(
"Service execution failed for "
,
name
)
return
nil
,
errormdl
.
Wrap
(
"Service execution failed for "
+
name
)
}
return
res
,
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