working commit
This commit is contained in:
+18
-18
@@ -8,54 +8,54 @@ import (
|
||||
"mbase/pkg/logger"
|
||||
)
|
||||
|
||||
type LogicConfig struct {
|
||||
type OperatorConfig struct {
|
||||
Database *maindb.Database
|
||||
}
|
||||
|
||||
type Logic struct {
|
||||
type Operator struct {
|
||||
log *logger.Logger
|
||||
db *maindb.Database
|
||||
dumpingSem atomic.Bool
|
||||
restoringSem atomic.Bool
|
||||
}
|
||||
|
||||
func NewLogic(conf *LogicConfig) (*Logic, error) {
|
||||
func NewOperator(conf *OperatorConfig) (*Operator, error) {
|
||||
var err error
|
||||
lg := &Logic{
|
||||
oper := &Operator{
|
||||
db: conf.Database,
|
||||
}
|
||||
lg.log = logger.NewLogger("logic")
|
||||
return lg, err
|
||||
oper.log = logger.NewLogger("Operator")
|
||||
return oper, err
|
||||
}
|
||||
|
||||
func (lg *Logic) DumpingSemUp() {
|
||||
lg.dumpingSem.Store(true)
|
||||
func (oper *Operator) DumpingSemUp() {
|
||||
oper.dumpingSem.Store(true)
|
||||
}
|
||||
|
||||
func (lg *Logic) DumpingSemDown() {
|
||||
lg.dumpingSem.Store(false)
|
||||
func (oper *Operator) DumpingSemDown() {
|
||||
oper.dumpingSem.Store(false)
|
||||
}
|
||||
|
||||
func (lg *Logic) WaitDumping() {
|
||||
func (oper *Operator) WaitDumping() {
|
||||
for {
|
||||
if !lg.dumpingSem.Load() {
|
||||
if !oper.dumpingSem.Load() {
|
||||
return
|
||||
}
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func (lg *Logic) RestoringSemUp() {
|
||||
lg.restoringSem.Store(true)
|
||||
func (oper *Operator) RestoringSemUp() {
|
||||
oper.restoringSem.Store(true)
|
||||
}
|
||||
|
||||
func (lg *Logic) RestoringSemDown() {
|
||||
lg.restoringSem.Store(false)
|
||||
func (oper *Operator) RestoringSemDown() {
|
||||
oper.restoringSem.Store(false)
|
||||
}
|
||||
|
||||
func (lg *Logic) WaitRestoring() {
|
||||
func (oper *Operator) WaitRestoring() {
|
||||
for {
|
||||
if !lg.restoringSem.Load() {
|
||||
if !oper.restoringSem.Load() {
|
||||
return
|
||||
}
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
|
||||
Reference in New Issue
Block a user