This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sum(x, y) { | |
| return x + y; | |
| } | |
| const a = 3; | |
| const b = 4; | |
| const c = sum(a, b); | |
| console.log(`${a} + ${b} =`, c); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sum(x: number, y: number) { | |
| return x + y; | |
| } | |
| const a: number = 3; | |
| const b: number = 4; | |
| const c: number = sum(a, b); | |
| console.log(`${a} + ${b} =`, c); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "compilerOptions": { | |
| "target": "esnext", | |
| "module": "commonjs", | |
| "moduleResolution": "node", | |
| "declaration": true, | |
| "sourceMap": true, | |
| "outDir": "../dist", | |
| "rootDir": "./" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function sum(x: number, y: number): number { | |
| return x + y; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fetch from 'node-fetch'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fetch from 'node-fetch'; | |
| import { sync } from 'globby'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Local Kafka development environment setup | |
| # ref: https://github.com/simplesteph/kafka-stack-docker-compose/blob/master/full-stack.yml | |
| version: '3' | |
| services: | |
| zoo1: | |
| image: zookeeper:3.4.9 | |
| restart: unless-stopped | |
| hostname: zoo1 | |
| ports: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { KafkaClient as Client, Producer, ProduceRequest } from 'kafka-node'; | |
| const kafkaHost = 'localhost:9092'; | |
| export function publish(topic: string, message: string): void { | |
| // The client connects to a Kafka broker | |
| const client = new Client({ kafkaHost }); | |
| // The producer handles publishing messages over a topic | |
| const producer = new Producer(client); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { KafkaClient as Client } from 'kafka-node'; | |
| const kafkaHost = 'localhost:9092'; | |
| const client = new Client({ kafkaHost }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { KafkaClient as Client, Consumer, Message, Offset, OffsetFetchRequest, ConsumerOptions } from 'kafka-node'; | |
| const kafkaHost = 'localhost:9092'; | |
| export function kafkaSubscribe(topic: string): void { | |
| const client = new Client({ kafkaHost }); | |
| const topics: OffsetFetchRequest[] = [{ topic: topic, partition: 0 }]; | |
| const options: ConsumerOptions = { autoCommit: false, fetchMaxWaitMs: 1000, fetchMaxBytes: 1024 * 1024 }; | |
| const consumer = new Consumer(client, topics, options); |
OlderNewer