在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):ancashoria/graphql-kafka-subscriptions开源软件地址(OpenSource Url):https://github.com/ancashoria/graphql-kafka-subscriptions开源编程语言(OpenSource Language):TypeScript 93.4%开源软件介绍(OpenSource Introduction):graphql-kafka-subscriptionsIt implements the PubSubEngine Interface from the graphql-subscriptions package and also the new AsyncIterator interface. It allows you to connect your subscriptions manager to a single Kafka topic used as Pub/Sub communication channel. Installation
Mac OS High Sierra / MojaveOpenSSL has been upgraded in High Sierra and homebrew does not overwrite default system libraries. That means when building node-rdkafka, because you are using openssl, you need to tell the linker where to find it: export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib Then you can run UsageInitializing the kafka pubsub clientimport { KafkaPubSub } from 'graphql-kafka-subscriptions'
export const pubsub = new KafkaPubSub({
topic: 'name-of-the-topic',
host: 'INSERT_KAFKA_IP',
port: 'INSERT_KAFKA_PORT',
globalConfig: {} // options passed directly to the consumer and producer
}) Publishing messages to the subcritionpayload = {
firstName: "John",
lastName: "Doe"
}
pubsub.publish('pubSubChannel', payload); Subscribing to a channelconst onMessage = (payload) => {
console.log(payload);
}
const subscription = await pubsub.subscribe('pubSubChannel', onMessage) ContributingContributions are welcome. Make sure to check the existing issues (including the closed ones) before requesting a feature, reporting a bug or opening a pull requests. For sending a PR follow:
Horia Miron notes: Thanks to davidyaha for graphql-redis-subscriptions which was the main inspiration point for this project. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论