Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Hubs] Fix remaining lint errors #13882

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I was going crazy because I know I fixed these:
https://github.com/Azure/azure-sdk-for-js/pull/13285/files#diff-55397d6ab644a9c4b90887b375e3a6095bea4e388a28f8a3fe3649082daf5539R66

Must have gotten lost in some merge conflicts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe

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