BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
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