From ec54d87b5039e9ed935029243e3830595145cf15 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Mon, 22 Jun 2020 18:23:33 -0700 Subject: [PATCH] [Event Hubs] Run formatter --- .../src/eventHubConsumerClientModels.ts | 2 +- .../event-hubs/src/eventHubProducerClient.ts | 32 +++++++++---------- sdk/eventhub/event-hubs/src/eventHubSender.ts | 4 ++- sdk/eventhub/event-hubs/src/models/private.ts | 2 +- sdk/eventhub/event-hubs/src/receiver.ts | 2 +- sdk/eventhub/event-hubs/test/client.spec.ts | 7 +++- sdk/eventhub/event-hubs/test/misc.spec.ts | 2 +- .../event-hubs/test/node/disconnects.spec.ts | 12 +++++-- sdk/eventhub/event-hubs/test/sender.spec.ts | 4 +-- 9 files changed, 40 insertions(+), 27 deletions(-) diff --git a/sdk/eventhub/event-hubs/src/eventHubConsumerClientModels.ts b/sdk/eventhub/event-hubs/src/eventHubConsumerClientModels.ts index 90aad9f221dd..ca51306d3614 100644 --- a/sdk/eventhub/event-hubs/src/eventHubConsumerClientModels.ts +++ b/sdk/eventhub/event-hubs/src/eventHubConsumerClientModels.ts @@ -117,7 +117,7 @@ export interface SubscriptionEventHandlers { * The `updateCheckpoint()` method on the context can be used to update checkpoints in the `CheckpointStore` * (if one was provided to the client). Use this in frequent intervals to mark events that have been processed * so that the client can restart from such checkpoints in the event of a restart or error recovery. - * + * * Note: It is possible for received events to be an empty array. * This can happen if there are no new events to receive * in the `maxWaitTimeInSeconds`, which is defaulted to 60 seconds. diff --git a/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts b/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts index 69d4fbf280e7..5ef3d55c39f5 100644 --- a/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts +++ b/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts @@ -9,8 +9,8 @@ import { instrumentEventData, TRACEPARENT_PROPERTY } from "./diagnostics/instrum import { createMessageSpan } from "./diagnostics/messageSpan"; import { EventData } from "./eventData"; import { EventDataBatch, EventDataBatchImpl, isEventDataBatch } from "./eventDataBatch"; -import { EventHubSender } from './eventHubSender'; -import { logErrorStackTrace, logger } from './log'; +import { EventHubSender } from "./eventHubSender"; +import { logErrorStackTrace, logger } from "./log"; import { EventHubProperties, PartitionProperties } from "./managementClient"; import { CreateBatchOptions, @@ -178,9 +178,7 @@ export class EventHubProducerClient { const error = new Error( `Max message size (${options.maxSizeInBytes} bytes) is greater than maximum message size (${maxMessageSize} bytes) on the AMQP sender link.` ); - logger.warning( - `[${this._context.connectionId}] ${error.message}` - ); + logger.warning(`[${this._context.connectionId}] ${error.message}`); logErrorStackTrace(error); throw error; } @@ -236,7 +234,7 @@ export class EventHubProducerClient { // link message span contexts let spanContextsToLink: SpanContext[] = []; - + if (isEventDataBatch(batch)) { // For batches, partitionId and partitionKey would be set on the batch. partitionId = batch.partitionId; @@ -283,10 +281,10 @@ export class EventHubProducerClient { } if (partitionId != undefined) { - partitionId = String(partitionId) + partitionId = String(partitionId); } if (partitionKey != undefined) { - partitionKey = String(partitionKey) + partitionKey = String(partitionKey); } let sender = this._sendersMap.get(partitionId || ""); @@ -342,9 +340,7 @@ export class EventHubProducerClient { * @throws Error if the underlying connection has been closed, create a new EventHubProducerClient. * @throws AbortError if the operation is cancelled via the abortSignal. */ - getEventHubProperties( - options: GetEventHubPropertiesOptions = {} - ): Promise { + getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise { return this._context.managementSession!.getEventHubProperties({ ...options, retryOptions: this._clientOptions.retryOptions @@ -360,12 +356,14 @@ export class EventHubProducerClient { * @throws AbortError if the operation is cancelled via the abortSignal. */ getPartitionIds(options: GetPartitionIdsOptions = {}): Promise> { - return this._context.managementSession!.getEventHubProperties({ - ...options, - retryOptions: this._clientOptions.retryOptions - }).then(eventHubProperties => { - return eventHubProperties.partitionIds; - }); + return this._context + .managementSession!.getEventHubProperties({ + ...options, + retryOptions: this._clientOptions.retryOptions + }) + .then((eventHubProperties) => { + return eventHubProperties.partitionIds; + }); } /** diff --git a/sdk/eventhub/event-hubs/src/eventHubSender.ts b/sdk/eventhub/event-hubs/src/eventHubSender.ts index 5ef7ac5ddbef..389496fbc0c1 100644 --- a/sdk/eventhub/event-hubs/src/eventHubSender.ts +++ b/sdk/eventhub/event-hubs/src/eventHubSender.ts @@ -306,7 +306,9 @@ export class EventHubSender extends LinkEntity { let encodedBatchMessage: Buffer | undefined; if (isEventDataBatch(events)) { if (events.count === 0) { - logger.info(`[${this._context.connectionId}] Empty batch was passsed. No events to send.`); + logger.info( + `[${this._context.connectionId}] Empty batch was passsed. No events to send.` + ); return; } encodedBatchMessage = events._generateMessage(); diff --git a/sdk/eventhub/event-hubs/src/models/private.ts b/sdk/eventhub/event-hubs/src/models/private.ts index 384b6c7d3250..af05c2e35f2d 100644 --- a/sdk/eventhub/event-hubs/src/models/private.ts +++ b/sdk/eventhub/event-hubs/src/models/private.ts @@ -127,4 +127,4 @@ export interface EventHubConsumerOptions { * against periodically making requests for partition properties using the Event Hub client. */ trackLastEnqueuedEventProperties?: boolean; -} \ No newline at end of file +} diff --git a/sdk/eventhub/event-hubs/src/receiver.ts b/sdk/eventhub/event-hubs/src/receiver.ts index abdda13d96f7..cd57087a8aa1 100644 --- a/sdk/eventhub/event-hubs/src/receiver.ts +++ b/sdk/eventhub/event-hubs/src/receiver.ts @@ -325,4 +325,4 @@ export class EventHubConsumer { throw error; } } -} \ No newline at end of file +} diff --git a/sdk/eventhub/event-hubs/test/client.spec.ts b/sdk/eventhub/event-hubs/test/client.spec.ts index 122f6cecab8a..48f3c7d7c242 100644 --- a/sdk/eventhub/event-hubs/test/client.spec.ts +++ b/sdk/eventhub/event-hubs/test/client.spec.ts @@ -10,7 +10,12 @@ import chaiString from "chai-string"; chai.use(chaiString); import debugModule from "debug"; const debug = debugModule("azure:event-hubs:client-spec"); -import { TokenCredential, EventHubProducerClient, EventHubConsumerClient, Subscription } from "../src"; +import { + TokenCredential, + EventHubProducerClient, + EventHubConsumerClient, + Subscription +} from "../src"; import { packageJsonInfo } from "../src/util/constants"; import { EnvVarKeys, getEnvVars, isNode } from "./utils/testUtils"; import { MessagingError } from "@azure/core-amqp"; diff --git a/sdk/eventhub/event-hubs/test/misc.spec.ts b/sdk/eventhub/event-hubs/test/misc.spec.ts index 19b0cd73cac6..952f6a478355 100644 --- a/sdk/eventhub/event-hubs/test/misc.spec.ts +++ b/sdk/eventhub/event-hubs/test/misc.spec.ts @@ -76,7 +76,7 @@ describe("Misc tests", function(): void { const msgBody = Buffer.from(msgString); const obj: EventData = { body: msgBody }; debug(`Partition ${partitionId} has last message with offset ${lastEnqueuedOffset}.`); - debug("Sending one message with %d bytes.", bodysize); + debug("Sending one message with %d bytes.", bodysize); await producerClient.sendBatch([obj], { partitionId }); debug("Successfully sent the large message."); diff --git a/sdk/eventhub/event-hubs/test/node/disconnects.spec.ts b/sdk/eventhub/event-hubs/test/node/disconnects.spec.ts index 827d94ee4228..60c68fd086ca 100644 --- a/sdk/eventhub/event-hubs/test/node/disconnects.spec.ts +++ b/sdk/eventhub/event-hubs/test/node/disconnects.spec.ts @@ -27,7 +27,11 @@ describe("disconnected", function() { describe("EventHubConsumerClient", function() { it("runtimeInfo work after disconnect", async () => { - const client = new EventHubConsumerClient(EventHubConsumerClient.defaultConsumerGroupName, service.connectionString, service.path); + const client = new EventHubConsumerClient( + EventHubConsumerClient.defaultConsumerGroupName, + service.connectionString, + service.path + ); const clientConnectionContext = client["_context"]; await client.getPartitionIds({}); @@ -46,7 +50,11 @@ describe("disconnected", function() { }); it("should receive after a disconnect", async () => { - const client = new EventHubConsumerClient(EventHubConsumerClient.defaultConsumerGroupName, service.connectionString, service.path); + const client = new EventHubConsumerClient( + EventHubConsumerClient.defaultConsumerGroupName, + service.connectionString, + service.path + ); const partitionId = "0"; const partitionProperties = await client.getPartitionProperties(partitionId); const clientConnectionContext = client["_context"]; diff --git a/sdk/eventhub/event-hubs/test/sender.spec.ts b/sdk/eventhub/event-hubs/test/sender.spec.ts index 90dc0ef3785e..04260cc55c45 100644 --- a/sdk/eventhub/event-hubs/test/sender.spec.ts +++ b/sdk/eventhub/event-hubs/test/sender.spec.ts @@ -116,7 +116,7 @@ describe("EventHub Sender", function(): void { it("maxSizeInBytes is set as expected", async () => { const batch = await producerClient.createBatch({ maxSizeInBytes: 30 }); should.equal(batch.maxSizeInBytes, 30); - }) + }); it("should be sent successfully", async function(): Promise { const list = ["Albert", `${Buffer.from("Mike".repeat(1300000))}`, "Marie"]; @@ -174,7 +174,7 @@ describe("EventHub Sender", function(): void { batch.maxSizeInBytes.should.be.gt(0); batch.tryAdd({ body: list[0] }).should.be.ok; - batch.tryAdd({ body: list[1] }).should.be.ok; + batch.tryAdd({ body: list[1] }).should.be.ok; const { subscriptionEventHandler,