utils

package
v2.2.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: AGPL-3.0 Imports: 22 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Backgrounds = sync.Map{} //后台导入导出任务

Backgrounds 后台任务集合(包含SQL导入和导出任务)

View Source
var Charsets = []string{"armscii8", "ascii", "big5", "binary", "cp1250", "cp1251", "cp1256", "cp1257", "cp850", "cp852", "cp866", "cp932", "dec8", "eucjpms", "euckr", "gb18030", "gb2312", "gbk", "geostd8", "greek", "hebrew", "hp8", "keybcs2", "koi8r", "koi8u", "latin1", "latin2", "latin5", "latin7", "macce", "macroman", "sjis", "swe7", "tis620", "ucs2", "ujis", "utf16", "utf16le", "utf32", "utf8", "utf8mb4"}

Charsets MySQL 支持的字符集

Functions

func All

func All() map[OP]Exec

All 所有任务

func Cancel

func Cancel(op OP, cacheKey string) error

Cancel 取消执行

func Export

func Export(ctx context.Context, cfg *driver.DbAuth, tables []string, structWriter, dataWriter interface{}, resetAutoIncrements ...bool) error

Export 导出SQL文件

func Import

func Import(ctx context.Context, cfg *driver.DbAuth, cacheDir string, files []string, asyncs ...bool) error

Import 导入SQL文件

func ResetAutoIncrement

func ResetAutoIncrement(sqlStructFile string) error

ResetAutoIncrement 重置AUTO_INCREMENT值为0

Types

type BGExec

type BGExec struct {
	Options echo.H
	Started time.Time
	Procs   *FileInfos
	// contains filtered or unexported fields
}

BGExec 后台执行信息

func NewGBExec

func NewGBExec(c context.Context, opt echo.H) *BGExec

NewGBExec 新建后台执行信息

func (*BGExec) AddFileInfo

func (b *BGExec) AddFileInfo(fi *FileInfo)

AddFileInfo 添加文件信息

func (*BGExec) Cancel

func (b *BGExec) Cancel() context.CancelFunc

Cancel 取消执行

func (*BGExec) Context

func (b *BGExec) Context() context.Context

Context 暂存上下文信息

type Exec

type Exec map[string]*BGExec

Exec 执行信息

func ListBy

func ListBy(op OP) Exec

ListBy 获取某个操作的所有任务

func (*Exec) Add

func (e *Exec) Add(op OP, cacheKey string, bgExec *BGExec)

Add 新增任务

func (*Exec) Cancel

func (e *Exec) Cancel(cacheKey string)

Cancel 取消某个任务

func (*Exec) Exists

func (e *Exec) Exists(cacheKey string) bool

Exists 任务是否存在

type FileInfo

type FileInfo struct {
	Start      time.Time
	End        time.Time
	Elapsed    time.Duration
	Path       string
	Size       int64
	Compressed bool
	Error      string
}

FileInfo 文件信息

type FileInfos

type FileInfos []*FileInfo

FileInfos 文件信息集合

type OP

type OP string

OP 操作类型

const (
	// OpExport 导出操作
	OpExport OP = `export`
	// OpImport 导入操作
	OpImport OP = `import`
)

func (OP) String

func (t OP) String() string

Jump to

Keyboard shortcuts

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