-
Notifications
You must be signed in to change notification settings - Fork 767
/
defs.go
107 lines (91 loc) · 4.07 KB
/
defs.go
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package cli
import (
"os"
"time"
"github.com/fatih/color"
"github.com/olekukonko/tablewriter"
s "go.uber.org/cadence/.gen/go/shared"
)
const (
localHostPort = "127.0.0.1:7933"
maxOutputStringLength = 200 // max length for output string
maxWorkflowTypeLength = 32 // max item length for output workflow type in table
defaultMaxFieldLength = 500 // default max length for each attribute field
maxWordLength = 120 // if text length is larger than maxWordLength, it will be inserted spaces
defaultTimeFormat = "15:04:05" // used for converting UnixNano to string like 16:16:36 (only time)
defaultDateTimeFormat = time.RFC3339 // used for converting UnixNano to string like 2018-02-15T16:16:36-08:00
defaultDomainRetentionDays = 3
defaultContextTimeoutInSeconds = 5
defaultContextTimeout = defaultContextTimeoutInSeconds * time.Second
defaultContextTimeoutForLongPoll = 2 * time.Minute
defaultDecisionTimeoutInSeconds = 10
defaultPageSizeForList = 500
defaultWorkflowIDReusePolicy = s.WorkflowIdReusePolicyAllowDuplicateFailedOnly
workflowStatusNotSet = -1
showErrorStackEnv = `CADENCE_CLI_SHOW_STACKS`
searchAttrInputSeparator = "|"
)
var envKeysForUserName = []string{
"USER",
"LOGNAME",
"HOME",
}
var resetTypesMap = map[string]string{
"FirstDecisionCompleted": "",
"LastDecisionCompleted": "",
"LastContinuedAsNew": "",
"BadBinary": FlagResetBadBinaryChecksum,
}
type jsonType int
const (
jsonTypeInput jsonType = iota
jsonTypeMemo
)
var (
cFactory ClientFactory
colorRed = color.New(color.FgRed).SprintFunc()
colorMagenta = color.New(color.FgMagenta).SprintFunc()
colorGreen = color.New(color.FgGreen).SprintFunc()
tableHeaderBlue = tablewriter.Colors{tablewriter.FgHiBlueColor}
optionErr = "there is something wrong with your command options"
osExit = os.Exit
workflowClosedStatusMap = map[string]s.WorkflowExecutionCloseStatus{
"completed": s.WorkflowExecutionCloseStatusCompleted,
"failed": s.WorkflowExecutionCloseStatusFailed,
"canceled": s.WorkflowExecutionCloseStatusCanceled,
"terminated": s.WorkflowExecutionCloseStatusTerminated,
"continuedasnew": s.WorkflowExecutionCloseStatusContinuedAsNew,
"continueasnew": s.WorkflowExecutionCloseStatusContinuedAsNew,
"timedout": s.WorkflowExecutionCloseStatusTimedOut,
// below are some alias
"c": s.WorkflowExecutionCloseStatusCompleted,
"complete": s.WorkflowExecutionCloseStatusCompleted,
"f": s.WorkflowExecutionCloseStatusFailed,
"fail": s.WorkflowExecutionCloseStatusFailed,
"cancel": s.WorkflowExecutionCloseStatusCanceled,
"terminate": s.WorkflowExecutionCloseStatusTerminated,
"term": s.WorkflowExecutionCloseStatusTerminated,
"continue": s.WorkflowExecutionCloseStatusContinuedAsNew,
"cont": s.WorkflowExecutionCloseStatusContinuedAsNew,
"timeout": s.WorkflowExecutionCloseStatusTimedOut,
}
)