-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathhandler.go
More file actions
85 lines (70 loc) · 1.97 KB
/
handler.go
File metadata and controls
85 lines (70 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Radon
*
* Copyright 2018-2020 The Radon Authors.
* Code is licensed under the GPLv3.
*
*/
package shiftmanager
import (
"github.com/radondb/shift/shift"
"github.com/xelabs/go-mysqlstack/sqlparser/depends/sqltypes"
)
// ShiftStatus used to indicates shift instance's status.
type ShiftStatus int
const (
// ShiftStatusNone enum, if status is none, some errors happen
ShiftStatusNone ShiftStatus = iota
// ShiftStatusMigrating enum
ShiftStatusMigrating
// ShiftStatusSuccess enum
ShiftStatusSuccess
// ShiftStatusFail enum
ShiftStatusFail
)
// ShiftType is used to distinguish what different type of shift
// If it is called by reshard, the type will be ShiftTypeReshard
// If it is called by rebalance, the type will be ShiftTypeRebalance
type ShiftType int
const (
// ShiftTypeNone enum, a shift type should not be none
ShiftTypeNone ShiftType = iota
// ShiftTypeReshard enum
ShiftTypeReshard
// ShiftTypeRebalance enum
ShiftTypeRebalance
)
// ShiftInfo used to record basic infos used by shift
type ShiftInfo struct {
From string
FromUser string
FromPassword string
FromDatabase string
FromTable string
To string
ToUser string
ToPassword string
ToDatabase string
ToTable string
Rebalance bool
Cleanup bool // if Cleanup is true, drop the FromTable.
Checksum bool
MysqlDump string
Threads int
PosBehinds int
WaitTimeBeforeChecksum int
RadonURL string
}
type ShiftMgrHandler interface {
Init() error
NewShiftInstance(shiftInfo *ShiftInfo, typ ShiftType) (shift.ShiftHandler, error)
StartShiftInstance(key string, shift shift.ShiftHandler, typ ShiftType) error
WaitInstanceFinishThread(key string) error
WaitInstanceFinish(key string) error
StopOneInstance(key string) error
StopAllInstance() error
GetStatus(key string) ShiftStatus
GetProgress(key string) *sqltypes.Result
GetShiftType(key string) ShiftType
Close() error
}