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
7e9a10a5
Commit
7e9a10a5
authored
May 08, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renames alerting engine to match other services
parent
93a8d8a2
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 @
7e9a10a5
...
...
@@ -16,7 +16,7 @@ import (
"golang.org/x/sync/errgroup"
)
type
Engine
struct
{
type
Alerting
Engine
struct
{
execQueue
chan
*
Job
//clock clock.Clock
ticker
*
Ticker
...
...
@@ -28,20 +28,20 @@ type Engine struct {
}
func
init
()
{
registry
.
RegisterService
(
&
Engine
{})
registry
.
RegisterService
(
&
Alerting
Engine
{})
}
func
NewEngine
()
*
Engine
{
e
:=
&
Engine
{}
func
NewEngine
()
*
Alerting
Engine
{
e
:=
&
Alerting
Engine
{}
e
.
Init
()
return
e
}
func
(
e
*
Engine
)
IsDisabled
()
bool
{
func
(
e
*
Alerting
Engine
)
IsDisabled
()
bool
{
return
!
setting
.
AlertingEnabled
||
!
setting
.
ExecuteAlerts
}
func
(
e
*
Engine
)
Init
()
error
{
func
(
e
*
Alerting
Engine
)
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 *Engine) Init() error {
return
nil
}
func
(
e
*
Engine
)
Run
(
ctx
context
.
Context
)
error
{
func
(
e
*
Alerting
Engine
)
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 *Engine) Run(ctx context.Context) error {
return
err
}
func
(
e
*
Engine
)
alertingTicker
(
grafanaCtx
context
.
Context
)
error
{
func
(
e
*
Alerting
Engine
)
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 *Engine) alertingTicker(grafanaCtx context.Context) error {
}
}
func
(
e
*
Engine
)
runJobDispatcher
(
grafanaCtx
context
.
Context
)
error
{
func
(
e
*
Alerting
Engine
)
runJobDispatcher
(
grafanaCtx
context
.
Context
)
error
{
dispatcherGroup
,
alertCtx
:=
errgroup
.
WithContext
(
grafanaCtx
)
for
{
...
...
@@ -106,7 +106,7 @@ var (
alertMaxAttempts
=
3
)
func
(
e
*
Engine
)
processJobWithRetry
(
grafanaCtx
context
.
Context
,
job
*
Job
)
error
{
func
(
e
*
Alerting
Engine
)
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 *Engine) processJobWithRetry(grafanaCtx context.Context, job *Job) error
}
}
func
(
e
*
Engine
)
endJob
(
err
error
,
cancelChan
chan
context
.
CancelFunc
,
job
*
Job
)
error
{
func
(
e
*
Alerting
Engine
)
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 *Engine) endJob(err error, cancelChan chan context.CancelFunc, job *Job)
return
err
}
func
(
e
*
Engine
)
processJob
(
attemptID
int
,
attemptChan
chan
int
,
cancelChan
chan
context
.
CancelFunc
,
job
*
Job
)
{
func
(
e
*
Alerting
Engine
)
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