2020-05-26 14:46:16 +00:00
|
|
|
package spooler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
es_locker "github.com/caos/zitadel/internal/eventstore/locker"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-07-07 14:53:54 +00:00
|
|
|
lockTable = "adminapi.locks"
|
2020-05-26 14:46:16 +00:00
|
|
|
lockedUntilKey = "locked_until"
|
|
|
|
lockerIDKey = "locker_id"
|
|
|
|
objectTypeKey = "object_type"
|
|
|
|
)
|
|
|
|
|
|
|
|
type locker struct {
|
|
|
|
dbClient *sql.DB
|
|
|
|
}
|
|
|
|
|
|
|
|
type lock struct {
|
|
|
|
LockerID string `gorm:"column:locker_id;primary_key"`
|
|
|
|
LockedUntil time.Time `gorm:"column:locked_until"`
|
|
|
|
ViewName string `gorm:"column:object_type;primary_key"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *locker) Renew(lockerID, viewModel string, waitTime time.Duration) error {
|
|
|
|
return es_locker.Renew(l.dbClient, lockTable, lockerID, viewModel, waitTime)
|
|
|
|
}
|