-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat]tools-v2: improve the snapshot tool
Signed-off-by: baytan0720 <[email protected]>
- Loading branch information
1 parent
e1aa430
commit 51b1936
Showing
8 changed files
with
229 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2023 NetEase Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* Project: CurveCli | ||
* Created Date: 2023-09-16 | ||
* Author: baytan0720 | ||
*/ | ||
|
||
package snapshot | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
) | ||
|
||
func NewQuerySubUri(params map[string]any) string { | ||
values := url.Values{} | ||
|
||
values.Add(QueryVersion, Version) | ||
for key, value := range params { | ||
if value != nil && value != "" { | ||
values.Add(key, fmt.Sprintf("%v", value)) | ||
} | ||
} | ||
|
||
return "/SnapshotCloneService?" + values.Encode() | ||
} | ||
|
||
type Response struct { | ||
Code string `json:"Code"` | ||
Message string `json:"Message"` | ||
RequestId string `json:"RequestId"` | ||
} | ||
|
||
type SnapshotInfo struct { | ||
File string `json:"File"` | ||
FileLength int `json:"FileLength"` | ||
Name string `json:"Name"` | ||
Progress float64 `json:"Progress"` | ||
SeqNum int `json:"SeqNum"` | ||
Status int `json:"status"` | ||
Time int64 `json:"Time"` | ||
UUID string `json:"UUID"` | ||
User string `json:"User"` | ||
} | ||
|
||
type SnapshotInfos []SnapshotInfo | ||
|
||
var SnapshotStatus = []string{"done", "in-progress", "deleting", "errorDeleting", "canceling", "error"} | ||
|
||
type TaskInfo struct { | ||
File string `json:"File"` | ||
FileType int `json:"FileType"` | ||
IsLazy bool `json:"IsLazy"` | ||
NextStep int `json:"NextStep"` | ||
Progress int `json:"Progress"` | ||
Src string `json:"Src"` | ||
TaskStatus int `json:"TaskStatus"` | ||
TaskType int `json:"TaskType"` | ||
Time int `json:"Time"` | ||
UUID string `json:"UUID"` | ||
User string `json:"User"` | ||
} | ||
|
||
type TaskInfos []TaskInfo | ||
|
||
var TaskStatus = []string{"Done", "Cloning", "Recovering", "Cleaning", "ErrorCleaning", "Error", "Retrying", "MetaInstalled"} | ||
var TaskType = []string{"clone", "recover"} | ||
var FileType = []string{"file", "snapshot"} | ||
var CloneStep = []string{"CreateCloneFile", "CreateCloneMeta", "CreateCloneChunk", "CompleteCloneMeta", "RecoverChunk", "ChangeOwner", "RenameCloneFile", "CompleteCloneFile", "End"} | ||
var IsLazy = []string{"false", "true"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.