feat: 实现配置校验与运维命令及优雅停机
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Ready 检查读写库可用且写入队列未因磁盘类失败进入 busy。
|
||||
func (d *DB) Ready(ctx context.Context) error {
|
||||
if d == nil || d.Write == nil || d.Read == nil {
|
||||
return errors.New("store: not open")
|
||||
}
|
||||
if err := d.Write.PingContext(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Read.PingContext(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if d.Queue != nil && !d.Queue.IsReady() {
|
||||
if err := d.Queue.LastWriteError(); err != nil {
|
||||
return errors.Join(ErrBusy, err)
|
||||
}
|
||||
return ErrBusy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user