fault

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionFollow   = "FOLLOW"   // follow the fault
	ActionUnfollow = "UNFOLLOW" // unfollow the fault
)
View Source
const (
	StateUnprocessing = "UNPROCESSING" // state of fault
	StateProcessing   = "PROCESSING"   // state of fault
	StateClosed       = "CLOSED"       // state of fault
	StateDiscarded    = "DISCARDED"    // state of fault
)

Variables

This section is empty.

Functions

func EventTimeInfo

func EventTimeInfo(eventInfos []event.EventInfo) (firstTime, lastTime string)

func Init

func Init()

func SQLBuilder

func SQLBuilder(filter Filter) string

Types

type CommentInfo

type CommentInfo struct {
	CreatedAt time.Time
	Creator   string
	Comment   string
}

type CreateInfo

type CreateInfo struct {
	Title   string   `json:"title" form:"title" binding:"required"`
	Note    string   `json:"note" form:"note"`
	Creator string   `json:"creator" form:"creator"`
	Owner   string   `json:"owner" form:"owner" binding:"required"`
	Tags    []string `json:"tags" form:"tags"`
}

type Fault

type Fault struct {
	gorm.Model
	Title   string
	Note    string
	Creator string
	Owner   string
	State   string
}

func (Fault) TableName

func (Fault) TableName() string

type FaultComment

type FaultComment struct {
	gorm.Model
	FaultId uint
	Creator string
	Comment string `gorm:"size:999"`
}

func (FaultComment) TableName

func (FaultComment) TableName() string

type FaultEvent

type FaultEvent struct {
	gorm.Model
	FaultId uint `gorm:"unique_index:idx_faultid_eventid"`
	EventId uint `gorm:"unique_index:idx_faultid_eventid"`
}

func (FaultEvent) TableName

func (FaultEvent) TableName() string

type FaultFollower

type FaultFollower struct {
	gorm.Model
	FaultId  uint   `gorm:"unique_index:idx_faultid_follower"`
	Follower string `gorm:"unique_index:idx_faultid_follower"`
}

func (FaultFollower) TableName

func (FaultFollower) TableName() string

type FaultInfo

type FaultInfo struct {
	Id        uint
	CreatedAt time.Time
	Title     string
	Note      string
	Creator   string
	Owner     string
	State     string
	Tags      []string
	Events    []event.EventInfo
	Followers []string
	Comments  []CommentInfo
}

type FaultStore

type FaultStore struct {
	AMDB   *gorm.DB
	Locker *sync.RWMutex
}
var Store *FaultStore

Store contains db connection info of alarm-manager. See Init.

func NewFaultStore

func NewFaultStore(db *gorm.DB) *FaultStore

func (*FaultStore) AddComment

func (fs *FaultStore) AddComment(faultid uint, creator, comment string) (
	FaultInfo, error)

func (*FaultStore) AddEvent

func (fs *FaultStore) AddEvent(faultid uint, eventids []uint) (FaultInfo, error)

func (*FaultStore) AddTag

func (fs *FaultStore) AddTag(faultid uint, tags []string) (FaultInfo, error)

func (*FaultStore) Create

func (fs *FaultStore) Create(createInfo CreateInfo) (FaultInfo, error)

func (*FaultStore) DeleteComment

func (fs *FaultStore) DeleteComment(faultid uint, creator, comment string) (FaultInfo, error)

func (*FaultStore) DeleteEvent

func (fs *FaultStore) DeleteEvent(faultid uint, eventids []uint) (
	FaultInfo, error)

func (*FaultStore) DeleteTag

func (fs *FaultStore) DeleteTag(faultid uint, tags []string) (
	FaultInfo, error)

func (*FaultStore) FaultTimeInfo

func (fs *FaultStore) FaultTimeInfo(faultid uint) (
	createdAt, closedAt time.Time, err error)

func (*FaultStore) Get

func (fs *FaultStore) Get(id uint) (FaultInfo, error)

func (*FaultStore) GetComment

func (fs *FaultStore) GetComment(faultid uint) ([]CommentInfo, error)

func (*FaultStore) GetEvent

func (fs *FaultStore) GetEvent(faultid uint) ([]event.EventInfo, error)

func (*FaultStore) GetFaultBasic

func (fs *FaultStore) GetFaultBasic(faultid uint) (Fault, error)

func (*FaultStore) GetFaultFollower

func (fs *FaultStore) GetFaultFollower(faultid uint) ([]string, error)

func (*FaultStore) GetTag

func (fs *FaultStore) GetTag(faultid uint) ([]string, error)

func (*FaultStore) GetTimeLine

func (fs *FaultStore) GetTimeLine(faultid uint) (TimeLine, error)

TODO: enrich the timeline of fault.

func (*FaultStore) List

func (fs *FaultStore) List(filter Filter) ([]FaultInfo, uint, error)

func (*FaultStore) UpdateBasic

func (fs *FaultStore) UpdateBasic(faultid uint, title, note string) (
	FaultInfo, error)

func (*FaultStore) UpdateFollower

func (fs *FaultStore) UpdateFollower(faultid uint, follower []string,
	action string) (FaultInfo, error)

func (*FaultStore) UpdateOwner

func (fs *FaultStore) UpdateOwner(faultid uint, newOwner string) (
	FaultInfo, error)

func (*FaultStore) UpdateState

func (fs *FaultStore) UpdateState(faultid uint, newState string) (FaultInfo, error)

type FaultTag

type FaultTag struct {
	gorm.Model
	FaultId uint   `gorm:"unique_index:idx_faultid_tag"`
	Tag     string `gorm:"unique_index:idx_faultid_tag"`
}

func (FaultTag) TableName

func (FaultTag) TableName() string

type Filter

type Filter struct {
	Start    uint
	End      uint
	Creator  string
	Owner    string
	State    string
	Title    string
	Follower string
	Tag      string
	Limit    uint
	Offset   uint
}

type StateChangeLog

type StateChangeLog struct {
	gorm.Model
	ReferTable string
	ReferId    uint
	ReferField string
	From       string
	To         string
}

func (StateChangeLog) TableName

func (StateChangeLog) TableName() string

type TimeLine

type TimeLine struct {
	FirstEventTime string
	LastEventTime  string
	FaultCreatedAt time.Time
	FaultClosedAt  time.Time
}

Jump to

Keyboard shortcuts

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