mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 10:06:14 +00:00
1) update master inteface of datanode enable qos 2) master clean client info if long time no report 3) enable qos online shutdown and startup 4) master set client alloc preriod and count of girds hit trigger condition 5) datanode qos limit value set by master and add disable conf and http interface 6) client qos init buffer calculate according on real buffer storage 7) create limiter for both hot and cold volume Signed-off-by: leonrayang <chl696@sina.com>
57 lines
901 B
Go
57 lines
901 B
Go
package util
|
|
|
|
type respErr struct {
|
|
errCh chan error
|
|
}
|
|
|
|
func (e *respErr) init() {
|
|
e.errCh = make(chan error, 1)
|
|
}
|
|
|
|
func (e *respErr) respond(err error) {
|
|
e.errCh <- err
|
|
close(e.errCh)
|
|
}
|
|
|
|
func (e *respErr) error() <-chan error {
|
|
return e.errCh
|
|
}
|
|
|
|
// Future the future
|
|
type Future struct {
|
|
respErr
|
|
respCh chan interface{}
|
|
}
|
|
|
|
func NewFuture() *Future {
|
|
f := &Future{
|
|
respCh: make(chan interface{}, 1),
|
|
}
|
|
f.init()
|
|
return f
|
|
}
|
|
|
|
func (f *Future) Respond(resp interface{}, err error) {
|
|
if err == nil {
|
|
f.respCh <- resp
|
|
close(f.respCh)
|
|
} else {
|
|
f.respErr.respond(err)
|
|
}
|
|
}
|
|
|
|
// Response wait response
|
|
func (f *Future) Response() (resp interface{}, err error) {
|
|
select {
|
|
case err = <-f.error():
|
|
return
|
|
case resp = <-f.respCh:
|
|
return
|
|
}
|
|
}
|
|
|
|
// AsyncResponse export channels
|
|
func (f *Future) AsyncResponse() (respCh <-chan interface{}, errCh <-chan error) {
|
|
return f.respCh, f.errCh
|
|
}
|