trans_base.go 490 B

1234567891011121314151617181920
  1. package database
  2. // 未保证线程同步,当数据库操作需要输出的时候,对应的transaction需要继承ITransaction及trans_base
  3. // 对应的DoAction也通过channel异步返回
  4. // 如果该数据库操作无须返回,则不需要继承
  5. type ITransaction interface {
  6. OnRet()
  7. DoAction(ch chan<- interface{})
  8. }
  9. type Trans_base struct {
  10. RetFunc func(state bool)
  11. State bool
  12. }
  13. func (this *Trans_base) OnRet() {
  14. if this.RetFunc != nil {
  15. this.RetFunc(this.State)
  16. }
  17. }