UNPKG

6.02 kBTypeScriptView Raw
1import { ServiceType } from './generaltypes';
2/**
3 * Represents the status of an an endpoint in a diagnostics report.
4 *
5 * @category Diagnostics
6 */
7export declare enum EndpointState {
8 /**
9 * Indicates the endpoint is disconnected.
10 */
11 Disconnected = 0,
12 /**
13 * Indicates the endpoint is still connecting.
14 */
15 Connecting = 1,
16 /**
17 * Indicates the endpoint is connected.
18 */
19 Connected = 2,
20 /**
21 * Indicates the endpoint is disconnecting.
22 */
23 Disconnecting = 3
24}
25/**
26 * Represents the status of an an endpoint in a ping report.
27 */
28export declare enum PingState {
29 /**
30 * Indicates the endpoint was pinged successfully.
31 */
32 Ok = 0,
33 /**
34 * Indicates the endpoint timed out during the ping.
35 */
36 Timeout = 1,
37 /**
38 * Indicates an error occured trying to ping the endpoint.
39 */
40 Error = 2
41}
42/**
43 * The JSON-formated output report from a ping operation.
44 *
45 * @see {PingResult}
46 * @category Diagnostics
47 */
48export interface JsonPingReport {
49 version: number;
50 id: string;
51 sdk: string;
52 services: {
53 [serviceType: string]: {
54 latency_us: number;
55 remote: string;
56 local: string;
57 id: string;
58 state: string;
59 namespace?: string;
60 error?: string;
61 }[];
62 };
63}
64/**
65 * The JSON-formated output report from a diagnostics operation.
66 *
67 * @see {DiagnosticsResult}
68 * @category Diagnostics
69 */
70export interface JsonDiagnosticsReport {
71 version: number;
72 id: string;
73 sdk: string;
74 services: {
75 [serviceType: string]: {
76 last_activity_us?: number;
77 remote: string;
78 local: string;
79 id: string;
80 state: string;
81 namespace?: string;
82 details?: string;
83 }[];
84 };
85}
86/**
87 * PingEndpoint represents a single endpoint in a ping result.
88 *
89 * @category Diagnostics
90 */
91export declare class PingEndpoint {
92 /**
93 * @internal
94 */
95 constructor(data: PingEndpoint);
96 /**
97 * The type of service this endpoint refers to.
98 */
99 type: ServiceType;
100 /**
101 * The unique identifier for this endpoint.
102 */
103 id: string;
104 /**
105 * The remote address of this endpoint.
106 */
107 remote: string;
108 /**
109 * The local address of this endpoint.
110 */
111 local: string;
112 /**
113 * The latency of the ping to the endpoint.
114 */
115 latency: number;
116 /**
117 * The current state of this endpoint.
118 */
119 state: PingState;
120 /**
121 * The bucket this endpoint is connected to.
122 */
123 bucket?: string;
124 /**
125 * Information about errors that occured during pinging.
126 */
127 error?: any;
128}
129/**
130 * PingResult represents the output of a ping operation.
131 *
132 * @category Diagnostics
133 */
134export declare class PingResult {
135 /**
136 * @internal
137 */
138 constructor(data: {
139 version: number;
140 id: string;
141 sdk: string;
142 services: {
143 [serviceType: string]: PingEndpoint[];
144 };
145 });
146 /**
147 * The version number of this report.
148 */
149 version: number;
150 /**
151 * The unique identifier for this report.
152 */
153 id: string;
154 /**
155 * The name of the SDK which generated this report.
156 */
157 sdk: string;
158 /**
159 * A list of service endpoints and their ping results.
160 */
161 services: {
162 [serviceType: string]: PingEndpoint[];
163 };
164 /**
165 * Returns a JSON formatted ping report.
166 */
167 toJSON(): JsonPingReport;
168}
169/**
170 * @category Diagnostics
171 */
172export interface PingOptions {
173 /**
174 * A unique identifier for the report generated by this operation.
175 */
176 reportId?: string;
177 /**
178 * The services which should be pinged.
179 */
180 serviceTypes?: ServiceType[];
181 /**
182 * The name of the bucket to ping.
183 */
184 bucket?: string;
185 /**
186 * The timeout for this operation, represented in milliseconds.
187 */
188 timeout?: number;
189}
190/**
191 * DiagnosticsEndpoint represents a single endpoint in a diagnostics
192 * result.
193 *
194 * @category Diagnostics
195 */
196export declare class DiagnosticsEndpoint {
197 /**
198 * @internal
199 */
200 constructor(data: DiagnosticsEndpoint);
201 /**
202 * The type of service this entry represents.
203 */
204 type: ServiceType;
205 /**
206 * The unique identifier for this endpoint.
207 */
208 id: string;
209 /**
210 * The local address of this endpoint.
211 */
212 local: string;
213 /**
214 * The remote address of this endpoint.
215 */
216 remote: string;
217 /**
218 * The time in milliseconds since the last activity.
219 */
220 lastActivity: number;
221 /**
222 * The current state of this endpoint.
223 */
224 state: EndpointState;
225 /**
226 * The name of the bucket this endpoint is connected to.
227 */
228 bucket?: string;
229 /**
230 * Various additional details about the endpoint.
231 */
232 details?: any;
233}
234/**
235 * DiagnosticsResult represents the output of a operation result.
236 *
237 * @category Diagnostics
238 */
239export declare class DiagnosticsResult {
240 /**
241 * @internal
242 */
243 constructor(data: {
244 version: number;
245 id: string;
246 sdk: string;
247 services: {
248 [serviceType: string]: DiagnosticsEndpoint[];
249 };
250 });
251 /**
252 * The version number of this report.
253 */
254 version: number;
255 /**
256 * The unique identifier for this report.
257 */
258 id: string;
259 /**
260 * The name of the SDK which generated this report.
261 */
262 sdk: string;
263 /**
264 * A list of service endpoints and their diagnostic status.
265 */
266 services: {
267 [serviceType: string]: DiagnosticsEndpoint[];
268 };
269 /**
270 * Returns a JSON formatted diagnostics report.
271 */
272 toJSON(): JsonDiagnosticsReport;
273}
274/**
275 * @category Diagnostics
276 */
277export interface DiagnosticsOptions {
278 /**
279 * A unique identifier for the report generated by this operation.
280 */
281 reportId?: string;
282}