model

package
v0.0.0-...-67ae82b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2016 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const SCHEMA_VERSION string = "0.0.1"

Variables

This section is empty.

Functions

func IsIntegrityConstraintViolation

func IsIntegrityConstraintViolation(err error) bool

func NullInt

func NullInt() sql.NullInt64

func NullIntToPtr

func NullIntToPtr(nullint sql.NullInt64) *int64

func NullIntValue

func NullIntValue(value int64) sql.NullInt64

func PtrToNullInt

func PtrToNullInt(value *int64) sql.NullInt64

Types

type ConnectionStatus

type ConnectionStatus struct {
	Unreachable        bool
	Slave              Slave
	CommunicationError msp.Error // Only valid if Unreachable=true
}

type DB

type DB struct {
	Driver string
	// contains filtered or unexported fields
}

func InitializeDB

func InitializeDB(driver, dsn string) (*DB, error)

func InitializeTestDB

func InitializeTestDB() (db *DB, dsn string, err error)

func InitializeTestDBFromFile

func InitializeTestDBFromFile(file string) (db *DB, dsn string, err error)

func (*DB) Begin

func (db *DB) Begin() *gorm.DB

func (*DB) CloseAndDrop

func (db *DB) CloseAndDrop()

type DesiredReplicaSetConstraintStatus

type DesiredReplicaSetConstraintStatus struct {
	Unsatisfied               bool
	ReplicaSet                ReplicaSet
	ConfiguredVolatileCount   uint
	ConfiguredPersistentCount uint
}

type MSPError

type MSPError struct {
	ID              int64 `gorm:"primary_key"`
	Identifier      string
	Description     string
	LongDescription string
}

msp.Error duplicated for decoupling protocol & internal representation

type MamidMetadata

type MamidMetadata struct {
	Key, Value string
}

type Mongod

type Mongod struct {
	// TODO missing UNIQUE constraint
	ID          int64 `gorm:"primary_key"`
	Port        PortNumber
	ReplSetName string

	ObservationError   MSPError
	ObservationErrorID sql.NullInt64 `sql:"type:integer NULL REFERENCES msp_errors(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED"` // TODO not cleaned up on Mongod deletion right now

	LastEstablishStateError   MSPError
	LastEstablishStateErrorID sql.NullInt64 `sql:"type:integer NULL REFERENCES msp_errors(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED"` // TODO not cleaned up on Mongod deletion right now

	ParentSlave   *Slave
	ParentSlaveID int64 `sql:"type:integer REFERENCES slaves(id) DEFERRABLE INITIALLY DEFERRED"`

	ReplicaSet   *ReplicaSet
	ReplicaSetID sql.NullInt64 `sql:"type:integer NULL REFERENCES replica_sets(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED"`

	DesiredState   MongodState
	DesiredStateID int64 `sql:"type:integer NOT NULL REFERENCES mongod_states(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"` // NOTE: we cascade on delete because Monogd cannot be without DesiredState

	ObservedState   MongodState
	ObservedStateID sql.NullInt64 `sql:"type:integer NULL REFERENCES mongod_states(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED"`
}

type MongodExecutionState

type MongodExecutionState uint
const (
	MongodExecutionStateForceDestroyed MongodExecutionState = iota
	MongodExecutionStateDestroyed
	MongodExecutionStateNotRunning
	MongodExecutionStateUninitiated
	MongodExecutionStateRecovering // invalid for a desired MongodState
	MongodExecutionStateRunning
)

type MongodKeyfile

type MongodKeyfile struct {
	ID      int64 `gorm:"primary_key"`
	Content string
}

type MongodMatchStatus

type MongodMatchStatus struct {
	Mismatch bool
	Mongod   Mongod
}

type MongodState

type MongodState struct {
	ID             int64 `gorm:"primary_key"`
	ParentMongod   *Mongod
	ParentMongodID int64 `sql:"type:integer NOT NULL REFERENCES mongods(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"`
	ShardingRole   ShardingRole
	ExecutionState MongodExecutionState
}

type MongodbCredential

type MongodbCredential struct {
	ID       int64 `gorm:"primary_key"`
	Username string
	Password string
}

type ObservedReplicaSetConstraintStatus

type ObservedReplicaSetConstraintStatus struct {
	Unsatisfied               bool
	ReplicaSet                ReplicaSet
	ConfiguredVolatileCount   uint
	ConfiguredPersistentCount uint
	ActualVolatileCount       uint
	ActualPersistentCount     uint
}

type PortNumber

type PortNumber uint16
const (
	PortNumberMin PortNumber = 1
	PortNumberMax            = 65535
)

type Problem

type Problem struct {
	ID              int64 `gorm:"primary_key"`
	Description     string
	LongDescription string
	ProblemType     ProblemType
	FirstOccurred   time.Time
	LastUpdated     time.Time

	Slave   *Slave
	SlaveID sql.NullInt64 `sql:"type:integer NULL REFERENCES slaves(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"`

	ReplicaSet   *ReplicaSet
	ReplicaSetID sql.NullInt64 `sql:"type:integer NULL REFERENCES replica_sets(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"`

	Mongod   *Mongod
	MongodID sql.NullInt64 `sql:"type:integer NULL REFERENCES mongods(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"`
}

type ProblemType

type ProblemType uint
const (
	ProblemTypeConnection ProblemType = iota
	ProblemTypeMismatch
	ProblemTypeDesiredReplicaSetConstraint
	ProblemTypeObservedReplicaSetConstraint
)

type ReplicaSet

type ReplicaSet struct {
	ID                    int64  `gorm:"primary_key"` //TODO needs to start incrementing at 1
	Name                  string `gorm:"unique_index"`
	PersistentMemberCount uint
	VolatileMemberCount   uint
	ShardingRole          ShardingRole
	Initiated             bool
	Mongods               []*Mongod

	Problems []*Problem
}

type ReplicaSetInitiationStatus

type ReplicaSetInitiationStatus struct {
	Initiated  bool
	ReplicaSet ReplicaSet
}

type RiskGroup

type RiskGroup struct {
	ID     int64  `gorm:"primary_key"` //TODO needs to start incrementing at 1, 0 is special value for slaves "out of risk" => define a constant?
	Name   string `gorm:"unique_index"`
	Slaves []*Slave
}

type ShardingRole

type ShardingRole string
const (
	ShardingRoleNone         ShardingRole = "none"
	ShardingRoleShardServer  ShardingRole = "shardsvr"
	ShardingRoleConfigServer ShardingRole = "configsvr"
)

func (ShardingRole) Value

func (s ShardingRole) Value() (driver.Value, error)

type Slave

type Slave struct {
	ID                   int64  `gorm:"primary_key"`
	Hostname             string `gorm:"unique_index"`
	Port                 PortNumber
	MongodPortRangeBegin PortNumber
	MongodPortRangeEnd   PortNumber
	PersistentStorage    bool
	Mongods              []*Mongod `gorm:"ForeignKey:ParentSlaveID"`
	ConfiguredState      SlaveState

	Problems []*Problem

	// Foreign keys
	RiskGroupID sql.NullInt64 `sql:"type:integer NULL REFERENCES risk_groups(id) DEFERRABLE INITIALLY DEFERRED"`

	ObservationError   *MSPError     // error in observation that is not tied to a specific Mongod
	ObservationErrorID sql.NullInt64 `sql:"type:integer NULL REFERENCES msp_errors(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED"` // TODO not cleaned up on slave deletion right now
}

type SlaveState

type SlaveState uint
const (
	SlaveStateActive SlaveState = iota
	SlaveStateMaintenance
	SlaveStateDisabled
)

type StatusMessage

type StatusMessage interface {
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL