Documentation
¶
Index ¶
- func BSONSingleFieldIndexKeyEquals(key bson.D, field string, direction int32) bool
- func DefaultOwnerID(hostname string) string
- func IsMongoDuplicateKeyError(err error) bool
- func TargetVersion(list []Migration) int64
- type LockAcquireInfo
- type Locker
- type Manager
- type ManagerConfig
- type Migration
- type MongoIndexInfo
- type MongoIndexState
- type MongoUniqueStringFieldDiagnostics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BSONSingleFieldIndexKeyEquals ¶ added in v0.1.7
func DefaultOwnerID ¶
func IsMongoDuplicateKeyError ¶ added in v0.1.7
func TargetVersion ¶
Types ¶
type LockAcquireInfo ¶ added in v0.1.8
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
func (*Locker) TryAcquireWithInfo ¶ added in v0.1.8
func (l *Locker) TryAcquireWithInfo(ctx context.Context) (LockAcquireInfo, error)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(db *mongo.Database, owner string, cfg ManagerConfig) *Manager
type ManagerConfig ¶ added in v0.1.7
type ManagerConfig struct {
LockKey string // e.g. identityservice:migrations
LeaseFor time.Duration
PollInterval time.Duration
OpTimeout time.Duration // OpTimeout (locks, reads/writes)
MigrationTimeout time.Duration // MigrationTimeout (long-running migrations)
Logger *logrus.Entry
FailFast bool // true — Run error
WaitForLeader bool // true — not ready, while leader not accept target
}
type Migration ¶
type Migration struct {
Version int64
Name string
Up func(ctx context.Context, db *mongo.Database) error
}
func ValidateAndSort ¶
type MongoIndexInfo ¶ added in v0.1.7
type MongoIndexInfo struct {
Name string `bson:"name"`
Key bson.D `bson:"key"`
Unique bool `bson:"unique,omitempty"`
}
func ListMongoIndexes ¶ added in v0.1.7
func ListMongoIndexes(ctx context.Context, col *mongo.Collection) ([]MongoIndexInfo, error)
type MongoIndexState ¶ added in v0.1.7
type MongoIndexState int
const ( MongoIndexAbsent MongoIndexState = iota MongoIndexUnique MongoIndexNonUnique )
func MongoSingleFieldIndexState ¶ added in v0.1.7
func MongoSingleFieldIndexState(indexes []MongoIndexInfo, field string, direction int32, desiredName string) (state MongoIndexState, existingName string, err error)
MongoSingleFieldIndexState: index with other desiredName, but other key-spec -> error, if exists by {field: direction}:
- unique -> MongoIndexUnique
- not unique -> MongoIndexNonUnique
type MongoUniqueStringFieldDiagnostics ¶ added in v0.1.7
func DiagnoseMongoUniqueStringField ¶ added in v0.1.7
func DiagnoseMongoUniqueStringField(ctx context.Context, col *mongo.Collection, field string, limit int) (MongoUniqueStringFieldDiagnostics, error)
DiagnoseMongoUniqueStringField:
- field duplicates (limit)
- documents with field=null
Click to show internal directories.
Click to hide internal directories.