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
f4a05767
Commit
f4a05767
authored
7 years ago
by
Ajit Jagtap
Browse files
Options
Downloads
Plain Diff
Merge branch 'Roshanp-GjsonHelpermdl' into 'devbranch'
Roshanp gjson helpermdl See merge request
!53
parents
fcce3c1c
9023c37c
2 merge requests
!54
Devbranch
,
!53
Roshanp gjson helpermdl
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dalmdl/fdb/fdbprod.go
+5
-11
dalmdl/fdb/fdbprod.go
gjsonhelpermdl/gjsonhelpermdl.go
+13
-6
gjsonhelpermdl/gjsonhelpermdl.go
loggermdl/loggerdefault.go
+1
-1
loggermdl/loggerdefault.go
loggermdl/loggerprod.go
+1
-1
loggermdl/loggerprod.go
with
20 additions
and
19 deletions
dalmdl/fdb/fdbprod.go
+
5
−
11
View file @
f4a05767
...
...
@@ -6,14 +6,8 @@
// Package fdb Prod this will compile only for production envirnoment
package
fdb
import
(
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/cachemdl"
)
func
init
()
{
Mastercache
=
cachemdl
.
CacheGCHelper
{}
//FIXME: Below hardcoded values need better number
Mastercache
.
Setup
(
5000
,
time
.
Second
*
500
)
}
// func init() {
// Mastercache = cachemdl.CacheGCHelper{}
// //FIXME: Below hardcoded values need better number
// Mastercache.Setup(5000, time.Second*500)
// }
This diff is collapsed.
Click to expand it.
gjsonhelpermdl/gjsonhelpermdl.go
+
13
−
6
View file @
f4a05767
...
...
@@ -6,12 +6,11 @@ import (
"unicode/utf16"
"unicode/utf8"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"github.com/tidwall/gjson"
)
// GetInterface - return interface of rs
func
GetInterface
(
t
*
gjson
.
Result
)
interface
{}
{
func
GetInterface
(
t
*
gjson
.
Result
,
timeStampKeys
...
string
)
interface
{}
{
if
t
.
Type
==
gjson
.
String
{
return
t
.
Str
}
...
...
@@ -23,7 +22,7 @@ func GetInterface(t *gjson.Result) interface{} {
case
gjson
.
Number
:
return
t
.
Num
case
gjson
.
JSON
:
r
:=
arrayOrMap
(
t
,
0
,
true
)
r
:=
arrayOrMap
(
t
,
0
,
true
,
timeStampKeys
...
)
if
r
.
vc
==
'{'
{
return
r
.
oi
}
else
if
r
.
vc
==
'['
{
...
...
@@ -43,7 +42,7 @@ type arrayOrMapResult struct {
vc
byte
}
func
arrayOrMap
(
t
*
gjson
.
Result
,
vc
byte
,
valueize
bool
)
(
r
arrayOrMapResult
)
{
func
arrayOrMap
(
t
*
gjson
.
Result
,
vc
byte
,
valueize
bool
,
timeStampKeys
...
string
)
(
r
arrayOrMapResult
)
{
var
json
=
t
.
Raw
var
i
int
var
value
gjson
.
Result
...
...
@@ -131,10 +130,9 @@ func arrayOrMap(t *gjson.Result, vc byte, valueize bool) (r arrayOrMapResult) {
}
else
{
if
valueize
{
if
_
,
ok
:=
r
.
oi
[
key
.
Str
];
!
ok
{
if
len
(
value
.
String
())
==
len
(
time
.
RFC3339Nano
)
{
if
len
(
timeStampKeys
)
>
0
&&
detectTimeStampKey
(
key
.
Str
,
timeStampKeys
)
{
t
,
err
:=
time
.
Parse
(
time
.
RFC3339Nano
,
value
.
String
())
if
err
==
nil
{
loggermdl
.
LogError
(
value
,
t
)
r
.
oi
[
key
.
Str
]
=
t
.
Local
()
}
else
{
r
.
oi
[
key
.
Str
]
=
value
.
Value
()
...
...
@@ -162,6 +160,15 @@ end:
return
}
func
detectTimeStampKey
(
key
string
,
timeStamppKeys
[]
string
)
bool
{
for
_
,
timeStampKey
:=
range
timeStamppKeys
{
if
timeStampKey
==
key
{
return
true
}
}
return
false
}
func
squash
(
json
string
)
string
{
// expects that the lead character is a '[' or '{'
// squash the value, ignoring all nested arrays and objects.
...
...
This diff is collapsed.
Click to expand it.
loggermdl/loggerdefault.go
+
1
−
1
View file @
f4a05767
//+build !prod
//
+build !prod
//@author Ajit Jagtap
//@version Thu Jul 05 2018 06:40:34 GMT+0530 (IST)
...
...
This diff is collapsed.
Click to expand it.
loggermdl/loggerprod.go
+
1
−
1
View file @
f4a05767
//+build prod
//
+build prod
package
loggermdl
...
...
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