Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Job Queues
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Services
Job Queues
Commits
6e28dc05
Verified
Commit
6e28dc05
authored
4 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
feat: queue info
parent
9bcb6325
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.idea/workspace.xml
+3
-1
3 additions, 1 deletion
.idea/workspace.xml
manager.go
+6
-0
6 additions, 0 deletions
manager.go
queue.go
+54
-0
54 additions, 0 deletions
queue.go
with
63 additions
and
1 deletion
.idea/workspace.xml
+
3
−
1
View file @
6e28dc05
...
...
@@ -6,7 +6,8 @@
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"9979eb22-471e-4f2f-b624-fd3edb5e8c6e"
name=
"Changes"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/worker.go"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/worker.go"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/manager.go"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/manager.go"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/queue.go"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/queue.go"
afterDir=
"false"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
...
@@ -256,6 +257,7 @@
<workItem
from=
"1734001335693"
duration=
"5602000"
/>
<workItem
from=
"1734012566872"
duration=
"4517000"
/>
<workItem
from=
"1734022155342"
duration=
"424000"
/>
<workItem
from=
"1734024671338"
duration=
"491000"
/>
</task>
<servers
/>
</component>
...
...
This diff is collapsed.
Click to expand it.
manager.go
+
6
−
0
View file @
6e28dc05
...
...
@@ -57,6 +57,12 @@ func NewManager() *Manager {
}
func
(
m
*
Manager
)
GetQueueStats
()
QueueStats
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
return
m
.
queue
.
Stats
()
}
// GetEventBus returns the event bus
func
(
m
*
Manager
)
GetEventBus
()
*
EventBus
{
m
.
mu
.
Lock
()
...
...
This diff is collapsed.
Click to expand it.
queue.go
+
54
−
0
View file @
6e28dc05
...
...
@@ -191,3 +191,57 @@ func removeJobID(deps []JobID, id JobID) []JobID {
}
return
deps
}
type
QueueStats
struct
{
ReadyQueueLength
int
`json:"ReadyQueueLength"`
JobMapLength
int
`json:"JobMapLength"`
PendingDeps
int
`json:"PendingDeps"`
ProcessedJobsCount
int
`json:"ProcessedJobsCount"`
MaxAgeReachedCount
int
`json:"MaxAgeReachedCount"`
PendingDependenciesCount
int
`json:"PendingDependenciesCount"`
OldestProcessedJobAge
time
.
Duration
`json:"OldestProcessedJobAge"`
}
// Stats computes and returns the statistics of the job queue
func
(
q
*
Queue
)
Stats
()
QueueStats
{
q
.
mu
.
Lock
()
defer
q
.
mu
.
Unlock
()
// Calculate the oldest processed job age
var
oldestProcessedJobAge
time
.
Duration
if
len
(
q
.
processedJobs
)
>
0
{
oldestAge
:=
time
.
Now
()
.
Sub
(
q
.
processedJobs
[
0
]
.
ProcessedTime
)
for
_
,
job
:=
range
q
.
processedJobs
{
jobAge
:=
time
.
Now
()
.
Sub
(
job
.
ProcessedTime
)
if
jobAge
>
oldestAge
{
oldestAge
=
jobAge
}
}
oldestProcessedJobAge
=
oldestAge
}
// Count how many jobs have reached MaxAge
maxAgeReachedCount
:=
0
currentTime
:=
time
.
Now
()
for
_
,
jobInfo
:=
range
q
.
processedJobs
{
if
currentTime
.
Sub
(
jobInfo
.
ProcessedTime
)
>
MaxAge
{
maxAgeReachedCount
++
}
}
// Count all pending dependencies
var
totalPendingDeps
=
0
for
_
,
deps
:=
range
q
.
pendingDependencies
{
totalPendingDeps
+=
len
(
deps
)
}
return
QueueStats
{
ReadyQueueLength
:
len
(
q
.
readyQueue
),
JobMapLength
:
len
(
q
.
jobMap
),
PendingDeps
:
len
(
q
.
pendingDependencies
),
ProcessedJobsCount
:
len
(
q
.
processedJobs
),
MaxAgeReachedCount
:
maxAgeReachedCount
,
PendingDependenciesCount
:
totalPendingDeps
,
OldestProcessedJobAge
:
oldestProcessedJobAge
,
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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