Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
3a2aaed8
Commit
3a2aaed8
authored
Aug 03, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a Struct to keep track of failure info
parent
0dd4c306
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
lib/gitlab/git/storage/circuit_breaker.rb
lib/gitlab/git/storage/circuit_breaker.rb
+7
-11
No files found.
lib/gitlab/git/storage/circuit_breaker.rb
View file @
3a2aaed8
...
...
@@ -2,6 +2,8 @@ module Gitlab
module
Git
module
Storage
class
CircuitBreaker
FailureInfo
=
Struct
.
new
(
:last_failure
,
:failure_count
)
attr_reader
:storage
,
:hostname
,
:storage_path
,
...
...
@@ -10,6 +12,8 @@ module Gitlab
:failure_reset_time
,
:storage_timeout
delegate
:last_failure
,
:failure_count
,
to: :failure_info
def
self
.
reset_all!
pattern
=
"
#{
Gitlab
::
Git
::
Storage
::
REDIS_KEY_PREFIX
}
*"
...
...
@@ -93,7 +97,7 @@ module Gitlab
end
def
track_storage_inaccessible
@failure_info
=
[
Time
.
now
,
failure_count
+
1
]
@failure_info
=
FailureInfo
.
new
(
Time
.
now
,
failure_count
+
1
)
Gitlab
::
Git
::
Storage
.
redis
.
with
do
|
redis
|
redis
.
pipelined
do
...
...
@@ -107,7 +111,7 @@ module Gitlab
def
track_storage_accessible
return
if
no_failures?
@failure_info
=
[
nil
,
0
]
@failure_info
=
FailureInfo
.
new
(
nil
,
0
)
Gitlab
::
Git
::
Storage
.
redis
.
with
do
|
redis
|
redis
.
pipelined
do
...
...
@@ -117,14 +121,6 @@ module Gitlab
end
end
def
last_failure
failure_info
.
first
end
def
failure_count
failure_info
.
last
end
def
failure_info
@failure_info
||=
get_failure_info
end
...
...
@@ -136,7 +132,7 @@ module Gitlab
last_failure
=
Time
.
at
(
last_failure
.
to_i
)
if
last_failure
.
present?
[
last_failure
,
failure_count
.
to_i
]
FailureInfo
.
new
(
last_failure
,
failure_count
.
to_i
)
end
def
cache_key
...
...
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