@axxel/event-bus 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/config/kafka.d.ts +0 -0
- package/dist/config/kafka.d.ts.map +0 -0
- package/dist/config/kafka.js +0 -0
- package/dist/consumers/index.d.ts +0 -0
- package/dist/consumers/index.d.ts.map +0 -0
- package/dist/consumers/index.js +0 -0
- package/dist/consumers/poolCreatedConsumer.d.ts +0 -0
- package/dist/consumers/poolCreatedConsumer.d.ts.map +0 -0
- package/dist/consumers/poolCreatedConsumer.js +0 -0
- package/dist/consumers/tokenPriceConsumer.d.ts +0 -0
- package/dist/consumers/tokenPriceConsumer.d.ts.map +0 -0
- package/dist/consumers/tokenPriceConsumer.js +0 -0
- package/dist/consumers/tradeExecutionConsumer.d.ts +0 -0
- package/dist/consumers/tradeExecutionConsumer.d.ts.map +0 -0
- package/dist/consumers/tradeExecutionConsumer.js +0 -0
- package/dist/consumers/walletTransactionConsumer.d.ts +0 -0
- package/dist/consumers/walletTransactionConsumer.d.ts.map +0 -0
- package/dist/consumers/walletTransactionConsumer.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.d.ts.map +0 -0
- package/dist/index.js +0 -0
- package/dist/producers/index.d.ts +0 -0
- package/dist/producers/index.d.ts.map +0 -0
- package/dist/producers/index.js +0 -0
- package/dist/producers/poolCreatedProducer.d.ts +0 -0
- package/dist/producers/poolCreatedProducer.d.ts.map +0 -0
- package/dist/producers/poolCreatedProducer.js +0 -0
- package/dist/producers/tokenPriceProducer.d.ts +4 -0
- package/dist/producers/tokenPriceProducer.d.ts.map +1 -1
- package/dist/producers/tokenPriceProducer.js +42 -3
- package/dist/producers/tradeExecutionProducer.d.ts +0 -0
- package/dist/producers/tradeExecutionProducer.d.ts.map +0 -0
- package/dist/producers/tradeExecutionProducer.js +0 -0
- package/dist/producers/walletTransactionProducer.d.ts +0 -0
- package/dist/producers/walletTransactionProducer.d.ts.map +0 -0
- package/dist/producers/walletTransactionProducer.js +0 -0
- package/dist/topics.d.ts +0 -0
- package/dist/topics.d.ts.map +0 -0
- package/dist/topics.js +0 -0
- package/dist/types/PoolCreatedEvent.d.ts +0 -0
- package/dist/types/PoolCreatedEvent.d.ts.map +0 -0
- package/dist/types/PoolCreatedEvent.js +0 -0
- package/dist/types/TokenPriceEvent.d.ts +0 -0
- package/dist/types/TokenPriceEvent.d.ts.map +0 -0
- package/dist/types/TokenPriceEvent.js +0 -0
- package/dist/types/TradeExecutionEvent.d.ts +0 -0
- package/dist/types/TradeExecutionEvent.d.ts.map +0 -0
- package/dist/types/TradeExecutionEvent.js +0 -0
- package/dist/types/WalletTransactionEvent.d.ts +0 -0
- package/dist/types/WalletTransactionEvent.d.ts.map +0 -0
- package/dist/types/WalletTransactionEvent.js +0 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.d.ts.map +0 -0
- package/dist/types/index.js +0 -0
- package/dist/validation/common.d.ts +0 -0
- package/dist/validation/common.d.ts.map +0 -0
- package/dist/validation/common.js +0 -0
- package/dist/validation/tokenPriceEvent.schema.d.ts +0 -0
- package/dist/validation/tokenPriceEvent.schema.d.ts.map +0 -0
- package/dist/validation/tokenPriceEvent.schema.js +0 -0
- package/dist/validation/walletTransactionEvent.schema.d.ts +0 -0
- package/dist/validation/walletTransactionEvent.schema.d.ts.map +0 -0
- package/dist/validation/walletTransactionEvent.schema.js +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
File without changes
|
package/dist/config/kafka.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/config/kafka.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/consumers/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.d.ts.map
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/producers/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { TokenPriceEvent } from '../types/TokenPriceEvent';
|
|
2
2
|
export declare function produceTokenPrice(event: TokenPriceEvent): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Batch produce multiple token prices in a single Kafka send for optimal performance
|
|
5
|
+
*/
|
|
6
|
+
export declare function produceTokenPriceBatch(events: TokenPriceEvent[]): Promise<void>;
|
|
3
7
|
//# sourceMappingURL=tokenPriceProducer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenPriceProducer.d.ts","sourceRoot":"","sources":["../../src/producers/tokenPriceProducer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tokenPriceProducer.d.ts","sourceRoot":"","sources":["../../src/producers/tokenPriceProducer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,0BAA0B,CAAC;AA+B3E,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,eAAe,iBAwB7D;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,eAAe,EAAE,iBAuBrE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.produceTokenPrice = produceTokenPrice;
|
|
4
|
+
exports.produceTokenPriceBatch = produceTokenPriceBatch;
|
|
4
5
|
const kafka_1 = require("../config/kafka");
|
|
5
6
|
const topics_1 = require("../topics");
|
|
6
7
|
function normalizePriceMap(price) {
|
|
@@ -9,9 +10,24 @@ function normalizePriceMap(price) {
|
|
|
9
10
|
}
|
|
10
11
|
return price;
|
|
11
12
|
}
|
|
13
|
+
// ---------- Singleton state ----------//
|
|
14
|
+
let producer = null;
|
|
15
|
+
let isConnecting = null;
|
|
16
|
+
async function getProducer() {
|
|
17
|
+
if (!producer) {
|
|
18
|
+
producer = kafka_1.kafka.producer();
|
|
19
|
+
}
|
|
20
|
+
if (!isConnecting) {
|
|
21
|
+
isConnecting = producer.connect().catch((err) => {
|
|
22
|
+
isConnecting = null;
|
|
23
|
+
throw err;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
await isConnecting;
|
|
27
|
+
return producer;
|
|
28
|
+
}
|
|
12
29
|
async function produceTokenPrice(event) {
|
|
13
|
-
const producer =
|
|
14
|
-
await producer.connect();
|
|
30
|
+
const producer = await getProducer();
|
|
15
31
|
const key = `${event.chainId}:${event.tokenAddress}`;
|
|
16
32
|
const serializedEvent = {
|
|
17
33
|
...event,
|
|
@@ -26,6 +42,29 @@ async function produceTokenPrice(event) {
|
|
|
26
42
|
},
|
|
27
43
|
],
|
|
28
44
|
});
|
|
29
|
-
await producer.disconnect();
|
|
30
45
|
console.log(`✅ Sent token price update for ${event.symbol ?? event.tokenAddress} (chain ${event.chainId})`);
|
|
31
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Batch produce multiple token prices in a single Kafka send for optimal performance
|
|
49
|
+
*/
|
|
50
|
+
async function produceTokenPriceBatch(events) {
|
|
51
|
+
if (events.length === 0)
|
|
52
|
+
return;
|
|
53
|
+
const producer = await getProducer();
|
|
54
|
+
const messages = events.map((event) => {
|
|
55
|
+
const key = `${event.chainId}:${event.tokenAddress}`;
|
|
56
|
+
const serializedEvent = {
|
|
57
|
+
...event,
|
|
58
|
+
price: normalizePriceMap(event.price),
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
key,
|
|
62
|
+
value: JSON.stringify(serializedEvent),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
await producer.send({
|
|
66
|
+
topic: topics_1.TOPICS.TOKEN_PRICES,
|
|
67
|
+
messages,
|
|
68
|
+
});
|
|
69
|
+
console.log(`✅ Sent ${events.length} token price updates in batch`);
|
|
70
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/topics.d.ts
CHANGED
|
File without changes
|
package/dist/topics.d.ts.map
CHANGED
|
File without changes
|
package/dist/topics.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/types/index.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/types/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axxel/event-bus",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Axxel Kafka Event Bus SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"tsx": "^4.20.6",
|
|
38
38
|
"typescript": "^5.9.3"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|