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
032e3101
Commit
032e3101
authored
4 years ago
by
Akshay Bharambe
2
Browse files
Options
Downloads
Patches
Plain Diff
Add: Display branchwise activity statistics
parent
fcb88377
Branches
Branches containing commit
Tags
MEP19.03.2020
Tags containing commit
2 merge requests
!220
Release v2.0.0 alpha
,
!219
Add: Support for branches
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
routebuildermdl/routebuildermdl.go
+2
-2
routebuildermdl/routebuildermdl.go
statemdl/state.go
+20
-2
statemdl/state.go
with
22 additions
and
4 deletions
routebuildermdl/routebuildermdl.go
+
2
−
2
View file @
032e3101
...
@@ -101,7 +101,7 @@ func executeServiceWithBranch(name, branch string, data []byte, isRestricted, is
...
@@ -101,7 +101,7 @@ func executeServiceWithBranch(name, branch string, data []byte, isRestricted, is
serviceCache
.
preHooksExec
(
&
rs
,
&
principalObj
)
serviceCache
.
preHooksExec
(
&
rs
,
&
principalObj
)
go
serviceCache
.
Service
(
&
rs
,
principalObj
)
go
serviceCache
.
Service
(
&
rs
,
principalObj
)
servingTime
:=
time
.
Since
(
start
)
servingTime
:=
time
.
Since
(
start
)
go
statemdl
.
UpdateServiceState
(
name
,
servingTime
,
serviceError
,
isRestricted
,
isRoleBased
)
go
statemdl
.
UpdateServiceState
WithBranch
(
name
,
branch
,
servingTime
,
serviceError
,
isRestricted
,
isRoleBased
)
return
asyncToken
,
nil
,
isCompressed
,
errormdl
.
NOERROR
,
nil
return
asyncToken
,
nil
,
isCompressed
,
errormdl
.
NOERROR
,
nil
}
}
rs
:=
gjson
.
ParseBytes
(
data
)
rs
:=
gjson
.
ParseBytes
(
data
)
...
@@ -112,7 +112,7 @@ func executeServiceWithBranch(name, branch string, data []byte, isRestricted, is
...
@@ -112,7 +112,7 @@ func executeServiceWithBranch(name, branch string, data []byte, isRestricted, is
servingTime
:=
time
.
Since
(
start
)
servingTime
:=
time
.
Since
(
start
)
// Record State for every service
// Record State for every service
go
statemdl
.
UpdateServiceState
(
name
,
servingTime
,
serviceError
,
isRestricted
,
isRoleBased
)
go
statemdl
.
UpdateServiceState
WithBranch
(
name
,
branch
,
servingTime
,
serviceError
,
isRestricted
,
isRoleBased
)
if
serviceError
==
nil
{
if
serviceError
==
nil
{
serviceCache
.
postHooksExec
(
result
,
&
principalObj
)
serviceCache
.
postHooksExec
(
result
,
&
principalObj
)
...
...
This diff is collapsed.
Click to expand it.
statemdl/state.go
+
20
−
2
View file @
032e3101
...
@@ -29,6 +29,7 @@ type Statistic struct {
...
@@ -29,6 +29,7 @@ type Statistic struct {
Description
string
`json:"description"`
Description
string
`json:"description"`
IsRestricted
bool
`json:"isRestricted"`
IsRestricted
bool
`json:"isRestricted"`
IsRoleBased
bool
`json:"isRoleBased"`
IsRoleBased
bool
`json:"isRoleBased"`
Branch
string
`json:"branch"`
// Only applicable to activity stats
}
}
type
groupResponse
struct
{
type
groupResponse
struct
{
...
@@ -196,17 +197,34 @@ func updateGroupCache(hitCount int64) {
...
@@ -196,17 +197,34 @@ func updateGroupCache(hitCount int64) {
// UpdateServiceState - update entry of service in state map
// UpdateServiceState - update entry of service in state map
func
UpdateServiceState
(
serviceName
string
,
servingTime
time
.
Duration
,
serviceError
error
,
isRestricted
,
isRoleBased
bool
)
{
func
UpdateServiceState
(
serviceName
string
,
servingTime
time
.
Duration
,
serviceError
error
,
isRestricted
,
isRoleBased
bool
)
{
UpdateServiceStateWithBranch
(
serviceName
,
"main"
,
servingTime
,
serviceError
,
isRestricted
,
isRoleBased
)
}
func
concatenateNameWithBranch
(
name
,
branch
string
)
string
{
if
branch
==
""
{
return
name
+
"_main"
}
return
name
+
"_"
+
branch
}
// UpdateServiceStateWithBranch - update entry of service from a branch in state map
func
UpdateServiceStateWithBranch
(
serviceName
,
branch
string
,
servingTime
time
.
Duration
,
serviceError
error
,
isRestricted
,
isRoleBased
bool
)
{
if
!
initStatus
{
if
!
initStatus
{
return
return
}
}
stateMutex
.
Lock
()
stateMutex
.
Lock
()
serviceState
,
ok
:=
stateCache
[
serviceName
]
key
:=
concatenateNameWithBranch
(
serviceName
,
branch
)
serviceState
,
ok
:=
stateCache
[
key
]
if
!
ok
{
if
!
ok
{
serviceState
=
Statistic
{
serviceState
=
Statistic
{
ServiceName
:
serviceName
,
ServiceName
:
serviceName
,
Name
:
serviceName
,
Name
:
serviceName
,
IsRestricted
:
isRestricted
,
IsRestricted
:
isRestricted
,
IsRoleBased
:
isRoleBased
,
IsRoleBased
:
isRoleBased
,
Branch
:
branch
,
}
}
}
}
serviceState
.
TotalHits
++
serviceState
.
TotalHits
++
...
@@ -224,7 +242,7 @@ func UpdateServiceState(serviceName string, servingTime time.Duration, serviceEr
...
@@ -224,7 +242,7 @@ func UpdateServiceState(serviceName string, servingTime time.Duration, serviceEr
serviceState
.
MinTime
=
servingTime
serviceState
.
MinTime
=
servingTime
}
}
}
}
stateCache
[
serviceName
]
=
serviceState
stateCache
[
key
]
=
serviceState
stateMutex
.
Unlock
()
stateMutex
.
Unlock
()
updateGlobalHit
()
updateGlobalHit
()
}
}
...
...
This diff is collapsed.
Click to expand it.
Ajit Jagtap
@ajitj
mentioned in commit
45b93576
·
4 years ago
mentioned in commit
45b93576
mentioned in commit 45b93576613fffa28ac13e87fd0c8f3486586208
Toggle commit list
Akshay Bharambe
@akshayb
mentioned in merge request
!226 (merged)
·
4 years ago
mentioned in merge request
!226 (merged)
mentioned in merge request !226
Toggle commit list
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