Feature: Kafka module - di.kafka#104
Open
alowrydi wants to merge 3 commits into
Open
Conversation
…ing following the injected dependency pattern observed in other developed modules and suite of k4unit test added (25/25 pass)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kafka consumer/producer module, di.kafka
Extracts
code/common/kafka.qfrom TorQ and packages it as a standalone kdb-x module. Wraps thekafkaqnative C shared library to provide Kafka consumer initialisation, producer initialisation, topic subscription, and message publishing, with incoming messages delivered to a configurablekupdcallback.Trello ticket - https://trello.com/c/eDFHYhSx/103-kdb-x-kafka-module
Files created
di/kafka/init.qkafka.q, defines export of 8 functionsdi/kafka/kafka.qdi/kafka/kafka.mddi/kafka/test.csvHow to test
Unit test example:
Coverage includes all invalid log-dependency shapes, all native function stub error messages, the
enabled:0bpath proven via a capturing mock logger, the missing-library path,setkupd, and multiple consecutiveinitcalls.Design decisions
1.
enabledvariable matches TorQ's platform-detection default -enableddefaults to`.z.o in `l64`, matching TorQ's ownkafka.qexactly rather than a hardcoded value. On a non-l64host the module loads disabled unless explicitly overridden.2. Missing library will log and continue, does not throw - If
enabled:1band the library file is not found,initlogs an error via the injected logger and leaves all native functions as stubs, rather than throwing. This matches TorQ's original log-and-degrade behaviour - a missing native library should not halt the calling process.3. Injected logging dependency -
initnow takes[config;deps]and requires alogdependency withinfo/warn/errorfunctions, throwing a clear, module-prefixed error if it is missing or incomplete. This logging support consistent with how the other new modules in this project are being built.4. Default
kupdlogs through the injected logger, not stdout - TorQ's original defaultkupdwrites raw bytes to stdout. Since this module now requires logging to be wired up regardless, the default handler logs via the injected logger instead, so there is one consistent output path rather than two.5. Native function stubs in disabled mode - TorQ leaves the native functions undefined when disabled, so calling them produces a generic, uninformative error. This module instead gives each one a stub that throws
'kafka not enabled, a clear, distinguishable error rather than an undefined-variable error.Checklist
Documentation
See kafka.md for full reference including config table, disabled-mode behaviour, exported function documentation, usage example, global side effect, and TorQ migration pattern table.