npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bf-lib-kafkacouch

v1.0.12

Published

Block-5 Kafka Couch Library

Downloads

1

Readme

Description

This Library should handle all interactions between kafka and couch

Data Asumptions,

It Monitor's created and updated,

  • Created assume's no document exists, and creates a new one
  • Updated assumes Document exits
  • message has an id field, that is the id for the document

#Usage

import { taskSchema } from "bf-legal-task";
import { KafkaCouchWatcher } from "lib-kafkacouch";
const TaskWatcher = new KafkaCouchWatcher({
  subject: "task",
  couch: `workflow-task_management`,
  kafka: { topic: `WORKFLOW.TASK_MANAGEMENT`, groupId: "app-asdf" },
  bodyValidation: taskSchema,
  id: "id",
  filter: (body, type, header) => {
    return true;
  },
  map: (body, type, header) => {
    return body;
  }
});
//After a commit happens
TaskWatcher.on("updated", async (body, type, header) => {
  console.log(packet);
});

Without couch ( for command's ext... )

import { taskSchema } from "bf-legal-task";
import { KafkaCouchWatcher } from "lib-kafkacouch";
const TaskWatcher = new KafkaCouchWatcher({
  subject: "task",
  couch: false,
  kafka: { topic: `WORKFLOW.TASK_MANAGEMENT`, groupId: "app-asdf" },
  bodyValidation: taskSchema,
  filter: (body, type, header) => {
    return true;
  },
  map: (body, type, header) => {
    return body;
  }
});
//After a commit happens
TaskWatcher.on("updated", async (body, type, header) => {
  console.log(packet);
});

Config Stuff

Couch by default get's it's creds from enviromental variables

const COUCH_USER: string = process.env.COUCH_USER || "admin";
const COUCH_PASSWORD: string = process.env.COUCH_PASSWORD || "password";
const COUCH_PORT: string = process.env.COUCH_PORT || "5984";
const COUCH_HOST: string = process.env.COUCH_HOST || "couchdb";
const COUCH_PROTO: string = process.env.COUCH_PROTO || "http";

KafkaCouchWatcher.kafka

| Key | Description | Required | | ------------------------ | ----------------------------------- | -------- | | topic | Kafka Topic | true | | groupId | Group ID ( for Round Robin Groups ) | true | | host | Kafka Host | false | | sessionTimeout | | false | | protocol | | false | | fromOffset | | false | | protocol | | false | | commitOffsetsOnFirstJoin | | false | | outOfRangeOffset | | false | | onRebalance | | false |

const k = {
  topic: `WORKFLOW.TASK_MANAGEMENT`,
  host: process.env.ZOOKEEPER_HOST || "zookeeper:2181",
  groupId: process.env.KAFKA_GROUP_ID || "default-groupa",
  sessionTimeout: 15000,
  protocol: ["roundrobin"],
  fromOffset: "earliest",
  commitOffsetsOnFirstJoin: true,
  outOfRangeOffset: "earliest",
  onRebalance: (isAlreadyMember: any, callback: any) => {
    callback();
  } // or null
};