重构通道管理逻辑,支持通过任务删除不同类型通道;引入 Asynq 处理异步任务;更新数据库结构以支持通道类型区分
This commit is contained in:
@@ -121,11 +121,17 @@ func (r *resource) fillFieldMap() {
|
||||
|
||||
func (r resource) clone(db *gorm.DB) resource {
|
||||
r.resourceDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
r.Short.db = db.Session(&gorm.Session{Initialized: true})
|
||||
r.Short.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
r.Long.db = db.Session(&gorm.Session{Initialized: true})
|
||||
r.Long.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return r
|
||||
}
|
||||
|
||||
func (r resource) replaceDB(db *gorm.DB) resource {
|
||||
r.resourceDo.ReplaceDB(db)
|
||||
r.Short.db = db.Session(&gorm.Session{})
|
||||
r.Long.db = db.Session(&gorm.Session{})
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -162,6 +168,11 @@ func (a resourceHasOneShort) Model(m *models.Resource) *resourceHasOneShortTx {
|
||||
return &resourceHasOneShortTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a resourceHasOneShort) Unscoped() *resourceHasOneShort {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type resourceHasOneShortTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a resourceHasOneShortTx) Find() (result *models.ResourceShort, err error) {
|
||||
@@ -200,6 +211,11 @@ func (a resourceHasOneShortTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a resourceHasOneShortTx) Unscoped() *resourceHasOneShortTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type resourceHasOneLong struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -233,6 +249,11 @@ func (a resourceHasOneLong) Model(m *models.Resource) *resourceHasOneLongTx {
|
||||
return &resourceHasOneLongTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a resourceHasOneLong) Unscoped() *resourceHasOneLong {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type resourceHasOneLongTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a resourceHasOneLongTx) Find() (result *models.ResourceLong, err error) {
|
||||
@@ -271,6 +292,11 @@ func (a resourceHasOneLongTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a resourceHasOneLongTx) Unscoped() *resourceHasOneLongTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type resourceDo struct{ gen.DO }
|
||||
|
||||
func (r resourceDo) Debug() *resourceDo {
|
||||
|
||||
Reference in New Issue
Block a user