-
Notifications
You must be signed in to change notification settings - Fork 0
/
enums.go
282 lines (230 loc) · 8.69 KB
/
enums.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
package pubnub
// StatusCategory is used as an enum to catgorize the various status events
// in the APIs lifecycle
type StatusCategory int
// OperationType is used as an enum to catgorize the various operations
// in the APIs lifecycle
type OperationType int
// ReconnectionPolicy is used as an enum to catgorize the reconnection policies
type ReconnectionPolicy int
// PNPushType is used as an enum to catgorize the available Push Types
type PNPushType int
const (
// PNNonePolicy is to be used when selecting the no Reconnection Policy
// ReconnectionPolicy is set in the config.
PNNonePolicy ReconnectionPolicy = 1 + iota
// PNLinearPolicy is to be used when selecting the Linear Reconnection Policy
// ReconnectionPolicy is set in the config.
PNLinearPolicy
// PNExponentialPolicy is to be used when selecting the Exponential Reconnection Policy
// ReconnectionPolicy is set in the config.
PNExponentialPolicy
)
const (
// PNUnknownCategory as the StatusCategory means an unknown status category event occurred.
PNUnknownCategory StatusCategory = 1 + iota
// PNTimeoutCategory as the StatusCategory means the request timeout has reached.
PNTimeoutCategory
// PNConnectedCategory as the StatusCategory means the channel is subscribed to receive messages.
PNConnectedCategory
// PNDisconnectedCategory as the StatusCategory means a disconnection occurred due to network issues.
PNDisconnectedCategory
// PNCancelledCategory as the StatusCategory means the context was cancelled.
PNCancelledCategory
// PNLoopStopCategory as the StatusCategory means the subscribe loop was stopped.
PNLoopStopCategory
// PNAcknowledgmentCategory as the StatusCategory is the Acknowledgement of an operation (like Unsubscribe).
PNAcknowledgmentCategory
// PNBadRequestCategory as the StatusCategory means the request was malformed.
PNBadRequestCategory
// PNAccessDeniedCategory as the StatusCategory means that PAM is enabled and the channel is not granted R/W access.
PNAccessDeniedCategory
// PNNoStubMatchedCategory as the StatusCategory means an unknown status category event occurred.
PNNoStubMatchedCategory
// PNReconnectedCategory as the StatusCategory means that the network was reconnected (after a disconnection).
// Applicable on for PNLinearPolicy and PNExponentialPolicy.
PNReconnectedCategory
// PNReconnectionAttemptsExhausted as the StatusCategory means that the reconnection attempts
// to reconnect to the network were exhausted. All channels would be unsubscribed at this point.
// Applicable on for PNLinearPolicy and PNExponentialPolicy.
// Reconnection attempts are set in the config: MaximumReconnectionRetries.
PNReconnectionAttemptsExhausted
// PNRequestMessageCountExceededCategory is fired when the MessageQueueOverflowCount limit is exceeded by the number of messages received in a single subscribe request
PNRequestMessageCountExceededCategory
)
const (
// PNSubscribeOperation is the enum used for the Subcribe operation.
PNSubscribeOperation OperationType = 1 + iota
// PNUnsubscribeOperation is the enum used for the Unsubcribe operation.
PNUnsubscribeOperation
// PNPublishOperation is the enum used for the Publish operation.
PNPublishOperation
// PNFireOperation is the enum used for the Fire operation.
PNFireOperation
// PNHistoryOperation is the enum used for the History operation.
PNHistoryOperation
// PNFetchMessagesOperation is the enum used for the Fetch operation.
PNFetchMessagesOperation
// PNWhereNowOperation is the enum used for the Where Now operation.
PNWhereNowOperation
// PNHereNowOperation is the enum used for the Here Now operation.
PNHereNowOperation
// PNHeartBeatOperation is the enum used for the Heartbeat operation.
PNHeartBeatOperation
// PNSetStateOperation is the enum used for the Set State operation.
PNSetStateOperation
// PNGetStateOperation is the enum used for the Get State operation.
PNGetStateOperation
// PNAddChannelsToChannelGroupOperation is the enum used for the Add Channels to Channel Group operation.
PNAddChannelsToChannelGroupOperation
// PNRemoveChannelFromChannelGroupOperation is the enum used for the Remove Channels from Channel Group operation.
PNRemoveChannelFromChannelGroupOperation
// PNRemoveGroupOperation is the enum used for the Remove Channel Group operation.
PNRemoveGroupOperation
// PNChannelsForGroupOperation is the enum used for the List Channels of Channel Group operation.
PNChannelsForGroupOperation
// PNPushNotificationsEnabledChannelsOperation is the enum used for the List Channels with Push Notifications enabled operation.
PNPushNotificationsEnabledChannelsOperation
// PNAddPushNotificationsOnChannelsOperation is the enum used for the Add Channels to Push Notifications operation.
PNAddPushNotificationsOnChannelsOperation
// PNRemovePushNotificationsFromChannelsOperation is the enum used for the Remove Channels from Push Notifications operation.
PNRemovePushNotificationsFromChannelsOperation
// PNRemoveAllPushNotificationsOperation is the enum used for the Remove All Channels from Push Notifications operation.
PNRemoveAllPushNotificationsOperation
// PNTimeOperation is the enum used for the Time operation.
PNTimeOperation
// PNAccessManagerGrant is the enum used for the Access Manager Grant operation.
PNAccessManagerGrant
// PNAccessManagerRevoke is the enum used for the Access Manager Revoke operation.
PNAccessManagerRevoke
// PNDeleteMessagesOperation is the enum used for the Delete Messages from History operation.
PNDeleteMessagesOperation
)
const (
// PNPushTypeNone is used as an enum to for selecting `none` as the PNPushType
PNPushTypeNone PNPushType = 1 + iota
// PNPushTypeGCM is used as an enum to for selecting `GCM` as the PNPushType
PNPushTypeGCM
// PNPushTypeAPNS is used as an enum to for selecting `APNS` as the PNPushType
PNPushTypeAPNS
// PNPushTypeMPNS is used as an enum to for selecting `MPNS` as the PNPushType
PNPushTypeMPNS
)
func (p PNPushType) String() string {
switch p {
case PNPushTypeAPNS:
return "apns"
case PNPushTypeGCM:
return "gcm"
case PNPushTypeMPNS:
return "mpns"
default:
return "none"
}
}
var operations = [...]string{
"Subscribe",
"Unsubscribe",
"Publish",
"History",
"Fetch Messages",
"Where Now",
"Here Now",
"Heartbeat",
"Set State",
"Get State",
"Add Channel To Channel Group",
"Remove Channel From Channel Group",
"Remove Channel Group",
"List Channels In Channel Group",
"List Push Enabled Channels",
"Add Push From Channel",
"Remove Push From Channel",
"Remove All Push Notifications",
"Time",
"Grant",
"Revoke",
"Delete messages",
}
func (c StatusCategory) String() string {
switch c {
case PNUnknownCategory:
return "Unknown"
case PNTimeoutCategory:
return "Timeout"
case PNConnectedCategory:
return "Connected"
case PNDisconnectedCategory:
return "Disconnected"
case PNCancelledCategory:
return "Cancelled"
case PNLoopStopCategory:
return "Loop Stop"
case PNAcknowledgmentCategory:
return "Acknowledgment"
case PNBadRequestCategory:
return "Bad Request"
case PNAccessDeniedCategory:
return "Access Denied"
case PNReconnectedCategory:
return "Reconnected"
case PNReconnectionAttemptsExhausted:
return "Reconnection Attempts Exhausted"
case PNNoStubMatchedCategory:
return "No Stub Matched"
default:
return "No Stub Matched"
}
}
func (t OperationType) String() string {
switch t {
case PNSubscribeOperation:
return "Subscribe"
case PNUnsubscribeOperation:
return "Unsubscribe"
case PNPublishOperation:
return "Publish"
case PNFireOperation:
return "Fire"
case PNHistoryOperation:
return "History"
case PNFetchMessagesOperation:
return "Fetch Messages"
case PNWhereNowOperation:
return "Where Now"
case PNHereNowOperation:
return "Here Now"
case PNHeartBeatOperation:
return "Heartbeat"
case PNSetStateOperation:
return "Set State"
case PNGetStateOperation:
return "Get State"
case PNAddChannelsToChannelGroupOperation:
return "Add Channel To Channel Group"
case PNRemoveChannelFromChannelGroupOperation:
return "Remove Channel From Channel Group"
case PNRemoveGroupOperation:
return "Remove Channel Group"
case PNChannelsForGroupOperation:
return "List Channels In Channel Group"
case PNPushNotificationsEnabledChannelsOperation:
return "List Push Enabled Channels"
case PNAddPushNotificationsOnChannelsOperation:
return "Add Push From Channel"
case PNRemovePushNotificationsFromChannelsOperation:
return "Remove Push From Channel"
case PNRemoveAllPushNotificationsOperation:
return "Remove All Push Notifications"
case PNTimeOperation:
return "Time"
case PNAccessManagerGrant:
return "Grant"
case PNAccessManagerRevoke:
return "Revoke"
case PNDeleteMessagesOperation:
return "Delete messages"
default:
return "No Category Matched"
}
}