@types/k6 0.39.0 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k6/README.md +1 -1
- k6/experimental/redis.d.ts +609 -0
- k6/experimental/timers.d.ts +47 -0
- k6/experimental/websockets.d.ts +176 -0
- k6/index.d.ts +3 -0
- k6/package.json +2 -2
k6/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for k6 (https://k6.io/docs/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Thu, 08 Sep 2022 10:02:37 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: none
|
|
14
14
|
|
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides a redis client allowing users to interact with redis,
|
|
3
|
+
* directly from their k6 scripts.
|
|
4
|
+
*
|
|
5
|
+
* https://k6.io/docs/javascript-api/k6-redis/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `Client` is a Redis client to interact with a Redis server or cluster.
|
|
10
|
+
*
|
|
11
|
+
* It exposes a promise-based API, allowing users to interact with Redis in an asynchronous manner.
|
|
12
|
+
*
|
|
13
|
+
* https://k6.io/docs/javascript-api/k6-redis/client
|
|
14
|
+
*/
|
|
15
|
+
export class Client {
|
|
16
|
+
protected __brand: never;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Instantiate a new Redis client.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Options.
|
|
22
|
+
* @returns instantiated Client
|
|
23
|
+
*/
|
|
24
|
+
constructor(options: Options);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sets the value of a key, with a time to live (ttl) value equal to
|
|
28
|
+
* the provided expiration.
|
|
29
|
+
*
|
|
30
|
+
* If the key already exists, it is overwritten.
|
|
31
|
+
*
|
|
32
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-set
|
|
33
|
+
*
|
|
34
|
+
* @param key - key to set
|
|
35
|
+
* @param value - value to set
|
|
36
|
+
* @param expiration - time to live in seconds. `0` means no expiration.
|
|
37
|
+
* @returns a promise that resolves to "OK" if the operation succeeded.
|
|
38
|
+
*/
|
|
39
|
+
set(key: string, value: any, expiration: number): Promise<string>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Gets the value of a key.
|
|
43
|
+
*
|
|
44
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-get
|
|
45
|
+
*
|
|
46
|
+
* @param key - key to get
|
|
47
|
+
* @returns a promise that resolves to the value of the key.
|
|
48
|
+
*/
|
|
49
|
+
get(key: string): Promise<string>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Atomically sets the value of a key and returns the value
|
|
53
|
+
* previously stored at that key.
|
|
54
|
+
*
|
|
55
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-getset
|
|
56
|
+
*
|
|
57
|
+
* @param key - key to get and set
|
|
58
|
+
* @param value - value to set
|
|
59
|
+
* @returns a promise that resolves to the old value of the key.
|
|
60
|
+
*/
|
|
61
|
+
getSet(key: string, value: any): Promise<string>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Removes the specified keys.
|
|
65
|
+
*
|
|
66
|
+
* A key is ignored if it does not exist.
|
|
67
|
+
*
|
|
68
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-del
|
|
69
|
+
*
|
|
70
|
+
* @param keys - keys to delete
|
|
71
|
+
* @returns a promise that resolves to the number of keys that were removed.
|
|
72
|
+
*/
|
|
73
|
+
del(keys: string[]): Promise<number>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get the value of a key and delete it.
|
|
77
|
+
*
|
|
78
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-getdel
|
|
79
|
+
*
|
|
80
|
+
* @param key - the key to get and delete
|
|
81
|
+
* @returns a promise that resolves to the value of the key that was deleted.
|
|
82
|
+
*/
|
|
83
|
+
getDel(key: string): Promise<string>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns the number of the provided keys arguments that exist.
|
|
87
|
+
*
|
|
88
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-exists
|
|
89
|
+
*
|
|
90
|
+
* @param keys - the keys to check the existence of
|
|
91
|
+
* @returns a promise that resolves to the number of keys that exist.
|
|
92
|
+
*/
|
|
93
|
+
exists(keys: string[]): Promise<number>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Increments the numerical value stored at key by one.
|
|
97
|
+
*
|
|
98
|
+
* If the key does not exist, it is set to 0 before performing the operation.
|
|
99
|
+
* If the key exists but cannot be treated as a number, the returned promise will be rejected.
|
|
100
|
+
*
|
|
101
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-incr
|
|
102
|
+
*
|
|
103
|
+
* @param key - key to increment the value of
|
|
104
|
+
* @returns a promise that resolves to the value of the key after the increment.
|
|
105
|
+
*/
|
|
106
|
+
incr(key: string): Promise<number>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Increments the numerical value stored at key by the provided increment.
|
|
110
|
+
*
|
|
111
|
+
* If the key does not exist, it is set to 0 before performing the operation.
|
|
112
|
+
* If the key exists but cannot be treated as a number, the returned promise will be rejected.
|
|
113
|
+
*
|
|
114
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-incrby
|
|
115
|
+
*
|
|
116
|
+
* @param key - key to increment the value of
|
|
117
|
+
* @param increment - amount to increment the value of the key by
|
|
118
|
+
* @returns a promise that resolves to the value of the key after the increment.
|
|
119
|
+
*/
|
|
120
|
+
incrBy(key: string, increment: number): Promise<number>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Decrements the numerical value stored at key by one.
|
|
124
|
+
*
|
|
125
|
+
* If the key does not exist, it is set to 0 before performing the operation.
|
|
126
|
+
* If the key exists but cannot be treated as a number, the returned promise will be rejected.
|
|
127
|
+
*
|
|
128
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-decr
|
|
129
|
+
*
|
|
130
|
+
* @param key - key to decrement the value of
|
|
131
|
+
* @returns a promise that resolves to the value of the key after the decrement.
|
|
132
|
+
*/
|
|
133
|
+
decr(key: string): Promise<number>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Decrements the numerical value stored at key by the provided decrement.
|
|
137
|
+
*
|
|
138
|
+
* If the key does not exist, it is set to 0 before performing the operation.
|
|
139
|
+
* If the key exists but cannot be treated as a number, the returned promise will be rejected.
|
|
140
|
+
*
|
|
141
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-decrby
|
|
142
|
+
*
|
|
143
|
+
* @param key - key to decrement the value of
|
|
144
|
+
* @param decrement - amount to decrement the value of the key by
|
|
145
|
+
* @returns a promise that resolves to the value of the key after the decrement.
|
|
146
|
+
*/
|
|
147
|
+
decrBy(key: string, decrement: number): Promise<number>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Returns a random key from the keyspace.
|
|
151
|
+
*
|
|
152
|
+
* If the database is empty, the returned promise will be rejected.
|
|
153
|
+
*
|
|
154
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-randomkey
|
|
155
|
+
*
|
|
156
|
+
* @returns a promise that resolves to a random key.
|
|
157
|
+
*/
|
|
158
|
+
randomKey(): Promise<string>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns the values of all the specified keys.
|
|
162
|
+
*
|
|
163
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-mget
|
|
164
|
+
*
|
|
165
|
+
* @param keys - the keys to get the values of
|
|
166
|
+
* @returns a promise that resolves to an array of the values of the keys.
|
|
167
|
+
*/
|
|
168
|
+
mget(keys: string[]): Promise<any[]>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Sets a timeout on a key. After the timeout has expired, the key will automatically be deleted.
|
|
172
|
+
*
|
|
173
|
+
* Calling expire with a non-positive timeout value will result in the being deleted rather
|
|
174
|
+
* than expired.
|
|
175
|
+
*
|
|
176
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-expire
|
|
177
|
+
*
|
|
178
|
+
* @param key - key to set the time to live of
|
|
179
|
+
* @param seconds - value to set the time to live of the key to (in seconds)
|
|
180
|
+
* @returns a promise that resolves to true if the operation succeeded, false otherwise.
|
|
181
|
+
*/
|
|
182
|
+
expire(key: string, seconds: number): Promise<boolean>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Returns the remaining time to live of a key that has a timeout.
|
|
186
|
+
*
|
|
187
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-ttl
|
|
188
|
+
*
|
|
189
|
+
* @param key - the key to get the time to live of
|
|
190
|
+
* @returns a promise that resolves to the time to live of the key, in seconds.
|
|
191
|
+
*/
|
|
192
|
+
ttl(key: string): Promise<number>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Removes the existing timeout on a key.
|
|
196
|
+
*
|
|
197
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-persist
|
|
198
|
+
*
|
|
199
|
+
* @param key - the key to remove the timeout of.
|
|
200
|
+
* @returns a promise that resolves to true if the operation succeeded, false otherwise.
|
|
201
|
+
*/
|
|
202
|
+
persist(key: string): Promise<boolean>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Prepends values to a list, creating the list if it does not already exist.
|
|
206
|
+
*
|
|
207
|
+
* If the key exists but does not hold a list, the returned promise will be rejected.
|
|
208
|
+
*
|
|
209
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-lpush
|
|
210
|
+
*
|
|
211
|
+
* @param key - key holding the list to prepend to
|
|
212
|
+
* @param values - values to prepend to the list
|
|
213
|
+
* @returns a promise that resolves to the number of elements in the list after the prepend operation.
|
|
214
|
+
*/
|
|
215
|
+
lpsuh(key: string, values: any[]): Promise<number>;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Appends values to a list, creating the list if it does not already exist.
|
|
219
|
+
*
|
|
220
|
+
* If the key exists but does not hold a list, the returned promise will be rejected.
|
|
221
|
+
*
|
|
222
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-rpush
|
|
223
|
+
*
|
|
224
|
+
* @param key - key holding the list to append to
|
|
225
|
+
* @param values - values to append to the list
|
|
226
|
+
* @returns a promise that resolves to the number of elements in the list after the append operation.
|
|
227
|
+
*/
|
|
228
|
+
rpush(key: string, values: any[]): Promise<number>;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Removes and returns the value at the head of the list stored at key.
|
|
232
|
+
*
|
|
233
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-lpop
|
|
234
|
+
*
|
|
235
|
+
* @param key - key holding the list to pop the head of
|
|
236
|
+
* @returns a promise that resolves to the value that was popped.
|
|
237
|
+
*/
|
|
238
|
+
lpop(key: string): Promise<string>;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Removes and returns the value at the tail of the list stored at key.
|
|
242
|
+
*
|
|
243
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-rpop
|
|
244
|
+
*
|
|
245
|
+
* @param key - key holding the list to pop the tail of
|
|
246
|
+
* @returns a promise that resolves to the value that was popped.
|
|
247
|
+
*/
|
|
248
|
+
rpop(key: string): Promise<string>;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns the elements stored in the list from start to end.
|
|
252
|
+
*
|
|
253
|
+
* The offsets are zero-based. These offsets can be negative numbers indicating
|
|
254
|
+
* offsets starting at the end of the list.
|
|
255
|
+
*
|
|
256
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-lrange
|
|
257
|
+
*
|
|
258
|
+
* @param key - key holding the list to get the range of
|
|
259
|
+
* @param start - index of the first element to return
|
|
260
|
+
* @param stop - index of the last element to return
|
|
261
|
+
* @returns a promise that resolves to an array of the values in the specified range.
|
|
262
|
+
*/
|
|
263
|
+
lrange(key: string, start: number, stop: number): Promise<string[]>;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Returns the element at the specified in the list stored at key.
|
|
267
|
+
*
|
|
268
|
+
* The offsets are zero-based. These offsets can be negative numbers indicating
|
|
269
|
+
* offsets starting at the end of the list.
|
|
270
|
+
*
|
|
271
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-lindex
|
|
272
|
+
*
|
|
273
|
+
* @param key - key holding the list to get the element of
|
|
274
|
+
* @param index - index of the element to get
|
|
275
|
+
* @returns a promise that resolves to the value of the element at the specified index.
|
|
276
|
+
*/
|
|
277
|
+
lindex(key: string, index: number): Promise<string>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Sets the value of an element in the list stored at key to new value.
|
|
281
|
+
*
|
|
282
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-lset
|
|
283
|
+
*
|
|
284
|
+
* @param key - key holding the list to set the element of
|
|
285
|
+
* @param index - index of the element to set
|
|
286
|
+
* @param element - value to set the element to
|
|
287
|
+
* @returns a promise that resolves to the 'OK' string if the operation succeeded
|
|
288
|
+
*/
|
|
289
|
+
lset(key: string, index: number, element: string): Promise<string>;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Removes the first `count` occurrences of `value` from the list stored at `key`.
|
|
293
|
+
*
|
|
294
|
+
* If the `count` is positive, elements are removed the from head of the list (from left to right)
|
|
295
|
+
* If the `count` is 0, all occurrences of `value` are removed.
|
|
296
|
+
* If the `count` is negative, elements are removed from the tail of the list (from right to left).
|
|
297
|
+
*
|
|
298
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-lrem
|
|
299
|
+
*
|
|
300
|
+
* @param key - key holding the list to remove the element of
|
|
301
|
+
* @param count - the number of elements matching the value to remove
|
|
302
|
+
* @param value - the value to remove
|
|
303
|
+
* @returns a promise that resolves to the number of elements removed.
|
|
304
|
+
*/
|
|
305
|
+
lrem(key: string, count: number, value: string): Promise<number>;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Returns the length of the list stored at the key.
|
|
309
|
+
*
|
|
310
|
+
* If the key does not exist, it is interpreted as an empty list and 0 is returned.
|
|
311
|
+
*
|
|
312
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-llen
|
|
313
|
+
*
|
|
314
|
+
* @param key - key holding the list to get the length of
|
|
315
|
+
* @returns a promise that resolves to the length of the list.
|
|
316
|
+
*/
|
|
317
|
+
llen(key: string): Promise<number>;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Sets the value of a hash field to the specified value.
|
|
321
|
+
*
|
|
322
|
+
* If the key does not exist, a new key holding a hash is created.
|
|
323
|
+
* If the field already exists, it is overwritten.
|
|
324
|
+
*
|
|
325
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hset
|
|
326
|
+
*
|
|
327
|
+
* @param key - key holding the hash to set the field's value of
|
|
328
|
+
* @param field - field to set the value of
|
|
329
|
+
* @param value - value to set the field to
|
|
330
|
+
* @returns a promise that resolves to the the number of fields that were changed.
|
|
331
|
+
*/
|
|
332
|
+
hset(key: string, field: string, value: string): Promise<number>;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Sets the value of a hash field to the specified value, if and only if the field does not yet exist.
|
|
336
|
+
*
|
|
337
|
+
* If the key does not exist, a new key holding a hash is created.
|
|
338
|
+
* If the field already exists, the returned promise will be rejected.
|
|
339
|
+
*
|
|
340
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hsetnx
|
|
341
|
+
*
|
|
342
|
+
* @param key - key holding the hash to set the field's value of
|
|
343
|
+
* @param field - field to set the value of
|
|
344
|
+
* @param value - value to set the field to
|
|
345
|
+
* @returns a promise that resolves to true if the hash field was set, false otherwise.
|
|
346
|
+
*/
|
|
347
|
+
hsetnx(key: string, field: string, value: string): Promise<boolean>;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
*
|
|
351
|
+
* Returns the value of the specified hash field.
|
|
352
|
+
*
|
|
353
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hget
|
|
354
|
+
*
|
|
355
|
+
* @param key - key holding the hash to get the field's value of
|
|
356
|
+
* @param field - field to get the value of
|
|
357
|
+
* @returns a promise that resolves to the value of the hash field.
|
|
358
|
+
*/
|
|
359
|
+
hget(key: string, field: string): Promise<string>;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Deletes the specified fields from the hash stored at key.
|
|
363
|
+
*
|
|
364
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hdel
|
|
365
|
+
*
|
|
366
|
+
* @param key - key holding the hash to delete the fields of
|
|
367
|
+
* @param fields - fields to delete from the hash
|
|
368
|
+
* @returns a promise that resolves to the number of fields that were deleted.
|
|
369
|
+
*/
|
|
370
|
+
hdel(key: string, fields: string[]): Promise<number>;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Returns all fields and values of the hash stored at key.
|
|
374
|
+
*
|
|
375
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hgetall
|
|
376
|
+
*
|
|
377
|
+
* @param key - the key holding the hash to get the fields of
|
|
378
|
+
* @returns a promise that resolves to an object of field/value pairs.
|
|
379
|
+
*/
|
|
380
|
+
hgetall(key: string): Promise<{ [key: string]: string }>;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Returns all fields of the hash stored at key.
|
|
384
|
+
*
|
|
385
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hkeys
|
|
386
|
+
*
|
|
387
|
+
* @param key - the key holding the hash to get the fields of
|
|
388
|
+
* @returns a promise that resolves to an array of field names.
|
|
389
|
+
*/
|
|
390
|
+
hkeys(key: string): Promise<string[]>;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Returns all values of the hash stored at key.
|
|
394
|
+
*
|
|
395
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hvals
|
|
396
|
+
*
|
|
397
|
+
* @param key - the key holding the hash to get the fields' values of
|
|
398
|
+
* @returns a promise that resolves to an array of field values.
|
|
399
|
+
*/
|
|
400
|
+
hvals(key: string): Promise<string[]>;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Return the number of fields contained in the hash stored at key.
|
|
404
|
+
*
|
|
405
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hlen
|
|
406
|
+
*
|
|
407
|
+
* @param key - the key holding the hash to get the number of fields of
|
|
408
|
+
* @returns a promise that resolves to the number of fields in the hash.
|
|
409
|
+
*/
|
|
410
|
+
hlen(key: string): Promise<number>;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Increments the numberical value stored at the hash field by the specified amount.
|
|
414
|
+
*
|
|
415
|
+
* If the key does not exist, a new key holding a hash is created.
|
|
416
|
+
* If the field does not exist, it is set to 0 before the operation is performed.
|
|
417
|
+
* If the field does not hold a nummerical value, the returned promise will be rejected.
|
|
418
|
+
*
|
|
419
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-hincrby
|
|
420
|
+
*
|
|
421
|
+
* @param key - the key holding the hash to get the number of fields of
|
|
422
|
+
* @param field - the hash's field to increment the value of
|
|
423
|
+
* @param increment - the amount to increment the value by
|
|
424
|
+
* @returns a promise that resolves to the value of the field after the increment.
|
|
425
|
+
*/
|
|
426
|
+
hincrby(key: string, field: string, increment: number): Promise<number>;
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Adds the specified elements to the set stored at key.
|
|
430
|
+
*
|
|
431
|
+
* Specified elements that are already a member of the set are ignored.
|
|
432
|
+
* If the key does not exist, a new set is created before adding the specified elements.
|
|
433
|
+
*
|
|
434
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-sadd
|
|
435
|
+
*
|
|
436
|
+
* @param key - the key holding the set to add a member to
|
|
437
|
+
* @param members - the members to add to the set
|
|
438
|
+
* @returns a promise that resolves to the number of members that were added to the set; excluding those that were already present.
|
|
439
|
+
*/
|
|
440
|
+
sadd(key: string, members: any[]): Promise<number>;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Removes the specified members from the set stored at key.
|
|
444
|
+
*
|
|
445
|
+
* Specified members that are not a member of this set are ignored.
|
|
446
|
+
* If key does not exist, it is treated as an empty set and this command returns 0.
|
|
447
|
+
*
|
|
448
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-srem
|
|
449
|
+
*
|
|
450
|
+
* @param key - the key holding the set to remove a member from
|
|
451
|
+
* @param members - the members to remove from the set
|
|
452
|
+
* @returns a promise that resolves to the number of members that were removed from the set.
|
|
453
|
+
*/
|
|
454
|
+
srem(key: string, members: any[]): Promise<number>;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Returns whether or not the specified member is a member of the set stored at key.
|
|
458
|
+
*
|
|
459
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-sismembers
|
|
460
|
+
*
|
|
461
|
+
* @param key - the key holding the set to check the belonging of
|
|
462
|
+
* @param member - the member to check the belonging of
|
|
463
|
+
* @returns a promise that resolves to true if the member is a member of the set, false otherwise.
|
|
464
|
+
*/
|
|
465
|
+
sismember(key: string, member: any): Promise<boolean>;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Returns the members of the set stored at key.
|
|
469
|
+
*
|
|
470
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-smembers
|
|
471
|
+
*
|
|
472
|
+
* @param key - the key holding the set to get the members of
|
|
473
|
+
* @returns a promise that resolves to an array of members in the set.
|
|
474
|
+
*/
|
|
475
|
+
smembers(key: string): Promise<string[]>;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Returns a random member of the set value stored at key.
|
|
479
|
+
*
|
|
480
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-srandmember
|
|
481
|
+
*
|
|
482
|
+
* @param key - the key holding the set to get the random member of
|
|
483
|
+
* @returns a promise that resolves to a random member of the set.
|
|
484
|
+
*/
|
|
485
|
+
srandmember(key: string): Promise<string>;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Pops a random member from the set stored at key.
|
|
489
|
+
*
|
|
490
|
+
* https://k6.io/docs/javascript-api/k6-redis/client/client-spop
|
|
491
|
+
*
|
|
492
|
+
* @param key - the key holding the set to pop the random member of
|
|
493
|
+
* @returns a promise that resolves to the popped member.
|
|
494
|
+
*/
|
|
495
|
+
spop(key: string): Promise<string>;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Options for configuring the redis Client.
|
|
500
|
+
*
|
|
501
|
+
* https://k6.io/docs/javascript-api/k6-redis/options
|
|
502
|
+
*/
|
|
503
|
+
export interface Options {
|
|
504
|
+
/**
|
|
505
|
+
* Array of addresses in the 'host:port' defining which connect Redis to connect to.
|
|
506
|
+
* Supplying a single entry would connect the client to a single Redis instance.
|
|
507
|
+
* Supplying multiple entries would connect the client to a cluster/sentinel nodes.
|
|
508
|
+
*/
|
|
509
|
+
addrs: string[];
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* The id of the database to be selected after connecting to the server.
|
|
513
|
+
* Only used when connecting to a single-node use.
|
|
514
|
+
*/
|
|
515
|
+
db?: number;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Username to authenticate the client connection with.
|
|
519
|
+
*/
|
|
520
|
+
username?: number;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Password to authenticate the client connection with.
|
|
524
|
+
*/
|
|
525
|
+
password?: number;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Username to authenticate the client connection with when connecting to a sentinel.
|
|
529
|
+
*/
|
|
530
|
+
sentinelUsername?: number;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Password to authenticate the client connection with when connecting to a sentinel.
|
|
534
|
+
*/
|
|
535
|
+
sentinelPassword?: number;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* The name of the master to connect to when connecting to a Redis cluster.
|
|
539
|
+
*/
|
|
540
|
+
masterName?: number;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* The maximum number of retries to attempt when connecting to a Redis server before giving up.
|
|
544
|
+
*/
|
|
545
|
+
maxRetries?: number;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* The minimum amount of time to wait between retries when connecting to a Redis server.
|
|
549
|
+
*/
|
|
550
|
+
minRetryBackoff?: number;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* The maximum amount of time to wait between retries when connecting to a Redis server.
|
|
554
|
+
*/
|
|
555
|
+
maxRetryBackoff?: number;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* The maximum amount of time to wait for a connection to a Redis server to be established.
|
|
559
|
+
*/
|
|
560
|
+
dialTimeout?: number;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* The maximum amount of time to wait for socket reads to succeed.
|
|
564
|
+
* Use `-1` for no timeout.
|
|
565
|
+
*/
|
|
566
|
+
readTimeout?: number;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* The maximum amount of time to wait for a socket write to succeed.
|
|
570
|
+
* Use `-1` for no timeout.
|
|
571
|
+
*/
|
|
572
|
+
writeTimeout?: number;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* The maximum number of socket connections to keep open in the connection pool.
|
|
576
|
+
*/
|
|
577
|
+
poolSize?: number;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* The minimum number of idle connections to keep open in the connection pool.
|
|
581
|
+
*/
|
|
582
|
+
minIdleConns?: number;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* The maximum number of idle connections to keep open in the connection pool.
|
|
586
|
+
*/
|
|
587
|
+
maxIdleConns?: number;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* The maximum amount of time a connection can be idle in the connection pool before being closed.
|
|
591
|
+
*/
|
|
592
|
+
maxConnAge?: number;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* The maximum amount of time to wait for a connection to the Redis server to be returned from the pool.
|
|
596
|
+
*/
|
|
597
|
+
poolTimeout?: number;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* The maximum amount of time the client waits for a connection to become active before timing out.
|
|
601
|
+
*/
|
|
602
|
+
idleTimeout?: number;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* The frequency at which the client checks for idle connections in the connection pool.
|
|
606
|
+
* Use `-1` to disable the checks.
|
|
607
|
+
*/
|
|
608
|
+
idleCheckFrequency?: number;
|
|
609
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides setInterval, setTimeout and co.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Set a timer which execution a function once the timer expires.
|
|
7
|
+
*
|
|
8
|
+
* @param functionRef - The function to be executed.
|
|
9
|
+
* @param delay - The delay in milliseconds.
|
|
10
|
+
* @param args - The arguments to be passed to the function.
|
|
11
|
+
* @returns The timer id.
|
|
12
|
+
*/
|
|
13
|
+
export function setTimeout(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutID;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cancels a timeout previously set with setTimeout().
|
|
17
|
+
*
|
|
18
|
+
* @param timeoutID - The timer id to be cancelled.
|
|
19
|
+
*/
|
|
20
|
+
export function clearTimeout(timeoutID: TimeoutID): void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Repeatedly execute a function, with a fixed time delay between each call.
|
|
24
|
+
*
|
|
25
|
+
* @param functionRef - The function to be executed.
|
|
26
|
+
* @param delay - The delay in milliseconds.
|
|
27
|
+
* @param args - The arguments to be passed to the function.
|
|
28
|
+
* @returns The interval id.
|
|
29
|
+
*/
|
|
30
|
+
export function setInterval(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Cancels a interval previously set with setInterval().
|
|
34
|
+
*
|
|
35
|
+
* @param intervalID - The interval id to be cancelled.
|
|
36
|
+
*/
|
|
37
|
+
export function clearInterval(intervalID: IntervalID): void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Type alias for a timer id.
|
|
41
|
+
*/
|
|
42
|
+
export type TimeoutID = number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Type alias for a interval id.
|
|
46
|
+
*/
|
|
47
|
+
export type IntervalID = number;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides an experimental implementation of the WebSocket API
|
|
3
|
+
* for k6.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Websocket object provides the API for creating and managing WebSocket
|
|
8
|
+
* connections as well as for sending and receiving data on the connection.
|
|
9
|
+
*/
|
|
10
|
+
export class WebSocket {
|
|
11
|
+
protected __brand: never;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The absolute URL to which the Websocket connection is established.
|
|
15
|
+
*/
|
|
16
|
+
readonly url: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The current state of the Websocket connection.
|
|
20
|
+
*/
|
|
21
|
+
readonly readyState: ReadyState;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The number of bytes of data that have been queued using calls to send()
|
|
25
|
+
* but not yet transmitted to the network.
|
|
26
|
+
*
|
|
27
|
+
* This value resets to zero once all queued data has been sent.
|
|
28
|
+
* This value does not reset to zero when the connection is closed;
|
|
29
|
+
* if you keep calling send(), this will continue to climb.
|
|
30
|
+
*/
|
|
31
|
+
readonly bufferedAmount: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The type of binary data being transmitted over the connection.
|
|
35
|
+
*/
|
|
36
|
+
readonly binaryType: BinaryType;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The Websocket constructor returns a newly created WebSocket object.
|
|
40
|
+
*
|
|
41
|
+
* @param url - The URL to which to connect; this should be the URL to which the WebSocket server will respond.
|
|
42
|
+
*/
|
|
43
|
+
constructor(url: string);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Enqueues data to be transmitted to the server over the WebSocket connection.
|
|
47
|
+
*
|
|
48
|
+
* @param data - the data to send to the server
|
|
49
|
+
*/
|
|
50
|
+
send(data: string | ArrayBuffer): void;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Bind event names to event handlers to be executed when their
|
|
54
|
+
* respective event is received by the server.
|
|
55
|
+
*
|
|
56
|
+
* @param event - the event to listen for
|
|
57
|
+
* @param listener - the callback to invoke when the event is emitted
|
|
58
|
+
*/
|
|
59
|
+
addEventListener(event: EventName, listener: (message: MessageEvent) => void): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Closes the WebSocket connection or connection attempt, if any.
|
|
63
|
+
*/
|
|
64
|
+
close(): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ReadyState describes the possible states of a WebSocket connection.
|
|
69
|
+
*/
|
|
70
|
+
export enum ReadyState {
|
|
71
|
+
/**
|
|
72
|
+
* Socket has been created. The connection is not yet open.
|
|
73
|
+
*/
|
|
74
|
+
Connecting = 0,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The connection is open and ready to communicate.
|
|
78
|
+
*/
|
|
79
|
+
Open = 1,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The connection is in the process of closing.
|
|
83
|
+
*/
|
|
84
|
+
Closing = 2,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The connection is closed or couldn't be opened.
|
|
88
|
+
*/
|
|
89
|
+
Closed = 3,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Type alias describe the types of binary data that can be
|
|
94
|
+
* transmitted over a Websocket connection.
|
|
95
|
+
*/
|
|
96
|
+
export type BinaryType = 'arrayBuffer';
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* EventName describes the possible events that can be emitted
|
|
100
|
+
* by a Websocket connection.
|
|
101
|
+
*/
|
|
102
|
+
export enum EventName {
|
|
103
|
+
/**
|
|
104
|
+
* Event fired when the connection is opened and ready to communcate.
|
|
105
|
+
*/
|
|
106
|
+
Open = 'open',
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Event fired when the connection has been closed.
|
|
110
|
+
*/
|
|
111
|
+
Close = 'close',
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Event fired when a connection has been closed due to an error.
|
|
115
|
+
*/
|
|
116
|
+
Error = 'error',
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Event fired when a message has been received from the server.
|
|
120
|
+
*/
|
|
121
|
+
Message = 'message',
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* MessageEvent is a simple class that holds the data of a message received from the server.
|
|
126
|
+
*/
|
|
127
|
+
export interface MessageEvent {
|
|
128
|
+
/**
|
|
129
|
+
* The data sent by the message emitter.
|
|
130
|
+
*/
|
|
131
|
+
data: string | ArrayBuffer;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* the type of the event.
|
|
135
|
+
*/
|
|
136
|
+
type: MessageType;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The time when the message was received.
|
|
140
|
+
*/
|
|
141
|
+
time: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* WebSocket message types, as defined in RFC 6455, section 11.8.
|
|
146
|
+
*/
|
|
147
|
+
export enum MessageType {
|
|
148
|
+
/**
|
|
149
|
+
* The message is a text message. The text message payload is
|
|
150
|
+
* interpreted as UTF-8 encodedtext data.
|
|
151
|
+
*/
|
|
152
|
+
Text = 1,
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The message is a binary message.
|
|
156
|
+
*/
|
|
157
|
+
Binary = 2,
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The message is a close control message. The optional message
|
|
161
|
+
* payload contains a numeric code and a text reason.
|
|
162
|
+
*/
|
|
163
|
+
Close = 8,
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The message is a ping control message. The optional message
|
|
167
|
+
* payload is UTF-8 encoded text.
|
|
168
|
+
*/
|
|
169
|
+
PingMessage = 9,
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The message is a pong control message. The optional message
|
|
173
|
+
* payload is UTF-8 encoded text.
|
|
174
|
+
*/
|
|
175
|
+
PongMessage = 10,
|
|
176
|
+
}
|
k6/index.d.ts
CHANGED
k6/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/k6",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.1",
|
|
4
4
|
"description": "TypeScript definitions for k6",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
},
|
|
51
51
|
"scripts": {},
|
|
52
52
|
"dependencies": {},
|
|
53
|
-
"typesPublisherContentHash": "
|
|
53
|
+
"typesPublisherContentHash": "a50052e283279ba370df2b7199491d32ef165fc6be88428aabf4df78fb04e768",
|
|
54
54
|
"typeScriptVersion": "4.1"
|
|
55
55
|
}
|