Skip to content

Commit

Permalink
[Event Hubs] Fix remaining lint errors (#13882)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a authored Feb 19, 2021
1 parent 391dd59 commit b361034
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions sdk/eventhub/event-hubs/src/eventhubConnectionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface EventHubConnectionConfig extends ConnectionConfig {
* different entities.
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-redeclare -- renaming constant would be a breaking change.
export const EventHubConnectionConfig = {
/**
* Creates the connection config.
Expand Down
28 changes: 14 additions & 14 deletions sdk/eventhub/event-hubs/test/perf/track-2/receive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/*
# Overview
Measures the maximum throughput of `receiver.receive()` in package `@azure/event-hubs`.
Expand Down Expand Up @@ -48,18 +51,22 @@ async function main(): Promise<void> {
await sendBatch(numberOfEvents, partitionIds, eventBodySize);
const writeResultsPromise = WriteResults(numberOfEvents);

await RunTest(connectionString, eventHubName, maxBatchSize, numberOfEvents);
await RunTest(maxBatchSize, numberOfEvents);
await writeResultsPromise;
}

async function sendBatch(numberOfEvents: number, partitionIds: string[], eventBodySize: number) {
async function sendBatch(
numberOfEvents: number,
partitionIds: string[],
eventBodySize: number
): Promise<void> {
const _payload = Buffer.alloc(eventBodySize);
const producer = new EventHubProducerClient(connectionString, eventHubName);
const numberOfPartitions = partitionIds.length;
const numberOfEventsPerPartition = Math.ceil(numberOfEvents / numberOfPartitions);

for (let partitionId of partitionIds) {
let batch = await producer.createBatch({ partitionId });
for (const partitionId of partitionIds) {
const batch = await producer.createBatch({ partitionId });
let numberOfEventsSent = 0;
// add events to our batch
while (numberOfEventsSent <= numberOfEventsPerPartition) {
Expand All @@ -75,23 +82,16 @@ async function sendBatch(numberOfEvents: number, partitionIds: string[], eventBo
await producer.close();
}

async function RunTest(
connectionString: string,
eventHubName: string,
maxBatchSize: number,
messages: number
): Promise<void> {
async function RunTest(maxBatchSize: number, messages: number): Promise<void> {
const consumerClient = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName);

const processEvents = async (events: EventData[]) => {
const processEvents = async (events: EventData[]): Promise<void> => {
_messages = _messages + events.length;
for (const _ of events) {
}
if (_messages === messages) {
await consumerClient.close();
}
};
const processError = async (err: Error, context: PartitionContext) => {
const processError = async (err: Error, context: PartitionContext): Promise<void> => {
console.log(`Error on partition "${context.partitionId}": ${err}`);
};

Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/test/perf/track-2/send.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SendTest extends PerfStressTest<SendTestOptions> {
this.eventBatch = new Array(this.parsedOptions.numberOfEvents.value!).fill(event);
}

public async globalCleanup() {
public async globalCleanup(): Promise<void> {
await this.producer.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ describe("EventHubConsumerClient", () => {
let subscription: Subscription | undefined;
await new Promise<void>((resolve, reject) => {
subscription = consumerClient.subscribe(
// @ts-expect-error
// @ts-expect-error number for partitionId should work even if type is string
0,
{
processEvents: async () => {
Expand Down Expand Up @@ -1248,7 +1248,9 @@ describe("EventHubConsumerClient", () => {
let subscription: Subscription | undefined;
const caughtErr = await new Promise<Error | MessagingError>((resolve) => {
subscription = badConsumerClient.subscribe({
processEvents: async () => {},
processEvents: async () => {
/** Nothing to do here */
},
processError: async (err) => {
resolve(err);
}
Expand All @@ -1267,7 +1269,9 @@ describe("EventHubConsumerClient", () => {
let subscription: Subscription | undefined;
const caughtErr = await new Promise<Error | MessagingError>((resolve) => {
subscription = consumerClient.subscribe("boo", {
processEvents: async () => {},
processEvents: async () => {
/** Nothing to do here */
},
processError: async (err) => {
resolve(err);
}
Expand Down

0 comments on commit b361034

Please sign in to comment.