data

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	// contains filtered or unexported fields
}

func InitData

func InitData(config *gorm.Config) (*Data, error)

func (*Data) CountLogsSize

func (d *Data) CountLogsSize() (int64, error)

func (*Data) CreateLog

func (d *Data) CreateLog(log *LogData) error

func (*Data) CreateLogGroup

func (d *Data) CreateLogGroup(groupLog *LogGroup) error

func (*Data) DeleteLogByFileId

func (d *Data) DeleteLogByFileId(fileId string) error

func (*Data) DeleteLogGroupByGroupId

func (d *Data) DeleteLogGroupByGroupId(groupId string) error

func (*Data) FindLogByFileId

func (d *Data) FindLogByFileId(FileId string) (*LogData, error)

func (*Data) FindLogGroup

func (d *Data) FindLogGroup(groupId string) (*LogGroup, error)

func (*Data) FindLogGroups

func (d *Data) FindLogGroups(query *FileListQuery) (*Page[*LogGroup], error)

func (*Data) FindLogs

func (d *Data) FindLogs(query *FileListQuery) (*Page[*LogData], error)

func (*Data) FindOldestLogs

func (d *Data) FindOldestLogs(size int) ([]*LogData, error)

func (*Data) FindShouldDeleteLogs

func (d *Data) FindShouldDeleteLogs(size int) ([]*LogData, error)

func (*Data) FindTimeoutLogs

func (d *Data) FindTimeoutLogs(before time.Time, size int) ([]*LogData, error)

func (*Data) UpdateLogGroup

func (d *Data) UpdateLogGroup(groupLog *LogGroup) error

func (*Data) UpdateLogStatus

func (d *Data) UpdateLogStatus(fileId string, status Status) error

type DataApi

type DataApi interface {
	CreateLogGroup(logGroup *LogGroup) error
	UpdateLogGroup(logGroup *LogGroup) error
	FindLogGroup(groupId string) (*LogGroup, error)
	FindLogGroups(query *FileListQuery) (*Page[*LogGroup], error)
	DeleteLogGroupByGroupId(groupId string) error

	CreateLog(log *LogData) error
	FindLogs(query *FileListQuery) (*Page[*LogData], error)
	UpdateLogStatus(fileId string, status Status) error
	DeleteLogByFileId(fileId string) error
	FindLogByFileId(fileId string) (*LogData, error)
	FindTimeoutLogs(before time.Time, size int) ([]*LogData, error)
	FindOldestLogs(size int) ([]*LogData, error)
	CountLogsSize() (int64, error)
}

func NewData

func NewData(config *config.Config, taskManager *task.TaskManager, storage storage.StorageApi) (DataApi, error)

type FileListQuery

type FileListQuery struct {
	PageQuery
	From *int64
	To   *int64
	Tags []*storage.Tag
}

func (*FileListQuery) GetFrom

func (f *FileListQuery) GetFrom() *time.Time

func (*FileListQuery) GetTo

func (f *FileListQuery) GetTo() *time.Time

type LogData

type LogData struct {
	Model
	Status     Status `json:"status"`
	Size       int64  `json:"size"`
	FileId     string `gorm:"index:unique" json:"fileId"`
	LogGroupID uint   `json:"-"`
	Tags       []*Tag `gorm:"many2many:log_tags;" json:"tags"`
	Name       string `json:"name"`
}

type LogGroup

type LogGroup struct {
	Model
	GroupId string     `json:"groupId"`
	Tags    []*Tag     `gorm:"many2many:log_group_tags;" json:"tags"`
	Size    int64      `json:"size"`
	Logs    []*LogData `gorm:"foreignKey:LogGroupID" json:"logs"`
	Name    string     `json:"name"`
}

type Model

type Model struct {
	ID        uint           `gorm:"primarykey" json:"-"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

func (*Model) GetOrderValue

func (m *Model) GetOrderValue() float64

type OrderData

type OrderData interface {
	GetOrderValue() float64
}

type Page

type Page[T OrderData] struct {
	Total int64 `json:"total"`
	Data  []T   `json:"data"`
}

func (*Page[T]) Desc

func (p *Page[T]) Desc()

func (*Page[T]) Merge

func (p *Page[T]) Merge(result rpc.MergeResult) error

func (*Page[T]) New

func (p *Page[T]) New() rpc.MergeResult

type PageQuery

type PageQuery struct {
	Size int
	Page int
}

func (*PageQuery) GetOffset

func (p *PageQuery) GetOffset() int

type Status

type Status string
const (
	Error   Status = "Error"
	Created Status = "Created"
	Saved   Status = "Saved"
	Unknown Status = "Unknown"
)

type Sum

type Sum struct {
	Total int64
}

type Tag

type Tag struct {
	Model
	Key   string `json:"key"`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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