MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / produceIncomingEvent

Function produceIncomingEvent

packages/queue/src/kafka.ts:186–212  ·  view source on GitHub ↗
(
  payload: EventsQueuePayloadIncomingEvent['payload'],
  partitionKey: string
)

Source from the content-addressed store, hash-verified

184};
185
186export const produceIncomingEvent = async (
187 payload: EventsQueuePayloadIncomingEvent['payload'],
188 partitionKey: string
189): Promise<void> => {
190 const p = await getProducer();
191 try {
192 await p.send({
193 topic: KAFKA_EVENTS_TOPIC,
194 timeout: KAFKA_REQUEST_TIMEOUT_MS,
195 messages: [
196 {
197 key: Buffer.from(partitionKey),
198 value: Buffer.from(JSON.stringify(payload)),
199 },
200 ],
201 });
202 } catch (err) {
203 if (isFatalProducerError(err)) {
204 kafkaLogger.warn(
205 { err },
206 'kafka producer in fatal state; resetting for next call'
207 );
208 resetProducer(p);
209 }
210 throw err;
211 }
212};
213
214const consumers = new Set<Consumer>();
215

Callers 2

handleTrackFunction · 0.90
postEventFunction · 0.90

Calls 7

getProducerFunction · 0.85
isFatalProducerErrorFunction · 0.85
resetProducerFunction · 0.85
sendMethod · 0.45
fromMethod · 0.45
stringifyMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected