Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nasa-gcn/gcn-kafka-js
Official Node.js client for the General Coordinates Network (GCN)
https://github.com/nasa-gcn/gcn-kafka-js
astronomy javascript kafka nodejs typescript
Last synced: about 7 hours ago
JSON representation
Official Node.js client for the General Coordinates Network (GCN)
- Host: GitHub
- URL: https://github.com/nasa-gcn/gcn-kafka-js
- Owner: nasa-gcn
- License: cc0-1.0
- Created: 2022-06-08T21:07:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-06T14:55:09.000Z (10 days ago)
- Last Synced: 2024-11-06T15:39:47.563Z (10 days ago)
- Topics: astronomy, javascript, kafka, nodejs, typescript
- Language: TypeScript
- Homepage: https://gcn.nasa.gov/docs/client
- Size: 111 KB
- Stars: 0
- Watchers: 5
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/gcn-kafka)](https://www.npmjs.com/package/gcn-kafka)
# GCN Kafka Client for Node.js
This is the official Node.js client for the [General Coordinates Network (GCN)](https://gcn.nasa.gov). It is a very lightweight wrapper around [Kafka.js](https://kafka.js.org).
## To Install
Run this command to install with [npm](https://www.npmjs.com):
```
npm install gcn-kafka
```## To Use
Create a client:
```mjs
import { Kafka } from 'gcn-kafka'
const kafka = new Kafka({
client_id: 'fill me in',
client_secret: 'fill me in',
})
```List topics:
```mjs
const admin = kafka.admin()
const topics = await admin.listTopics()
console.log(topics)
```Subscribe to topics and receive alerts:
```mjs
const consumer = kafka.consumer()
await consumer.subscribe({
topics: [
'gcn.classic.text.FERMI_GBM_FIN_POS',
'gcn.classic.text.LVC_INITIAL',
],
})await consumer.run({
eachMessage: async (payload) => {
const value = payload.message.value
console.log(value?.toString())
},
})
```## Testing and Development Kafka Clusters
GCN has three Kafka clusters: production, testing, and an internal development deployment. Use the optional `domain` parameter to select which broker to connect to.
```mjs
// Production (default)
const kafka = new Kafka({
client_id: 'fill me in',
client_secret: 'fill me in',
domain: 'gcn.nasa.gov',
})// Testing
const kafka = new Kafka({
client_id: 'fill me in',
client_secret: 'fill me in',
domain: 'test.gcn.nasa.gov',
})// Development (internal)
const kafka = new Kafka({
client_id: 'fill me in',
client_secret: 'fill me in',
domain: 'dev.gcn.nasa.gov',
})
```