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

xkite-core

v1.0.28

Published

Core library for xkite application

Downloads

86

Readme

xkite-core version license

Core Library for xkite, a Kafka Integrated Testing Environment

xkite-core provides a comprehensive prototyping, testing, and monitoring toolset for Apache Kafka. Use xkite to bootstrap your next project, or install our library into an existing project. Built by developers, for developers.

Dependencies

The latest stable versions of:

  • Node.js and NPM
  • docker-compose

Installation

  1. Clone this Repository git clone https://github.com/oslabs-beta/xkite-core.git

  2. Install Dependencies cd into the cloned repository and run npm install

Who Uses xkite-core

  • xkite GUI
  • xkite CLI

How It Works

The xkite-core library is, as the name suggests, the core library for xkite.

To interface with xkite-core, simply import the Kite class into your project.

In xkite, Kite provides the underlying functionality for configuring a Docker Compose YAML configuration, managing docker containers (configure, run, pause and shutdown), interfacing with remote xkite servers, and providing configuration settings for developers to easily connect to Kafka instances.

Kite Class Data Types

Click to expand details.

Overall state of Kite, provided by Kite.getState().

type KiteState =
  | 'Unknown'
  | 'Init'
  | 'Configured'
  | 'Running'
  | 'Paused'
  | 'Shutdown';

State of remote Kite connection, provided by Kite.getServerState().

type KiteServerState = 'Disconnected' | 'Connected';

Input object to create a docker instances. Used for Kite.configure().

interface KiteConfig {
  kafka: KiteKafkaCfg;
  db?: dbCfg;
  sink?: sinkCfg;
  grafana?: grafanaCfg;
  prometheus?: prometheusCfg;
}

Response object from Kite.getSetup() available after Kite is configured.

interface KiteSetup {
  dBSetup?: dbCfg;
  kafkaSetup: KafkaSetup;
  spring?: { port: number };
  prometheus?: { port: number };
  grafana?: { port: number };
  zookeeper?: { ports: number[] };
  jmx?: { ports: number[] };
  jupyter?: { port: number };
  spark?: { port: number[] };
  docker?: { services: string[] };
}

Response object from Kite.getKafkaSetup() available after Kite is configured.

interface KafkaSetup {
  clientId: string;
  brokers: Array<string>;
  ssl?: boolean;
}

Format of the configuration file object provided by Kite.getConfigFile().

Note: the fileStream object is a stream of the docker-compose.yml file generated from Kite.configure()

interface KiteConfigFile {
  header?: any;
  fileStream: Buffer;
}

Configuration object as a part of the KiteConfig object. It defines which data source the user wants configured.

interface dbCfg {
  name: 'postgresql' | 'ksql';
  port?: number | undefined;
  postgresql?: {
    username: string;
    password: string;
    dbname: string;
  };
  ksql?: {
    schema_port?: number | undefined;
  };
  kafkaconnect?: {
    port?: number | undefined;
  };
}

Configuration object as a part of the KiteConfig object. It defines which data sink the user wants configured

interface sinkCfg {
  name: 'jupyter' | 'spark';
  port?: number;
  rpc_port?: number;
  kafkaconnect?: {
    port?: number | undefined;
  };
}

Configuration object as a part of the KiteConfig object. It defines which port the user wants their grafana interface to be configured on

interface grafanaCfg {
  port?: number | undefined;
}

Configuration object as a part of the KiteConfig object. It defines prometheus settings the user wants configured such as port, scrape and evaluation intervals

interface prometheusCfg {
  port?: number | undefined;
  scrape_interval?: number; //seconds
  evaluation_interval?: number; //seconds
}

Kite Class Methods

Click to expand details.

Note: If no input is give a default configuration will be used.

Type Definition:

configure: (arg?: string | KiteConfig | undefined) => Promise<'void'>;

Example:

const { Kite } = require('xkite-core');

await Kite.configure(); // configure local default
// or
await Kite.configure('http://localhost:3000'); // configure remote
// or

deploys all configured docker instances from Kite.configure(). If the Kite serverState === "Connected" then this deployment will happen on the remote server.

Type Definition:

deploy: () => Promise<void>;

Example:

const { Kite } = require('xkite-core');

await Kite.deploy();

pauses any/all running docker instances. If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

pause: (service?: string[] | undefined) => Promise<any>;

Example:

const { Kite } = require('xkite-core');

await Kite.pause(['kafka1', 'kafka2']); // pauses kafka1 and kafka2 docker services

await Kite.pause(); // pauses all docker instances

Unpauses any/all running docker instances. If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

unpause: (service?: string[] | undefined) => Promise<any>;

Example:

const { Kite } = require('xkite-core');

await Kite.unpause(['kafka1', 'kafka2']); // unpauses kafka1 and kafka2 docker services

await Kite.unpause(); // unpauses all docker instances

Shuts down all running or paused docker instances and removes all configured volumes. If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

shutdown: () => Promise<any>;

Example:

const { Kite } = require('xkite-core');

await Kite.shutdown();

Retrieves the KiteSetup object created after Kite.configure(). If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

getSetup: () => KiteSetup | Promise<KiteSetup>;

Example:

const { Kite } = require('xkite-core');

const setup = await Kite.getSetup();

Retrieves the KafkaSetup object created after Kite.configure(). If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

getSetup: () => KiteSetup | Promise<KiteSetup>;

Example:

const { Kafka } = require('kafkajs')
const { Kite } = require('xkite-core');
const kafkaSetup = await Kite.getKafkaSetup();

const kafka = new Kafka({
  ...kafkaSetup,
  clientId: 'myapp'
})
...

Retrieves the dBCfg object created after Kite.configure(). If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

getDBSetup: () => dbCfg | Promise<dbCfg | undefined>;

Example:

const { Kite } = require('xkite-core');
const dBSetup = await Kite.getDBSetup();

Retrieves the KiteConfig object created after Kite.configure(). If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

getConfig: () => KiteConfig | Promise<KiteConfig>;

Example:

const { Kite } = require('xkite-core');
const config = await Kite.getConfig();

Retrieves the KiteConfig object created after Kite.configure(). If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

getConfig: () => KiteConfig | Promise<KiteConfig>;

Example:

const { Kite } = require('xkite-core');
const config = await Kite.getConfig();

Retrieves the current KiteState. If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

getKiteState: () => KiteState | Promise<KiteState>;

Example:

const { Kite } = require('xkite-core');
const state = await Kite.getState();

Retrieves the state of remote connection with the Kite server.

Type Definition:

getKiteServerState: () => KiteServerState;

Example:

const { Kite } = require('xkite-core');
const serverState = await Kite.getServerState();

Retrieves the current package.zip file from Kite. This file contains the full set of dependencies to replicate the docker ecosystem sans xkite-core. If the Kite serverState === "Connected" then this command will be initiated on the remote server.

Type Definition:

getPackageBuild: () => Promise<KiteConfigFile | Error>;

Example:

const { Kite } = require('xkite-core');
const fs = require('fs');

const pkg = await Kite.getPackageBuild();
fs.writeFileSync(
        path.resolve(__dirname, 'package.zip'),
        Buffer.from(pkg.fileStream)
      );

Docker Images

xkite uses the following docker images to provide their associated services:

  • xkite/kafka-connector
  • bitnami/jmx-exporter
  • confluentinc/cp-kafka
  • confluentinc/cp-zookeeper
  • prom/prometheus
  • grafana/grafana-oss
  • postgres
  • confluentinc/ksqldb-server
  • confluentinc/ksqldb-cli
  • confluentinc/cp-schema-registry
  • jupyterhub/jupyterhub
  • bitnami/spark
  • eclipse-temurin