Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit dff1079

Browse files
authored
Merge pull request #166 from amarzavery/component
[EPH] use EventHubConnectionConfig and remove dependency on amp-common and rhea-promise
2 parents edfdffb + ba99925 commit dff1079

13 files changed

+75
-56
lines changed

.travis.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
language: node_js
22

33
node_js:
4+
- "6"
45
- "8"
56
- "10"
67

7-
before_install:
8-
- cd client
9-
8+
env:
9+
- TEST_DIR=client
10+
- TEST_DIR=processor
1011
script:
11-
- npm test
12+
- cd $TEST_DIR && npm install && npm test

processor/changelog.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2018-10-05 1.0.6
2+
- Remove `@azure/amqp-common` and `rhea-promise` as dependencies, since we use very little from
3+
those libraries and there is a risk of having two instances of rhea in the dependency chain which
4+
can cause problems while encoding types for filters.
5+
- `HostContext.connectionConfig` is now of type `EventHubConnectionConfig`.
6+
- Minimum dependency on `@azure/event-hubs: "^1.0.6"`.
7+
18
## 2018-10-01 1.0.5
29
- Bumping minimum version of @azure/event-hubs to "1.0.5".
310
- Taking a dependency on "@azure/amqp-common" for reusing the common parts.

processor/lib/azureBlob.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { BlobService, CreateContainerResult } from "./blobService";
55
import { BlobService as StorageBlobService } from "azure-storage";
6-
import { Dictionary } from "@azure/amqp-common";
6+
import { Dictionary } from "@azure/event-hubs";
77

88
/**
99
* @ignore

processor/lib/blobService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
import { Dictionary } from "@azure/event-hubs";
45
import { createBlobService, BlobService as StorageBlobService, ServiceResponse } from "azure-storage";
56
import * as log from "./log";
67
import { validateType, getStorageError } from "./util/utils";
78
import { defaultMaximumExecutionTimeInMs } from "./util/constants";
8-
import { Dictionary } from "@azure/amqp-common";
99
const path = require("path-browserify");
1010
/**
1111
* @ignore

processor/lib/hostContext.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import * as uuid from "uuid/v4";
55
import {
6-
EventHubClient, EventPosition, TokenProvider, DefaultDataTransformer,
7-
EventHubRuntimeInformation, EventHubPartitionRuntimeInformation, ConnectionConfig
6+
EventHubClient, EventPosition, TokenProvider, DefaultDataTransformer, Dictionary,
7+
EventHubRuntimeInformation, EventHubPartitionRuntimeInformation, EventHubConnectionConfig
88
} from "@azure/event-hubs";
9-
import { Constants, Dictionary, getNewAsyncLock, AsyncLock } from "@azure/amqp-common";
9+
import * as AsyncLock from "async-lock";
1010
import { LeaseManager } from "./leaseManager";
1111
import { PumpManager } from "./pumpManager";
1212
import { PartitionManager } from "./partitionManager";
@@ -25,7 +25,7 @@ import {
2525
import {
2626
maxLeaseDurationInSeconds, minLeaseDurationInSeconds, defaultLeaseRenewIntervalInSeconds,
2727
defaultLeaseDurationInSeconds, defaultStartupScanDelayInSeconds, packageInfo, userAgentPrefix,
28-
defaultFastScanIntervalInSeconds, defaultSlowScanIntervalInSeconds
28+
defaultFastScanIntervalInSeconds, defaultSlowScanIntervalInSeconds, defaultConsumerGroup
2929
} from "./util/constants";
3030

3131
/**
@@ -39,7 +39,7 @@ export interface BaseHostContext {
3939
eventHubPath: string;
4040
storageContainerName?: string;
4141
eventHubConnectionString: string;
42-
connectionConfig: ConnectionConfig;
42+
connectionConfig: EventHubConnectionConfig;
4343
onEphError: OnEphError;
4444
leaseRenewInterval: number;
4545
leaseDuration: number;
@@ -148,10 +148,10 @@ export namespace HostContext {
148148
const onEphErrorFunc: OnEphError = () => {
149149
// do nothing
150150
};
151-
const config = ConnectionConfig.create(options.eventHubConnectionString!, options.eventHubPath);
151+
const config = EventHubConnectionConfig.create(options.eventHubConnectionString!, options.eventHubPath);
152152

153153
// set defaults
154-
if (!options.consumerGroup) options.consumerGroup = Constants.defaultConsumerGroup;
154+
if (!options.consumerGroup) options.consumerGroup = defaultConsumerGroup;
155155
if (!options.eventHubPath) options.eventHubPath = config.entityPath;
156156
if (!options.leaseRenewInterval) options.leaseRenewInterval = defaultLeaseRenewIntervalInSeconds;
157157
if (!options.leaseDuration) options.leaseDuration = defaultLeaseDurationInSeconds;
@@ -178,7 +178,7 @@ export namespace HostContext {
178178

179179
const context: BaseHostContext = {
180180
hostName: hostName,
181-
checkpointLock: getNewAsyncLock({ maxPending: 100000 }),
181+
checkpointLock: new AsyncLock({ maxPending: 100000 }),
182182
checkpointLockId: `checkpoint-${uuid()}`,
183183
eventHubConnectionString: options.eventHubConnectionString!,
184184
connectionConfig: config,

processor/lib/partitionScanner.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
import { randomNumberFromInterval } from "@azure/amqp-common";
4+
import { randomNumberFromInterval } from "./util/utils";
55
import { HostContextWithPumpManager } from "./hostContext";
66
import { CompleteLease } from "./completeLease";
77
import { BaseLease } from "./baseLease";

processor/lib/util/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const leaseLost = "leaselost";
1616
export const leaseIdMismatchWithLeaseOperation = "leaseidmismatchwithleaseoperation";
1717
export const leaseIdMismatchWithBlobOperation = "leaseidmismatchwithbloboperation";
1818
export const userAgentPrefix = "/js-event-processor-host";
19+
export const defaultConsumerGroup = "$default";
1920
export const packageInfo = {
2021
name: "@azure/event-processor-host",
2122
version: "1.0.5"

processor/lib/util/utils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import * as log from "../log";
55
import { StorageError } from "azure-storage";
66
import { EPHDiagnosticInfo } from "../modelTypes";
77

8+
/**
9+
* Generates a random number between the given interval
10+
* @param {number} min Min number of the range (inclusive).
11+
* @param {number} max Max number of the range (inclusive).
12+
*/
13+
export function randomNumberFromInterval(min: number, max: number): number {
14+
return Math.floor(Math.random() * (max - min + 1) + min);
15+
}
16+
817
/**
918
* Validates the type and requiredness of a given parameter.
1019
* @param paramName The name of the parameter.

processor/package-lock.json

+26-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

processor/package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
{
22
"name": "@azure/event-processor-host",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Azure Event Processor Host (Event Hubs) SDK for JS.",
55
"author": "Microsoft Corporation",
66
"license": "MIT",
77
"main": "./dist/lib/index.js",
88
"types": "./typings/lib/index.d.ts",
99
"dependencies": {
10-
"@azure/event-hubs": "^1.0.5",
11-
"@azure/amqp-common": "^0.1.3",
12-
"rhea-promise": "^0.1.6",
10+
"@azure/event-hubs": "^1.0.6",
1311
"azure-storage": "^2.10.1",
1412
"async-lock": "^1.1.3",
1513
"debug": "^3.1.0",
1614
"ms-rest-azure": "^2.5.7",
15+
"path-browserify": "^1.0.0",
1716
"tslib": "^1.9.3",
18-
"uuid": "^3.3.2",
19-
"path-browserify": "^1.0.0"
17+
"uuid": "^3.3.2"
2018
},
2119
"devDependencies": {
2220
"@types/async-lock": "^1.1.0",
23-
"@types/uuid": "^3.4.3",
24-
"@types/debug": "^0.0.30",
25-
"@types/node": "^8.0.37",
2621
"@types/chai": "^4.1.4",
2722
"@types/chai-as-promised": "^7.1.0",
23+
"@types/debug": "^0.0.30",
24+
"@types/dotenv": "^4.0.3",
2825
"@types/mocha": "^5.2.5",
26+
"@types/node": "^8.0.37",
27+
"@types/uuid": "^3.4.3",
2928
"chai": "^4.1.2",
3029
"chai-as-promised": "^7.1.1",
30+
"dotenv": "^5.0.1",
3131
"mocha": "^5.2.0",
32+
"rimraf": "^2.6.2",
3233
"ts-node": "^7.0.0",
3334
"tslint": "^5.11.0",
34-
"typescript": "^2.9.2",
35-
"dotenv": "^5.0.1",
36-
"@types/dotenv": "^4.0.3"
35+
"typescript": "^2.9.2"
3736
},
3837
"scripts": {
3938
"tslint": "tslint -p . -c tslint.json --exclude examples/**/*.ts --exclude tests/**/*.ts",
4039
"tsc": "tsc",
40+
"prebuild": "rimraf dist && rimraf typings",
4141
"build": "npm run tslint && npm run tsc",
4242
"test": "npm run build",
4343
"unit": "mocha -r ts-node/register -t 50000 ./tests/**/*.spec.ts --exit",
@@ -51,4 +51,4 @@
5151
"bugs": {
5252
"url": "http://github.com/Azure/azure-event-hubs-node/issues"
5353
}
54-
}
54+
}

processor/tests/eph.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ chai.use(chaiAsPromised);
99
import * as debugModule from "debug";
1010
const should = chai.should();
1111
const debug = debugModule("azure:eph:eph-spec");
12-
import { EventHubClient, EventData, EventPosition, delay } from "@azure/event-hubs";
12+
import { EventHubClient, EventData, EventPosition, delay, Dictionary } from "@azure/event-hubs";
1313
import * as dotenv from "dotenv";
1414
import { PartitionContext, OnReceivedMessage, EventProcessorHost, OnReceivedError } from "../lib";
15-
import { Dictionary } from "@azure/amqp-common";
1615
dotenv.config();
1716

1817
describe("EPH", function () {

processor/tests/iothub.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const debug = debugModule("azure:eph:iothub-spec");
1212
import {
1313
EventPosition, OnReceivedError, PartitionContext, EventData, OnReceivedMessage, EventProcessorHost
1414
} from "../lib";
15-
import { delay } from "@azure/amqp-common";
15+
import { delay } from "@azure/event-hubs";
1616
dotenv.config();
1717

1818
describe("EPH with iothub connection string", function () {

processor/tests/retry.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "mocha";
55
import * as chai from "chai";
66
import { retry, RetryConfig } from "../lib/util/utils";
77
import * as chaiAsPromised from "chai-as-promised";
8-
import { delay } from "@azure/amqp-common";
8+
import { delay } from "@azure/event-hubs";
99
chai.use(chaiAsPromised);
1010
import * as debugModule from "debug";
1111
const should = chai.should();

0 commit comments

Comments
 (0)