ax(mining): rename cb to circuitBreaker in FetchLatestGitHubVersion
AX Principle 1 — predictable names over short names. The local variable `cb` requires mental mapping; `circuitBreaker` names the value directly. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
dc2f415fc2
commit
1edbd19f25
1 changed files with 3 additions and 3 deletions
|
|
@ -36,16 +36,16 @@ type GitHubRelease struct {
|
|||
|
||||
// tag, err := FetchLatestGitHubVersion("xmrig", "xmrig") // "v6.21.0"
|
||||
func FetchLatestGitHubVersion(owner, repo string) (string, error) {
|
||||
cb := getGitHubCircuitBreaker()
|
||||
circuitBreaker := getGitHubCircuitBreaker()
|
||||
|
||||
result, err := cb.Execute(func() (interface{}, error) {
|
||||
result, err := circuitBreaker.Execute(func() (interface{}, error) {
|
||||
return fetchGitHubVersionDirect(owner, repo)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
// If circuit is open, try to return cached value with warning
|
||||
if err == ErrCircuitOpen {
|
||||
if cached, ok := cb.GetCached(); ok {
|
||||
if cached, ok := circuitBreaker.GetCached(); ok {
|
||||
if tagName, ok := cached.(string); ok {
|
||||
return tagName, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue