{"id":13783353,"url":"https://github.com/nodefluent/sequelize-kafka-connect","last_synced_at":"2025-04-26T13:30:50.107Z","repository":{"id":21337986,"uuid":"92410902","full_name":"nodefluent/sequelize-kafka-connect","owner":"nodefluent","description":":gem: nodejs kafka connect connector for MySQL, Postgres, SQLite and MSSQL","archived":false,"fork":false,"pushed_at":"2022-12-10T17:23:34.000Z","size":988,"stargazers_count":39,"open_issues_count":16,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-14T07:54:12.064Z","etag":null,"topics":["etl","kafka","kafka-connect","mssql","mysql","nodejs","postgres","sequelize","sqlite"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nodefluent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-25T14:21:30.000Z","updated_at":"2024-02-23T07:13:00.000Z","dependencies_parsed_at":"2023-01-14T07:00:24.210Z","dependency_job_id":null,"html_url":"https://github.com/nodefluent/sequelize-kafka-connect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodefluent%2Fsequelize-kafka-connect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodefluent%2Fsequelize-kafka-connect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodefluent%2Fsequelize-kafka-connect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodefluent%2Fsequelize-kafka-connect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodefluent","download_url":"https://codeload.github.com/nodefluent/sequelize-kafka-connect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222920988,"owners_count":17058104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["etl","kafka","kafka-connect","mssql","mysql","nodejs","postgres","sequelize","sqlite"],"created_at":"2024-08-03T19:00:19.632Z","updated_at":"2024-11-11T01:36:15.696Z","avatar_url":"https://github.com/nodefluent.png","language":"JavaScript","funding_links":[],"categories":["Development"],"sub_categories":["Connectors"],"readme":"# sequelize-kafka-connect\n\nNode.js Kafka Connect connector for MySQL, Postgres, SQLite and MSSQL databases\n\n[![Build Status](https://travis-ci.org/nodefluent/sequelize-kafka-connect.svg?branch=master)](https://travis-ci.org/nodefluent/sequelize-kafka-connect)\n\n[![Coverage Status](https://coveralls.io/repos/github/nodefluent/sequelize-kafka-connect/badge.svg?branch=master)](https://coveralls.io/github/nodefluent/sequelize-kafka-connect?branch=master)\n\n## Use API\n\n```\nnpm install --save sequelize-kafka-connect\n```\n\n## A note on native mode\n\nIf you are using the native mode (`config: { noptions: {} }`).\nYou will have to manually install `node-rdkafka` alongside kafka-connect.\n(This requires a Node.js version between 9 and 12 and will not work with Node.js \u003e= 13, last tested with 12.16.1)\n\nOn Mac OS High Sierra / Mojave:\n`CPPFLAGS=-I/usr/local/opt/openssl/include LDFLAGS=-L/usr/local/opt/openssl/lib yarn add --frozen-lockfile node-rdkafka@2.7.4`\n\nOtherwise:\n`yarn add --frozen-lockfile node-rdkafka@2.7.4`\n\n(Please also note: Doing this with npm does not work, it will remove your deps, `npm i -g yarn`)\n\n### database -\u003e kafka\n\n```es6\nconst { runSourceConnector } = require(\"sequelize-kafka-connect\");\nrunSourceConnector(config, [], onError).then(config =\u003e {\n    //runs forever until: config.stop();\n});\n```\n\n### kafka -\u003e database\n\n```es6\nconst { runSinkConnector } = require(\"sequelize-kafka-connect\");\nrunSinkConnector(config, [], onError).then(config =\u003e {\n    //runs forever until: config.stop();\n});\n```\n\n### kafka -\u003e database (with custom topic (no source-task topic))\n\n```es6\nconst { runSinkConnector, ConverterFactory } = require(\"sequelize-kafka-connect\");\n\nconst tableSchema = {\n    \"id\": {\n        \"type\": \"integer\",\n        \"allowNull\": false,\n        \"primaryKey\": true\n    },\n    \"name\": {\n        \"type\": \"varchar(255)\",\n        \"allowNull\": true\n    }\n};\n\nconst etlFunc = (messageValue, callback) =\u003e {\n\n    //type is an example json format field\n    if (messageValue.type === \"publish\") {\n        return callback(null, {\n            id: messageValue.payload.id,\n            name: messageValue.payload.name\n        });\n    }\n\n    if (messageValue.type === \"unpublish\") {\n        return callback(null, null); //null value will cause deletion\n    }\n\n    callback(new Error(\"unknown messageValue.type\"));\n};\n\nconst converter = ConverterFactory.createSinkSchemaConverter(tableSchema, etlFunc);\n\nrunSinkConnector(config, [converter], onError).then(config =\u003e {\n    //runs forever until: config.stop();\n});\n\n/*\n    this example would be able to store kafka message values\n    that look like this (so completely unrelated to messages created by a default SourceTask)\n    {\n        payload: {\n            id: 123,\n            name: \"bla\"\n        },\n        type: \"publish\"\n    }\n*/\n```\n\n## Use CLI\nnote: in BETA :seedling:\n\n```\nnpm install -g sequelize-kafka-connect\n```\n\n```\n# run source etl: database -\u003e kafka\nnkc-sequelize-source --help\n```\n\n```\n# run sink etl: kafka -\u003e database\nnkc-sequelize-sink --help\n```\n\n## Config(uration)\n```es6\nconst config = {\n    kafka: {\n        //zkConStr: \"localhost:2181/\",\n        kafkaHost: \"localhost:9092\",\n        logger: null,\n        groupId: \"kc-sequelize-test\",\n        clientName: \"kc-sequelize-test-name\",\n        workerPerPartition: 1,\n        options: {\n            sessionTimeout: 8000,\n            protocol: [\"roundrobin\"],\n            fromOffset: \"earliest\", //latest\n            fetchMaxBytes: 1024 * 100,\n            fetchMinBytes: 1,\n            fetchMaxWaitMs: 10,\n            heartbeatInterval: 250,\n            retryMinTimeout: 250,\n            requireAcks: 1,\n            //ackTimeoutMs: 100,\n            //partitionerType: 3\n        }\n    },\n    topic: \"sc_test_topic\",\n    partitions: 1,\n    maxTasks: 1,\n    pollInterval: 2000,\n    produceKeyed: true,\n    produceCompressionType: 0,\n    connector: {\n        options: {\n            host: \"localhost\",\n            port: 5432,\n            dialect: \"sqlite\",\n            pool: {\n                max: 5,\n                min: 0,\n                idle: 10000\n            },\n            storage: path.join(__dirname, \"test-db.sqlite\")\n        },\n        database: null,\n        user: null,\n        password: null,\n        maxPollCount: 50,\n        table: \"accounts\",\n        incrementingColumnName: \"id\"\n    },\n    http: {\n        port: 3149,\n        middlewares: []\n    },\n    enableMetrics: true,\n    batch: {\n        batchSize: 100, \n        commitEveryNBatch: 1, \n        concurrency: 1,\n        commitSync: true\n    }\n};\n```\n\n## Native Clients Config(uration)\n```es6\nconst config = {\n   \n    kafka: {\n        noptions: {\n            \"metadata.broker.list\": \"localhost:9092\",\n            \"group.id\": \"n-test-group\",\n            \"enable.auto.commit\": false,\n            \"debug\": \"all\",\n            \"event_cb\": true,\n            \"client.id\": \"kcs-test\"\n        },\n        tconf: {\n            \"auto.offset.reset\": \"earliest\",\n            \"request.required.acks\": 1\n        }\n    },\n   \n    topic: \"sc_test_topic\",\n    partitions: 1,\n    maxTasks: 1,\n    pollInterval: 2000,\n    produceKeyed: true,\n    produceCompressionType: 0,\n    connector: {\n        options: {\n            host: \"localhost\",\n            port: 5432,\n            dialect: \"sqlite\",\n            pool: {\n                max: 5,\n                min: 0,\n                idle: 10000\n            },\n            storage: path.join(__dirname, \"test-db.sqlite\")\n        },\n        database: null,\n        user: null,\n        password: null,\n        maxPollCount: 50,\n        table: \"accounts\",\n        incrementingColumnName: \"id\"\n    },\n    http: {\n        port: 3149,\n        middlewares: []\n    },\n    enableMetrics: true\n};\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodefluent%2Fsequelize-kafka-connect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodefluent%2Fsequelize-kafka-connect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodefluent%2Fsequelize-kafka-connect/lists"}