Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
f51bbb91
Commit
f51bbb91
authored
5 years ago
by
Ming Deng
Browse files
Options
Downloads
Patches
Plain Diff
Adding GracefulShutdownFilter
parent
7d89d02b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
config/graceful_shutdown.go
+20
-9
20 additions, 9 deletions
config/graceful_shutdown.go
with
20 additions
and
9 deletions
config/graceful_shutdown.go
+
20
−
9
View file @
f51bbb91
...
...
@@ -110,9 +110,9 @@ func BeforeShutdown() {
// If this application is not the provider, it will do nothing
destroyProviderProtocols
()
// waiting for accepted requests to be processed.
// reject sending the new request, and waiting for response of sending requests
waitForSendingRequests
()
// after this step, the response from other providers will be rejected.
// If this application is not the consumer, it will do nothing
destroyConsumerProtocols
()
...
...
@@ -134,7 +134,10 @@ func destroyConsumerProtocols() {
if
consumerConfig
==
nil
||
consumerConfig
.
ProtocolConf
==
nil
{
return
}
destroyProtocols
(
consumerConfig
.
ProtocolConf
)
protocols
:=
consumerConfig
.
ProtocolConf
.
(
map
[
interface
{}]
interface
{})
for
name
,
_
:=
range
protocols
{
extension
.
GetProtocol
(
name
.
(
string
))
.
Destroy
()
}
}
/**
...
...
@@ -148,13 +151,21 @@ func destroyProviderProtocols() {
if
providerConfig
==
nil
||
providerConfig
.
ProtocolConf
==
nil
{
return
}
destroyProtocols
(
providerConfig
.
ProtocolConf
)
}
func
destroyProtocols
(
protocolConf
interface
{})
{
protocols
:=
protocolConf
.
(
map
[
interface
{}]
interface
{})
consumerProtocol
:=
make
(
map
[
string
]
interface
{},
0
)
if
consumerConfig
!=
nil
&&
consumerConfig
.
ProtocolConf
!=
nil
{
consumerProtocol
=
consumerConfig
.
ProtocolConf
.
(
map
[
string
]
interface
{})
}
protocols
:=
providerConfig
.
ProtocolConf
.
(
map
[
string
]
interface
{})
for
name
,
_
:=
range
protocols
{
extension
.
GetProtocol
(
name
.
(
string
))
.
Destroy
()
_
,
found
:=
consumerProtocol
[
name
]
// the protocol is the consumer's protocol, we can not destroy it.
if
found
{
continue
}
extension
.
GetProtocol
(
name
)
.
Destroy
()
}
}
...
...
@@ -185,7 +196,7 @@ func waitForReceivingRequests() {
}
// for consumer. It will wait for the response of sending requests
func
waitForSendingRequests
()
{
func
waitForSendingRequests
()
{
logger
.
Info
(
"Graceful shutdown --- Keep waiting until sending requests getting response or timeout "
)
if
consumerConfig
==
nil
||
consumerConfig
.
ShutdownConfig
==
nil
{
// ignore this step
...
...
This diff is collapsed.
Click to expand it.
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