@ably-labs/locust 0.0.1 → 0.0.2

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.
package/README.md CHANGED
@@ -10,7 +10,7 @@ _[Ably](https://ably.com) is the platform that powers synchronized digital exper
10
10
 
11
11
  ## Quick Start
12
12
 
13
- See [example/users.js](/example/users.js) for an example of defining Locust users in JavaScript, and [example/index.js](/example/index.js) for an example program which connects to a Locust master and runs the defined users during a load test.
13
+ See [example/users.ts](/example/users.ts) for an example of defining Locust users in TypeScript, and [example/index.ts](/example/index.ts) for an example program which connects to a Locust master and runs the defined users during a load test.
14
14
 
15
15
  The example can be run by copying `example/.env.sample` to `example/.env`, setting `ABLY_API_KEY` to your Ably API key, and running [Docker Compose](https://docs.docker.com/compose/):
16
16
 
@@ -83,3 +83,15 @@ worker.register('ExampleUser', () => new User());
83
83
 
84
84
  worker.run();
85
85
  ```
86
+
87
+ ## Testing
88
+
89
+ Start an instance of Locust and run the tests:
90
+
91
+ ```
92
+ cd tests
93
+
94
+ docker compose up --build
95
+
96
+ npm test
97
+ ```
package/lib/Worker.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import winston from 'winston';
1
+ import * as winston from 'winston';
2
2
  import { Dealer } from 'zeromq';
3
3
  import { Message, MessageType } from './Message';
4
4
  import { Stats } from './Stats';
package/lib/Worker.js CHANGED
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
22
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
23
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -42,12 +61,9 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
42
61
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
43
62
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
44
63
  };
45
- var __importDefault = (this && this.__importDefault) || function (mod) {
46
- return (mod && mod.__esModule) ? mod : { "default": mod };
47
- };
48
64
  Object.defineProperty(exports, "__esModule", { value: true });
49
65
  exports.Worker = void 0;
50
- var winston_1 = __importDefault(require("winston"));
66
+ var winston = __importStar(require("winston"));
51
67
  var zeromq_1 = require("zeromq");
52
68
  var constants_1 = require("./constants");
53
69
  var Message_1 = require("./Message");
@@ -72,10 +88,10 @@ var Worker = /** @class */ (function () {
72
88
  this.userFns = {};
73
89
  this.users = {};
74
90
  this.state = "ready" /* Ready */;
75
- this.log = winston_1.default.createLogger({
76
- format: winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.json()),
91
+ this.log = winston.createLogger({
92
+ format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
77
93
  transports: [
78
- new winston_1.default.transports.Console({
94
+ new winston.transports.Console({
79
95
  level: opts.logLevel || 'info',
80
96
  }),
81
97
  ],
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * See https://github.com/locustio/locust/blob/2.4.3/locust/runners.py#L879-L886
8
8
  */
9
- export declare const PROTOCOL_VERSION = "2.4.3";
9
+ export declare const PROTOCOL_VERSION = "2.5.0";
10
10
  /**
11
11
  * The interval between successive heartbeats.
12
12
  */
package/lib/constants.js CHANGED
@@ -9,7 +9,7 @@ exports.STATS_INTERVAL = exports.HEARTBEAT_INTERVAL = exports.PROTOCOL_VERSION =
9
9
  *
10
10
  * See https://github.com/locustio/locust/blob/2.4.3/locust/runners.py#L879-L886
11
11
  */
12
- exports.PROTOCOL_VERSION = '2.4.3';
12
+ exports.PROTOCOL_VERSION = '2.5.0';
13
13
  /**
14
14
  * The interval between successive heartbeats.
15
15
  */
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@ably-labs/locust",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A JavaScript load generator for Locust.io.",
5
5
  "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
6
7
  "scripts": {
7
8
  "build": "tsc --build",
8
9
  "clean": "tsc --build --clean",
@@ -11,7 +12,7 @@
11
12
  "test": "jest"
12
13
  },
13
14
  "files": [
14
- "lib"
15
+ "lib/**/*"
15
16
  ],
16
17
  "repository": {
17
18
  "type": "git",