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
34ed3497
Commit
34ed3497
authored
6 years ago
by
Ajit Jagtap
Browse files
Options
Downloads
Patches
Plain Diff
Removed Loggers
parent
5df94ae3
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!23
Devbranch to Master
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
dalmdl/fdb/fdb.go
+1
-16
dalmdl/fdb/fdb.go
errormdl/errormdl_test.go
+18
-3
errormdl/errormdl_test.go
loggermdl/loggerdefault.go
+0
-43
loggermdl/loggerdefault.go
loggermdl/loggerdefault_test.go
+0
-2
loggermdl/loggerdefault_test.go
servicebuildermdl/servicebuildermdl.go
+2
-2
servicebuildermdl/servicebuildermdl.go
servicebuildermdl/servicebuildermdl_test.go
+23
-1
servicebuildermdl/servicebuildermdl_test.go
with
44 additions
and
67 deletions
dalmdl/fdb/fdb.go
+
1
−
16
View file @
34ed3497
...
...
@@ -29,22 +29,14 @@ var (
// GetDataDAO will return query data
func
GetDataDAO
(
filePath
,
query
string
,
isCachable
bool
,
rs
gjson
.
Result
)
(
gjson
.
Result
,
error
)
{
loggermdl
.
LogDebug
(
"GetDataDAO Started"
)
if
rs
.
Raw
!=
""
{
loggermdl
.
LogDebug
(
"GetDataDAO rs.Raw is not empty"
)
rs
=
rs
.
Get
(
query
)
return
rs
,
nil
}
if
isCachable
{
loggermdl
.
LogDebug
(
"GetDataDAO isCachable is on"
)
data
,
err
:=
Mastercache
.
Get
(
filePath
+
query
)
if
errormdl
.
CheckErr
(
err
)
!=
nil
{
loggermdl
.
LogWarn
(
"getDataFromMasterCache key not found"
)
}
else
{
if
errormdl
.
CheckErr
(
err
)
==
nil
{
val
,
ok
:=
data
.
(
gjson
.
Result
)
if
errormdl
.
CheckBool
(
ok
)
{
return
val
,
nil
...
...
@@ -56,23 +48,16 @@ func GetDataDAO(filePath, query string, isCachable bool, rs gjson.Result) (gjson
}
byteData
,
err
:=
getDataFromFDB
(
filePath
)
if
errormdl
.
CheckErr
(
err
)
!=
nil
{
loggermdl
.
LogWarn
(
"Got error in from getDataFromFDB func "
,
err
)
return
gjson
.
Result
{},
errormdl
.
CheckErr
(
err
)
}
if
query
==
constantmdl
.
STAR
{
loggermdl
.
LogDebug
(
"Firing Start query"
)
rs
=
gjson
.
ParseBytes
(
byteData
)
}
else
{
loggermdl
.
LogDebug
(
"this is not START query"
)
rs
=
gjson
.
ParseBytes
(
byteData
)
.
Get
(
query
)
}
if
isCachable
{
loggermdl
.
LogDebug
(
"isCachable is on"
)
err
:=
Mastercache
.
Set
(
filePath
+
query
,
rs
)
if
errormdl
.
CheckErr1
(
err
)
!=
nil
{
loggermdl
.
LogDebug
(
"Got error in Mastercache.Set"
)
loggermdl
.
LogWarn
(
errormdl
.
CheckErr1
(
err
))
return
rs
,
errormdl
.
CheckErr1
(
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
errormdl/errormdl_test.go
+
18
−
3
View file @
34ed3497
...
...
@@ -18,10 +18,25 @@ func TestCoreError_Wrap(t *testing.T) {
}
func
TestCheckBool
(
t
*
testing
.
T
)
{
IsTestingNegetiveCaseOn
=
true
assert
.
Tru
e
(
t
,
CheckBool
(
true
),
"it should return true"
)
IsTestingNegetiveCaseOnCheck
Int
=
false
IsTestingNegetiveCaseOn
CheckBool
=
true
assert
.
Fals
e
(
t
,
CheckBool
(
true
),
"it should return true"
)
IsTestingNegetiveCaseOnCheck
Bool
=
false
assert
.
False
(
t
,
CheckBool
(
false
),
"it should return false"
)
IsTestingNegetiveCaseOnCheckBool1
=
true
assert
.
False
(
t
,
CheckBool1
(
true
),
"it should return true"
)
IsTestingNegetiveCaseOnCheckBool1
=
false
assert
.
False
(
t
,
CheckBool1
(
false
),
"it should return false"
)
IsTestingNegetiveCaseOnCheckBool2
=
true
assert
.
False
(
t
,
CheckBool2
(
true
),
"it should return true"
)
IsTestingNegetiveCaseOnCheckBool2
=
false
assert
.
False
(
t
,
CheckBool2
(
false
),
"it should return false"
)
IsTestingNegetiveCaseOnCheckBool3
=
true
assert
.
False
(
t
,
CheckBool3
(
true
),
"it should return true"
)
IsTestingNegetiveCaseOnCheckBool3
=
false
assert
.
False
(
t
,
CheckBool3
(
false
),
"it should return false"
)
}
func
TestCheckError
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
loggermdl/loggerdefault.go
+
0
−
43
View file @
34ed3497
...
...
@@ -11,8 +11,6 @@ import (
"fmt"
"os"
"github.com/tidwall/gjson"
"github.com/TylerBrock/colorjson"
logging
"github.com/op/go-logging"
goon
"github.com/shurcooL/go-goon"
...
...
@@ -97,47 +95,6 @@ func LogJSONString(str string) {
fmt
.
Println
(
string
(
s
))
}
// LogJSONString Format string
func
LogGJSONString
(
obj
gjson
.
Result
)
{
// var objnew map[string]interface{}
// json.Unmarshal([]byte(str), &objnew)
f
:=
colorjson
.
NewFormatter
()
f
.
Indent
=
2
s
,
_
:=
f
.
Marshal
(
obj
.
Raw
)
fmt
.
Println
(
string
(
s
))
}
func
LogGJSONString2
(
obj
*
gjson
.
Result
)
{
// var objn ew map[string]interface{}
var
objnew1
map
[
string
]
interface
{}
// st := obj.Value
// fmt.Println(obj)
test
,
_
:=
json
.
Marshal
(
obj
)
// LogVars()
json
.
Unmarshal
(
test
,
&
objnew1
)
// fmt.Println(objnew1["Raw"])
somevar
:=
objnew1
[
"Raw"
]
mystr
:=
somevar
.
(
string
)
// fmt.Println("<<<<", mystr)
a
:=
`{"Age": 1,"Name": "sometext"}`
LogJSONString
(
mystr
)
LogJSONString
(
a
)
// test2, _ := json.Marshal(somevar)
// err1 := json.Unmarshal([]byte(somevar), &objnew)
// fmt.Println(err1, objnew)
// f := colorjson.NewFormatter()
// f.Indent = 2
// s, _ := f.Marshal(objnew)
// fmt.Println(string(s))
}
// LogHRStart can end line with <<<
func
LogHRStart
()
{
fmt
.
Println
(
">>>>>>>>>>>>>>>>>>>>>>>"
)
...
...
This diff is collapsed.
Click to expand it.
loggermdl/loggerdefault_test.go
+
0
−
2
View file @
34ed3497
//+build !prod
//@author Ajit Jagtap
//@version Thu Jul 05 2018 06:40:10 GMT+0530 (IST)
...
...
This diff is collapsed.
Click to expand it.
servicebuildermdl/servicebuildermdl.go
+
2
−
2
View file @
34ed3497
...
...
@@ -115,7 +115,7 @@ func (ab *AbstractBusinessLogicHolder) SetFinalData(data interface{}) {
// EchoBL sample EchoBL logic handler
func
(
ab
*
AbstractBusinessLogicHolder
)
EchoBL
()
map
[
string
]
interface
{}
{
loggermdl
.
LogWarn
(
"EchoBL called"
)
//
loggermdl.LogWarn("EchoBL called")
return
map
[
string
]
interface
{}{
"ok"
:
int64
(
1
),
}
...
...
@@ -174,7 +174,7 @@ func (sb *ServiceBuilder) Run() *ServiceBuilder {
tmp
:=
step
.
RunFunc
()
result
,
_
:=
yql
.
Match
(
step
.
RawYQL
,
tmp
)
if
!
result
{
loggermdl
.
LogWarn
(
step
.
Stepname
,
"Failed"
,
result
)
//
loggermdl.LogWarn(step.Stepname, "Failed", result)
step
.
ErrorFunc
()
break
}
...
...
This diff is collapsed.
Click to expand it.
servicebuildermdl/servicebuildermdl_test.go
+
23
−
1
View file @
34ed3497
...
...
@@ -20,7 +20,7 @@ type MyBLLayer struct {
// attach methods to it
func
(
m
*
MyBLLayer
)
FindAndVerifyMobileNumber
()
map
[
string
]
interface
{}
{
loginID
:=
"noone"
result1
,
ok
:=
m
.
GetResult
(
"daodata1"
)
result1
,
ok
:=
m
.
GetResult
set
(
"daodata1"
)
if
!
ok
{
loggermdl
.
LogError
(
"error in convert"
)
...
...
@@ -62,6 +62,28 @@ func TestService(t *testing.T) {
assert
.
Equal
(
t
,
"SystemIntegrator"
,
*
sb
,
"this should be same"
)
}
func
BenchmarkService
(
b
*
testing
.
B
)
{
for
index
:=
0
;
index
<
b
.
N
;
index
++
{
mb
:=
MyBLLayer
{}
mb
.
Build
()
loaddata
:=
func
(
ab
*
AbstractBusinessLogicHolder
)
{
mb
.
ServiceData
[
"daodata1"
]
=
GetUsersInfo
()
}
// finalStep := func(ab *AbstractBusinessLogicHolder) *interface{} {
// s :=
// return &s
// }
GetSB
(
"mysrv"
,
&
mb
.
AbstractBusinessLogicHolder
)
.
AddStep
(
"Check Mobile"
,
"owner in ('SystemIntegrator')"
,
loaddata
,
mb
.
FindAndVerifyMobileNumber
,
mb
.
EchoBL
)
.
AddStep
(
"Test STEP 2"
,
"owner = 'SystemIntegrator'"
,
nil
,
mb
.
FindAndVerifyMobileNumber
,
mb
.
EchoBL
)
.
Run
()
.
FinalOutput
(
nil
)
}
}
func
TestYQL
(
t
*
testing
.
T
)
{
a
:=
map
[
string
]
interface
{}{
"owner"
:
"a"
,
...
...
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