Skip to content

Instantly share code, notes, and snippets.

@titouancreach
Created May 22, 2024 22:11
Show Gist options
  • Save titouancreach/2fad45f4ce2184e00831a4bc691b2175 to your computer and use it in GitHub Desktop.
Save titouancreach/2fad45f4ce2184e00831a4bc691b2175 to your computer and use it in GitHub Desktop.
index.ts
import { NodeRuntime } from "@effect/platform-node";
import { Schema } from "@effect/schema";
import { startConsumer } from "consumer";
import { Console, Effect, LogLevel, Logger, pipe } from "effect";
const consumer = startConsumer({
queueName: "QueueName",
processFunc: (message) => {
return Console.log("Treated !!", message);
},
schema: Schema.Struct({
idMessage: Schema.String.pipe(Schema.startsWith("msg_")),
}),
}).pipe(Logger.withMinimumLogLevel(LogLevel.Debug));
NodeRuntime.runMain(
pipe(Effect.all([Effect.fork(consumer)]), Effect.andThen(Effect.never)),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment