add settings

This commit is contained in:
eamon 2020-05-28 12:29:45 +08:00
parent ec6a2cf037
commit cebec7b154
2 changed files with 19 additions and 19 deletions

View File

@ -1,4 +1,5 @@
{
"window.autoDetectColorScheme": false,
"editor.tabSize": 2,
"editor.semanticTokenColorCustomizations":{
"enabled": true, // enable semantic highlighting for all themes
@ -22,15 +23,15 @@
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#cfd3ef",
"activityBarBadge.foreground": "#15202b",
"titleBar.activeBackground": "#5e7959",
"titleBar.inactiveBackground": "#5e795999",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveForeground": "#e7e7e799",
"statusBarItem.hoverBackground": "#759570",
"statusBar.foreground": "#e7e7e7",
"activityBar.activeBackground": "#759570",
"statusBar.background": "#5e7959",
"statusBar.border": "#5e7959",
"titleBar.activeBackground": "#5e7959",
"titleBar.inactiveBackground": "#5e795999",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveForeground": "#e7e7e799",
"titleBar.border": "#5e7959"
},
"go.languageServerFlags": [],

View File

@ -82,33 +82,32 @@ func (rb *RequestBreaker) Do(work func(ctx context.Context) (interface{}, error)
//before
fmt.Println("before do : request:", rb.cnter.Total())
rb.mutex.Lock()
//handle status of Open to HalfOpen
if rb.state == StateOpen && rb.options.Expiry.Before(time.Now()) {
rb.state = StateHalfOpen
rb.cnter.Reset()
rb.options.OnStateChanged(rb.options.Name, StateOpen, StateHalfOpen)
}
rb.mutex.Unlock()
switch rb.state {
case StateOpen:
return nil, ErrTooManyRequests
case StateHalfOpen:
//do work from requested user
result, err := work(rb.options.Ctx)
if err != nil {
rb.cnter.Count(FailureState)
// result, err := work(rb.options.Ctx)
// if err != nil {
// rb.cnter.Count(FailureState)
// } else {
// rb.cnter.Count(SuccessState)
// return result, nil
// }
} else {
rb.cnter.Count(SuccessState)
return result, nil
if rb.options.Expiry.Before(time.Now()) {
rb.state = StateHalfOpen
rb.cnter.Reset()
rb.options.OnStateChanged(rb.options.Name, StateOpen, StateHalfOpen)
}
case StateClosed:
}
rb.mutex.Unlock()
//do work
//do work from requested user
result, err := work(rb.options.Ctx)