model

package
v1.10.6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows   = errors.New("record not found")
	ErrConflict = errors.New("record conflict")
)

Functions

func DeleteClient

func DeleteClient(id uint) error

func DeleteTask

func DeleteTask(id uint) error

func DeleteTaskByClientId added in v1.4.0

func DeleteTaskByClientId(clientId uint) error

func Init

func Init() error

func UpdateClientActive

func UpdateClientActive(id uint, active bool) error

func UpdateClientOffline added in v1.3.0

func UpdateClientOffline(id uint) error

func UpdateClientOnline

func UpdateClientOnline(client *Client) error

func UpdateTaskActive

func UpdateTaskActive(id uint, active bool) error

func UpdateTaskCompress added in v1.5.0

func UpdateTaskCompress(id uint, compress bool) error

func UpdateTaskTraffic added in v1.8.0

func UpdateTaskTraffic(id uint, in, out uint) error

func Wrap

func Wrap(err error) error

Types

type Client

type Client struct {
	Id     uint   `json:"id" gorm:"primaryKey,autoIncrement"`
	Name   string `json:"name"`
	Key    string `json:"key" gorm:"uniqueIndex"`
	Ver    string `json:"ver"`
	Active bool   `json:"active" gorm:"default:true"`
	Online bool   `json:"online"`

	Addr     string `json:"addr"`
	GO       string `json:"go"`
	OS       string `json:"os"`
	ARCH     string `json:"arch"`
	Hostname string `json:"hostname"`

	LastOnlineAt time.Time `json:"last_online_at"`

	CreateAt time.Time `json:"create_at" gorm:"autoCreateTime:milli"`
	UpdateAt time.Time `json:"update_at" gorm:"autoUpdateTime:milli"`
}

func CreateClient

func CreateClient(client *Client) (*Client, error)

func GetClientById

func GetClientById(id uint) (*Client, error)

func GetClientByKey

func GetClientByKey(key string) (*Client, error)

func ListClient

func ListClient() (clients []*Client, err error)

func UpdateClient

func UpdateClient(client *Client) (*Client, error)

type Size added in v1.9.1

type Size uint

func (Size) String added in v1.9.1

func (x Size) String() string

type Task

type Task struct {
	Id         uint   `json:"id" gorm:"primaryKey,autoIncrement"`
	ClientId   uint   `json:"client_id"`
	Name       string `json:"name"`
	Secret     string `json:"secret" gorm:"uniqueIndex"`
	Addr       string `json:"addr"`
	Active     bool   `json:"active" gorm:"default:true"`
	Compress   bool   `json:"compress"`
	TrafficIn  Size   `json:"traffic_in" gorm:"default:0"`
	TrafficOut Size   `json:"traffic_out" gorm:"default:0"`

	CreateAt time.Time `json:"create_at" gorm:"autoCreateTime:milli"`
	UpdateAt time.Time `json:"update_at" gorm:"autoUpdateTime:milli"`
}

func CreateTask

func CreateTask(task *Task) (*Task, error)

func GetTaskById

func GetTaskById(id uint) (*Task, error)

func GetTaskBySecret

func GetTaskBySecret(clientId uint, secret string) (*Task, error)

func ListTaskByClientId

func ListTaskByClientId(clientId uint) (tasks []*Task, err error)

func UpdateTask

func UpdateTask(task *Task) (*Task, error)

Jump to

Keyboard shortcuts

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