loopbackio / loopbackio/loopback-connector-mongodb

How to register events

Open
#734 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
186
Forks
238
Avg merge
2h 49m
Merged PRs (30d)
1

Description

I want to know how to register these events
```
["timeout",
"close",
"serverOpening",
"serverDescriptionChanged",
"serverHeartbeatStarted",
"serverHeartbeatSucceeded",
"serverHeartbeatFailed",
"serverClosed",
"topologyOpening",
"topologyClosed",
"topologyDescriptionChanged",
"joined",
"left",
"ping",
"ha",
"all",
"fullsetup",]
```
i am registering the events like this
```
client.on("connected", (event) => {
customLogger.info(
`received mongodb connected event ${JSON.stringify(event, null, 2)}`,
);
});

client.on("serverOpening", (event) => {
customLogger.info(
`received "serverOpening": ${JSON.stringify(event, null, 2)}`,
);
});

client.on("serverClosed", (event) => {
customLogger.info(
`received "serverClosed": ${JSON.stringify(event, null, 2)}`,
);
});

client.on("serverDescriptionChanged", (event) => {
customLogger.info(
`received "serverDescriptionChanged": ${JSON.stringify(
event,
null,
2,
)}`,
);
});

client.on("topologyOpening", (event) => {
customLogger.info(
`received "topologyOpening": ${JSON.stringify(event, null, 2)}`,
);
});
client.on("topologyClosed", (event) => {
customLogger.info(
`received "topologyClosed": ${JSON.stringify(event, null, 2)}`,
);
});

client.on("topologyDescriptionChanged", (event) => {
customLogger.info(
`received "topologyDescriptionChanged": ${JSON.stringify(
event,
null,
2,
)}`,
);
});

client.on("serverHeartbeatStarted", (event) => {
customLogger.info(
`received "serverHeartbeatStarted": ${JSON.stringify(event, null, 2)}`,
);
});

client.on("serverHeartbeatSucceeded", (event) => {
customLogger.info(
`received "serverHeartbeatSucceeded": ${JSON.stringify(
event,
null,
2,
)}`,
);
});
client.on("serverHeartbeatFailed", (event) => {
customLogger.info(
`received "serverHeartbeatFailed": ${JSON.stringify(event, null, 2)}`,
);
});
```
but when the connection is established only "Connected" is being triggered and not others
i assume "serverOpening" and "topologyOpening" should also get called as per there description
![image](https://github.com/loopbackio/loopback-connector-mongodb/assets/37167732/2ebb4a31-1f8c-4d7e-98ba-d746ea26e401)
![image](https://github.com/loopbackio/loopback-connector-mongodb/assets/37167732/d22c6ff3-6842-46ab-90cf-38017ee37c6a)

can someone help me solve/understand this ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the client.on registrations for connected, serverOpening, and topologyOpening and compare them with the connector's documented MongoDB event behavior. Determine whether the missing events are expected or need forwarding, then reproduce the connection sequence and document or test the observed result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, nodejs
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.