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

Commit

Permalink
Merge pull request #82 from amarzavery/sendpart
Browse files Browse the repository at this point in the history
minor updates to the EH client and EPH
  • Loading branch information
amarzavery authored Jun 14, 2018
2 parents 03d6d56 + c72ff64 commit a5e8173
Show file tree
Hide file tree
Showing 31 changed files with 478 additions and 448 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: node_js

node_js:
- "8"
before_install:

before_install:
- cd client

script:
script:
- npm test
4 changes: 4 additions & 0 deletions client/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2018-06-13 0.2.3
- Minor doc fixes and sample updates.
- Add a listener for the disconnected event after opening the connection.

## 2018-05-23 0.2.2
- Fixed the partitionkey issue while sending events. #73.
- Bumped the minimum dependency on rhea to 0.2.13. This gives us type definitions for rhea.
Expand Down
2 changes: 2 additions & 0 deletions client/examples/batchReceive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient, EventData } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "EVENTHUB_CONNECTION_STRING";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/batchSendReceive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient, EventData, EventPosition, OnMessage, OnError, EventHubsError } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "EVENTHUB_CONNECTION_STRING";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/createEpochReceiver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient, OnError, EventHubsError, OnMessage, delay } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "EVENTHUB_CONNECTION_STRING";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/getHubRuntimeInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "EVENTHUB_CONNECTION_STRING";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/iotGetHubRuntimeInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "IOTHUB_CONNECTION_STRING";
const str = process.env[connectionString] || "";
Expand Down
5 changes: 3 additions & 2 deletions client/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"private": true,
"version": "0.0.1",
"dependencies": {
"azure-event-hubs": "*"
"azure-event-hubs": "*",
"dotenv": "^5.0.1"
},
"scripts": {
"build": "tsc -p ./tsconfig.json --baseUrl ../"
}
}
}
2 changes: 2 additions & 0 deletions client/examples/sendReceiveWithInteractiveAuth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { EventHubClient, aadEventHubsAudience, EventPosition } from "azure-event-hubs";
import * as msrestAzure from "ms-rest-azure";
import * as dotenv from "dotenv";
dotenv.config();

const endpoint = "ENDPOINT";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/sendReceiveWithSPAuth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { EventHubClient, aadEventHubsAudience, EventPosition } from "azure-event-hubs";
import * as msrestAzure from "ms-rest-azure";
import * as dotenv from "dotenv";
dotenv.config();

const endpoint = "ENDPOINT";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/simpleSendReceive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient, EventPosition, OnMessage, OnError, EventHubsError, delay } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "EVENTHUB_CONNECTION_STRING";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/simpleSender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient, EventData } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "EVENTHUB_CONNECTION_STRING";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/streamingReceive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { EventHubClient, EventPosition, OnMessage, OnError, EventHubsError, ReceiveOptions } from "azure-event-hubs";
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = "EVENTHUB_CONNECTION_STRING";
const entityPath = "EVENTHUB_NAME";
Expand Down
2 changes: 2 additions & 0 deletions client/examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"moduleResolution": "node",
"noImplicitReturns": true,
"outDir": "js",
"importHelpers": true,
"allowJs": false,
"noUnusedLocals": true,
"strict": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
"declaration": false,
"baseUrl": "../",
"paths": {
Expand Down
2 changes: 1 addition & 1 deletion client/lib/batchingReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class BatchingReceiver extends EventHubReceiver {
* Instantiate a new receiver from the AMQP `Receiver`. Used by `EventHubClient`.
*
* @constructor
* @param {EventHubClient} client The EventHub client.
* @param {ConnectionContext} context The connection context.
* @param {string} partitionId Partition ID from which to receive.
* @param {ReceiveOptions} [options] Options for how you'd like to connect.
* @param {string} [options.consumerGroup] Consumer group from which to receive.
Expand Down
2 changes: 1 addition & 1 deletion client/lib/eventHubClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class EventHubClient {

/**
* Starts the receiver by establishing an AMQP session and an AMQP receiver link on the session. Messages will be passed to
* the provided onMessage handler and error will be passes to the provided onError handler.
* the provided onMessage handler and error will be passed to the provided onError handler.
*
* @param {string|number} partitionId Partition ID from which to receive.
* @param {OnMessage} onMessage The message handler to receive event data objects.
Expand Down
12 changes: 7 additions & 5 deletions client/lib/eventHubSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { ClientEntity } from "./clientEntity";
const debug = debugModule("azure:event-hubs:sender");

/**
* Instantiates a new sender from the AMQP `Sender`. Used by `EventHubClient`.
*
* @param {any} session - The amqp session on which the amqp sender link was created.
* @param {any} sender - The amqp sender link.
* @constructor
* Describes the EventHubSender that will send event data to EventHub.
* @class EventHubSender
*/
export class EventHubSender extends ClientEntity {
/**
* @property {string} senderLock The unqiue lock name per connection that is used to acquire the
* lock for establishing a sender link by an entity on that connection.
* @readonly
*/
readonly senderLock: string = `sender-${uuid()}`;
/**
* @property {any} [_sender] The AMQP sender link.
Expand Down
11 changes: 11 additions & 0 deletions client/lib/rhea-promise/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ export function connect(options?: rhea.ConnectionOptions): Promise<rhea.Connecti
connection.removeListener("connection_open", onOpen);
connection.removeListener("connection_close", onClose);
connection.removeListener("disconnected", onClose);
connection.removeListener("disconnected", onTransportClose);
}

function onOpen(context: rhea.EventContext): void {
removeListeners(connection);
connection.once("disconnected", onTransportClose);
process.nextTick(() => {
debug("Resolving the promise with amqp connection.");
resolve(connection);
Expand All @@ -43,6 +45,15 @@ export function connect(options?: rhea.ConnectionOptions): Promise<rhea.Connecti
reject(context.connection.error);
}

function onTransportClose(context: rhea.EventContext): void {
debug(`Error occurred on the amqp connection.`, context.connection.error);
closeConnection(context.connection).then(() => {
context.connection = undefined as any;
}).catch((err: Error) => {
debug(`Error occurred while closing amqp connection.`, err);
});
}

connection.once("connection_open", onOpen);
connection.once("connection_close", onClose);
connection.once("disconnected", onClose);
Expand Down
2 changes: 1 addition & 1 deletion client/lib/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ export const defaultPrefetchCount = 1000;
export const reconnectLimit = 100;
export const packageJsonInfo = {
name: "azure-event-hubs-js",
version: "0.2.0"
version: "0.2.3"
};
3 changes: 2 additions & 1 deletion client/lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ export class Timeout {
private _timer?: NodeJS.Timer;

set<T>(t: number, value?: T): Promise<T> {
const self = this;
return new Promise<T>((resolve) => {
this._timer = setTimeout(() => resolve(value), t);
self._timer = setTimeout(() => resolve(value), t);
});
}

Expand Down
Loading

0 comments on commit a5e8173

Please sign in to comment.