Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b6493587
Commit
b6493587
authored
May 08, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename alerting engine to service
parent
e1b9d361
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
pkg/services/alerting/engine.go
+12
-12
No files found.
pkg/services/alerting/engine.go
View file @
b6493587
...
...
@@ -16,7 +16,7 @@ import (
"golang.org/x/sync/errgroup"
)
type
Alerting
Engin
e
struct
{
type
Alerting
Servic
e
struct
{
execQueue
chan
*
Job
//clock clock.Clock
ticker
*
Ticker
...
...
@@ -28,20 +28,20 @@ type AlertingEngine struct {
}
func
init
()
{
registry
.
RegisterService
(
&
Alerting
Engin
e
{})
registry
.
RegisterService
(
&
Alerting
Servic
e
{})
}
func
NewEngine
()
*
Alerting
Engin
e
{
e
:=
&
Alerting
Engin
e
{}
func
NewEngine
()
*
Alerting
Servic
e
{
e
:=
&
Alerting
Servic
e
{}
e
.
Init
()
return
e
}
func
(
e
*
Alerting
Engin
e
)
IsDisabled
()
bool
{
func
(
e
*
Alerting
Servic
e
)
IsDisabled
()
bool
{
return
!
setting
.
AlertingEnabled
||
!
setting
.
ExecuteAlerts
}
func
(
e
*
Alerting
Engin
e
)
Init
()
error
{
func
(
e
*
Alerting
Servic
e
)
Init
()
error
{
e
.
ticker
=
NewTicker
(
time
.
Now
(),
time
.
Second
*
0
,
clock
.
New
())
e
.
execQueue
=
make
(
chan
*
Job
,
1000
)
e
.
scheduler
=
NewScheduler
()
...
...
@@ -52,7 +52,7 @@ func (e *AlertingEngine) Init() error {
return
nil
}
func
(
e
*
Alerting
Engin
e
)
Run
(
ctx
context
.
Context
)
error
{
func
(
e
*
Alerting
Servic
e
)
Run
(
ctx
context
.
Context
)
error
{
alertGroup
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
alertGroup
.
Go
(
func
()
error
{
return
e
.
alertingTicker
(
ctx
)
})
alertGroup
.
Go
(
func
()
error
{
return
e
.
runJobDispatcher
(
ctx
)
})
...
...
@@ -61,7 +61,7 @@ func (e *AlertingEngine) Run(ctx context.Context) error {
return
err
}
func
(
e
*
Alerting
Engin
e
)
alertingTicker
(
grafanaCtx
context
.
Context
)
error
{
func
(
e
*
Alerting
Servic
e
)
alertingTicker
(
grafanaCtx
context
.
Context
)
error
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
e
.
log
.
Error
(
"Scheduler Panic: stopping alertingTicker"
,
"error"
,
err
,
"stack"
,
log
.
Stack
(
1
))
...
...
@@ -86,7 +86,7 @@ func (e *AlertingEngine) alertingTicker(grafanaCtx context.Context) error {
}
}
func
(
e
*
Alerting
Engin
e
)
runJobDispatcher
(
grafanaCtx
context
.
Context
)
error
{
func
(
e
*
Alerting
Servic
e
)
runJobDispatcher
(
grafanaCtx
context
.
Context
)
error
{
dispatcherGroup
,
alertCtx
:=
errgroup
.
WithContext
(
grafanaCtx
)
for
{
...
...
@@ -106,7 +106,7 @@ var (
alertMaxAttempts
=
3
)
func
(
e
*
Alerting
Engin
e
)
processJobWithRetry
(
grafanaCtx
context
.
Context
,
job
*
Job
)
error
{
func
(
e
*
Alerting
Servic
e
)
processJobWithRetry
(
grafanaCtx
context
.
Context
,
job
*
Job
)
error
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
e
.
log
.
Error
(
"Alert Panic"
,
"error"
,
err
,
"stack"
,
log
.
Stack
(
1
))
...
...
@@ -141,7 +141,7 @@ func (e *AlertingEngine) processJobWithRetry(grafanaCtx context.Context, job *Jo
}
}
func
(
e
*
Alerting
Engin
e
)
endJob
(
err
error
,
cancelChan
chan
context
.
CancelFunc
,
job
*
Job
)
error
{
func
(
e
*
Alerting
Servic
e
)
endJob
(
err
error
,
cancelChan
chan
context
.
CancelFunc
,
job
*
Job
)
error
{
job
.
Running
=
false
close
(
cancelChan
)
for
cancelFn
:=
range
cancelChan
{
...
...
@@ -150,7 +150,7 @@ func (e *AlertingEngine) endJob(err error, cancelChan chan context.CancelFunc, j
return
err
}
func
(
e
*
Alerting
Engin
e
)
processJob
(
attemptID
int
,
attemptChan
chan
int
,
cancelChan
chan
context
.
CancelFunc
,
job
*
Job
)
{
func
(
e
*
Alerting
Servic
e
)
processJob
(
attemptID
int
,
attemptChan
chan
int
,
cancelChan
chan
context
.
CancelFunc
,
job
*
Job
)
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
e
.
log
.
Error
(
"Alert Panic"
,
"error"
,
err
,
"stack"
,
log
.
Stack
(
1
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment