Skip to content

resonatehq/resonate-transport-kafka-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@resonatehq/kafka

@resonatehq/kafka is the official Kafka transport binding for the Resonate TypeScript SDK. It replaces the default HTTP transport, routing task invocations and resumptions through Kafka topics instead.

Installation

npm install @resonatehq/kafka

Usage

Pass a Kafka transport instance when constructing Resonate:

import { type Context, Resonate } from "@resonatehq/sdk";
import { Kafka } from "@resonatehq/kafka";

const transport = new Kafka({ brokers: ["localhost:9092"] });
await transport.start();

const resonate = new Resonate({ transport });

resonate.register("foo", function* foo(ctx: Context): Generator {
  return yield* ctx.rpc("bar");
});

resonate.register("bar", function bar(_ctx: Context) {
  return "hello world";
});

const result = await resonate.run("foo.1", "foo");
console.log(result); // "hello world"

await resonate.stop();

Before running, create the required Kafka topics:

resonate
default

Start the Resonate server with Kafka enabled:

resonate dev --api-kafka-enable --aio-kafka-enable

Then run your application:

npx ts-node app.ts

Examples

Documentation

Full documentation: docs.resonatehq.io

About

The official Kafka transport binding for Resonate.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •