I have v22.10.2.0 of EventStoreDB:and v5.0.1 of @eventstore/db-client for nodejs is installed. Following is my code. The idea is to perform a load test by appending 1000 messages each second.
import { EventStoreDBClient } from "@eventstore/db-client";
import log from "node-file-logger";
import { jsonEvent } from "@eventstore/db-client";
import { v4 as uuid } from 'uuid';
const eventStoreClient = EventStoreDBClient.connectionString`esdb://localhost:2111,localhost:2112,localhost:2113?tls=false`;
const sendEvent = async function (event) {
try {
let sent = await eventStoreClient.appendToStream(event.stream, event.event);
sent = {
...sent,
nextExpectedRevision: sent.nextExpectedRevision.toString(),
position: {
commit: sent.position.commit.toString(),
prepare: sent.position.prepare.toString()
}
}
log.Info(sent)
return 0;
} catch (error) {
log.Error("--------------------------------ERROR EVENT---------------------------------------");
log.Error(event);
log.Error(error);
log.Error("----------------------------------------------------------------------------------");
sendEvent(event);
return 0;
}
}
const payload = {
// 5kb test payload
}
const generateTestEvent = () => {
return {
stream: "LoadTestStream",
event: jsonEvent({
type: "LoadTest",
data: {
entityId: uuid(),
...payload
},
})
};
};
// Generate 1000 events per second
setInterval(function () {
for (let i = 1; i <= 1000; i++) {
const randomEvent = generateTestEvent();
sendEvent(randomEvent);
}
}, 1000);
When the execution is started, the code works fine and all event append successfully. But after the deaultDeadline
limit passes, the code throws a deadline-exceeded
exception. I tried overriding the defaultDeadline
value but the behavior didn’t change. All events append successfully until the specified deadline passes and after that, the same deadline-exceeded
exception is thrown for each event. I have the following questions:
- How can I set infinite deadline except specifying a very large integer as the deadline?
- As I am not appending event in batches. Shouldn’t the deadline reset after every append?
- Anything that I am missing and can be helpful to me.