Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
ef521f35
Commit
ef521f35
authored
Feb 24, 2020
by
vrg0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5s延时监控门限可配置
parent
8c99c8ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
delayed5s.go
pkg/points/delayed5s.go
+19
-9
No files found.
pkg/points/delayed5s.go
View file @
ef521f35
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"git.quantgroup.cn/DevOps/enoch/pkg/global"
"git.quantgroup.cn/DevOps/enoch/pkg/global"
"github.com/vrg0/go-common/logger"
"github.com/vrg0/go-common/logger"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zapcore"
"strconv"
"sync"
"sync"
"time"
"time"
)
)
...
@@ -14,10 +15,11 @@ type Node struct {
...
@@ -14,10 +15,11 @@ type Node struct {
}
}
type
Delayed5s
struct
{
type
Delayed5s
struct
{
Server
map
[
string
]
Node
Server
map
[
string
]
Node
Client
map
[
string
]
Node
Client
map
[
string
]
Node
lock
*
sync
.
Mutex
lock
*
sync
.
Mutex
save
*
logger
.
Logger
save
*
logger
.
Logger
duration
int
}
}
func
NewDelayed5s
()
*
Delayed5s
{
func
NewDelayed5s
()
*
Delayed5s
{
...
@@ -26,16 +28,24 @@ func NewDelayed5s() *Delayed5s {
...
@@ -26,16 +28,24 @@ func NewDelayed5s() *Delayed5s {
savePath
+=
"_delayed5s"
savePath
+=
"_delayed5s"
}
}
durationString
:=
global
.
Config
.
GetOrDefault
(
global
.
NamespaceApplication
,
"delayed5s.duration"
,
"1000000000"
)
durationInt
,
err
:=
strconv
.
Atoi
(
durationString
)
if
err
!=
nil
{
durationInt
=
1000000000
}
return
&
Delayed5s
{
return
&
Delayed5s
{
Server
:
make
(
map
[
string
]
Node
),
Server
:
make
(
map
[
string
]
Node
),
Client
:
make
(
map
[
string
]
Node
),
Client
:
make
(
map
[
string
]
Node
),
lock
:
new
(
sync
.
Mutex
),
lock
:
new
(
sync
.
Mutex
),
save
:
logger
.
New
(
savePath
,
zapcore
.
DebugLevel
),
save
:
logger
.
New
(
savePath
,
zapcore
.
DebugLevel
),
duration
:
durationInt
,
}
}
}
}
func
(
d
*
Delayed5s
)
Run
()
{
func
(
d
*
Delayed5s
)
Run
()
{
d
.
save
.
Info
(
"5s延时监控程序启动"
)
d
.
save
.
Info
(
"5s延时监控程序启动"
)
d
.
save
.
Info
(
"监控门限:"
,
d
.
duration
,
"us"
)
go
func
()
{
go
func
()
{
for
{
for
{
time
.
Sleep
(
time
.
Second
*
30
)
time
.
Sleep
(
time
.
Second
*
30
)
...
@@ -65,7 +75,7 @@ func (d *Delayed5s) Run() {
...
@@ -65,7 +75,7 @@ func (d *Delayed5s) Run() {
}
}
//Duration单位微妙,转化为纳秒
//Duration单位微妙,转化为纳秒
if
(
clientNode
.
Points
.
Duration
-
serverNode
.
Points
.
Duration
)
*
1e3
>
int
(
1
*
time
.
Second
)
{
if
(
clientNode
.
Points
.
Duration
-
serverNode
.
Points
.
Duration
)
*
1e3
>
d
.
duration
{
d
.
save
.
Info
(
clientNode
.
Points
,
serverNode
.
Points
)
d
.
save
.
Info
(
clientNode
.
Points
,
serverNode
.
Points
)
delete
(
d
.
Client
,
id
)
delete
(
d
.
Client
,
id
)
delete
(
d
.
Server
,
id
)
delete
(
d
.
Server
,
id
)
...
...
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