Skip to content

Commit

Permalink
Merge pull request Azure#166 from amarzavery/component
Browse files Browse the repository at this point in the history
[EPH] use EventHubConnectionConfig and remove dependency on amp-common and rhea-promise
  • Loading branch information
amarzavery authored Oct 5, 2018
2 parents edfdffb + ba99925 commit dff1079
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 56 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
language: node_js

node_js:
- "6"
- "8"
- "10"

before_install:
- cd client

env:
- TEST_DIR=client
- TEST_DIR=processor
script:
- npm test
- cd $TEST_DIR && npm install && npm test
7 changes: 7 additions & 0 deletions processor/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2018-10-05 1.0.6
- Remove `@azure/amqp-common` and `rhea-promise` as dependencies, since we use very little from
those libraries and there is a risk of having two instances of rhea in the dependency chain which
can cause problems while encoding types for filters.
- `HostContext.connectionConfig` is now of type `EventHubConnectionConfig`.
- Minimum dependency on `@azure/event-hubs: "^1.0.6"`.

## 2018-10-01 1.0.5
- Bumping minimum version of @azure/event-hubs to "1.0.5".
- Taking a dependency on "@azure/amqp-common" for reusing the common parts.
Expand Down
2 changes: 1 addition & 1 deletion processor/lib/azureBlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

/**
* @ignore
Expand Down
2 changes: 1 addition & 1 deletion processor/lib/blobService.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import { Dictionary } from "@azure/event-hubs";
import { createBlobService, BlobService as StorageBlobService, ServiceResponse } from "azure-storage";
import * as log from "./log";
import { validateType, getStorageError } from "./util/utils";
import { defaultMaximumExecutionTimeInMs } from "./util/constants";
import { Dictionary } from "@azure/amqp-common";
const path = require("path-browserify");
/**
* @ignore
Expand Down
16 changes: 8 additions & 8 deletions processor/lib/hostContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import * as uuid from "uuid/v4";
import {
EventHubClient, EventPosition, TokenProvider, DefaultDataTransformer,
EventHubRuntimeInformation, EventHubPartitionRuntimeInformation, ConnectionConfig
EventHubClient, EventPosition, TokenProvider, DefaultDataTransformer, Dictionary,
EventHubRuntimeInformation, EventHubPartitionRuntimeInformation, EventHubConnectionConfig
} from "@azure/event-hubs";
import { Constants, Dictionary, getNewAsyncLock, AsyncLock } from "@azure/amqp-common";
import * as AsyncLock from "async-lock";
import { LeaseManager } from "./leaseManager";
import { PumpManager } from "./pumpManager";
import { PartitionManager } from "./partitionManager";
Expand All @@ -25,7 +25,7 @@ import {
import {
maxLeaseDurationInSeconds, minLeaseDurationInSeconds, defaultLeaseRenewIntervalInSeconds,
defaultLeaseDurationInSeconds, defaultStartupScanDelayInSeconds, packageInfo, userAgentPrefix,
defaultFastScanIntervalInSeconds, defaultSlowScanIntervalInSeconds
defaultFastScanIntervalInSeconds, defaultSlowScanIntervalInSeconds, defaultConsumerGroup
} from "./util/constants";

/**
Expand All @@ -39,7 +39,7 @@ export interface BaseHostContext {
eventHubPath: string;
storageContainerName?: string;
eventHubConnectionString: string;
connectionConfig: ConnectionConfig;
connectionConfig: EventHubConnectionConfig;
onEphError: OnEphError;
leaseRenewInterval: number;
leaseDuration: number;
Expand Down Expand Up @@ -148,10 +148,10 @@ export namespace HostContext {
const onEphErrorFunc: OnEphError = () => {
// do nothing
};
const config = ConnectionConfig.create(options.eventHubConnectionString!, options.eventHubPath);
const config = EventHubConnectionConfig.create(options.eventHubConnectionString!, options.eventHubPath);

// set defaults
if (!options.consumerGroup) options.consumerGroup = Constants.defaultConsumerGroup;
if (!options.consumerGroup) options.consumerGroup = defaultConsumerGroup;
if (!options.eventHubPath) options.eventHubPath = config.entityPath;
if (!options.leaseRenewInterval) options.leaseRenewInterval = defaultLeaseRenewIntervalInSeconds;
if (!options.leaseDuration) options.leaseDuration = defaultLeaseDurationInSeconds;
Expand All @@ -178,7 +178,7 @@ export namespace HostContext {

const context: BaseHostContext = {
hostName: hostName,
checkpointLock: getNewAsyncLock({ maxPending: 100000 }),
checkpointLock: new AsyncLock({ maxPending: 100000 }),
checkpointLockId: `checkpoint-${uuid()}`,
eventHubConnectionString: options.eventHubConnectionString!,
connectionConfig: config,
Expand Down
2 changes: 1 addition & 1 deletion processor/lib/partitionScanner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import { randomNumberFromInterval } from "@azure/amqp-common";
import { randomNumberFromInterval } from "./util/utils";
import { HostContextWithPumpManager } from "./hostContext";
import { CompleteLease } from "./completeLease";
import { BaseLease } from "./baseLease";
Expand Down
1 change: 1 addition & 0 deletions processor/lib/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const leaseLost = "leaselost";
export const leaseIdMismatchWithLeaseOperation = "leaseidmismatchwithleaseoperation";
export const leaseIdMismatchWithBlobOperation = "leaseidmismatchwithbloboperation";
export const userAgentPrefix = "/js-event-processor-host";
export const defaultConsumerGroup = "$default";
export const packageInfo = {
name: "@azure/event-processor-host",
version: "1.0.5"
Expand Down
9 changes: 9 additions & 0 deletions processor/lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import * as log from "../log";
import { StorageError } from "azure-storage";
import { EPHDiagnosticInfo } from "../modelTypes";

/**
* Generates a random number between the given interval
* @param {number} min Min number of the range (inclusive).
* @param {number} max Max number of the range (inclusive).
*/
export function randomNumberFromInterval(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1) + min);
}

/**
* Validates the type and requiredness of a given parameter.
* @param paramName The name of the parameter.
Expand Down
50 changes: 26 additions & 24 deletions processor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions processor/package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
{
"name": "@azure/event-processor-host",
"version": "1.0.5",
"version": "1.0.6",
"description": "Azure Event Processor Host (Event Hubs) SDK for JS.",
"author": "Microsoft Corporation",
"license": "MIT",
"main": "./dist/lib/index.js",
"types": "./typings/lib/index.d.ts",
"dependencies": {
"@azure/event-hubs": "^1.0.5",
"@azure/amqp-common": "^0.1.3",
"rhea-promise": "^0.1.6",
"@azure/event-hubs": "^1.0.6",
"azure-storage": "^2.10.1",
"async-lock": "^1.1.3",
"debug": "^3.1.0",
"ms-rest-azure": "^2.5.7",
"path-browserify": "^1.0.0",
"tslib": "^1.9.3",
"uuid": "^3.3.2",
"path-browserify": "^1.0.0"
"uuid": "^3.3.2"
},
"devDependencies": {
"@types/async-lock": "^1.1.0",
"@types/uuid": "^3.4.3",
"@types/debug": "^0.0.30",
"@types/node": "^8.0.37",
"@types/chai": "^4.1.4",
"@types/chai-as-promised": "^7.1.0",
"@types/debug": "^0.0.30",
"@types/dotenv": "^4.0.3",
"@types/mocha": "^5.2.5",
"@types/node": "^8.0.37",
"@types/uuid": "^3.4.3",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"dotenv": "^5.0.1",
"mocha": "^5.2.0",
"rimraf": "^2.6.2",
"ts-node": "^7.0.0",
"tslint": "^5.11.0",
"typescript": "^2.9.2",
"dotenv": "^5.0.1",
"@types/dotenv": "^4.0.3"
"typescript": "^2.9.2"
},
"scripts": {
"tslint": "tslint -p . -c tslint.json --exclude examples/**/*.ts --exclude tests/**/*.ts",
"tsc": "tsc",
"prebuild": "rimraf dist && rimraf typings",
"build": "npm run tslint && npm run tsc",
"test": "npm run build",
"unit": "mocha -r ts-node/register -t 50000 ./tests/**/*.spec.ts --exit",
Expand All @@ -51,4 +51,4 @@
"bugs": {
"url": "http://github.com/Azure/azure-event-hubs-node/issues"
}
}
}
3 changes: 1 addition & 2 deletions processor/tests/eph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ chai.use(chaiAsPromised);
import * as debugModule from "debug";
const should = chai.should();
const debug = debugModule("azure:eph:eph-spec");
import { EventHubClient, EventData, EventPosition, delay } from "@azure/event-hubs";
import { EventHubClient, EventData, EventPosition, delay, Dictionary } from "@azure/event-hubs";
import * as dotenv from "dotenv";
import { PartitionContext, OnReceivedMessage, EventProcessorHost, OnReceivedError } from "../lib";
import { Dictionary } from "@azure/amqp-common";
dotenv.config();

describe("EPH", function () {
Expand Down
2 changes: 1 addition & 1 deletion processor/tests/iothub.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const debug = debugModule("azure:eph:iothub-spec");
import {
EventPosition, OnReceivedError, PartitionContext, EventData, OnReceivedMessage, EventProcessorHost
} from "../lib";
import { delay } from "@azure/amqp-common";
import { delay } from "@azure/event-hubs";
dotenv.config();

describe("EPH with iothub connection string", function () {
Expand Down
2 changes: 1 addition & 1 deletion processor/tests/retry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "mocha";
import * as chai from "chai";
import { retry, RetryConfig } from "../lib/util/utils";
import * as chaiAsPromised from "chai-as-promised";
import { delay } from "@azure/amqp-common";
import { delay } from "@azure/event-hubs";
chai.use(chaiAsPromised);
import * as debugModule from "debug";
const should = chai.should();
Expand Down

0 comments on commit dff1079

Please sign in to comment.