Skip to content

Support for stream processing tools such as Kafka and NSQ#112

Merged
d-Rickyy-b merged 30 commits into
devfrom
kafka
Jul 13, 2026
Merged

Support for stream processing tools such as Kafka and NSQ#112
d-Rickyy-b merged 30 commits into
devfrom
kafka

Conversation

@d-Rickyy-b

Copy link
Copy Markdown
Owner

This pull request introduce architectural improvements and enhancements to the broadcast system, adds support for external stream processing (Kafka and NSQ), updates configuration and dependencies, and refines linter and build settings. The main focus is on refactoring the certificate broadcast mechanism to be more modular and extensible, enabling integration with various client types and external systems.

The kafka implementation still lacks support for multiple brokers and partitions. If you feel like that's needed, please create an issue and I'll try to add it as a feature in an upcoming release.

Broadcast System Refactor and Extensibility

  • Refactored the broadcast system by introducing a new Dispatcher (formerly BroadcastManager) in internal/broadcast/broadcastmanager.go, which now manages clients via a CertProcessor interface, allowing for different client implementations (e.g., WebSocket, Kafka, NSQ). The dispatcher handles registration, unregistration, message dispatching, and client statistics.
  • Added a BaseClient struct to encapsulate common client logic (buffering, skipping, naming, etc.), which can be embedded in different client types.

Configuration and External Integration

  • Extended the config.yaml to support external stream processing tools (Kafka and NSQ), added options for real client IP handling, and improved buffer size configuration (renamed broadcastmanager buffer to dispatcher).

Dependency and Build Updates

  • Standardized Docker Compose port mappings by quoting host:port strings for compatibility.

Bug Fixes and Minor Improvements

  • Fixed a context leak in cmd/certpicker/main.go by properly canceling the context after use.
  • Updated Go module dependencies.
  • Standardized Docker Compose port mapping syntax.
  • Fixed context leak in certificate picker CLI.

d-Rickyy-b added 30 commits July 7, 2026 00:54
refers to #23 and #35

I needed to change the config to an arrary in order to have proper support for multiple kinds of queues and stream processors. Currently NSQ and kafka are supported. Future releases could support amazon SNS/SQS by creating a new client in the broadcast package and by extending the config.
Sends messages to the broker in batches to improve throughput. Messages are collected and flushed when a maximum batch size is reached or after a
configured wait time. This significantly reduces individual write calls.
Messages are also dropped if the client isn't connected.
The code for reading and validating the config grew quite big, so it made sense to split it up into multiple files and have a method called Valid() that checks for config validity on each individual struct.

In a further iteration we should split the config_test.go into multiple test files each testing only the respective individual files.
Made stream type configurable so that users can decide which stream they want to feed into kafka.
This should work well with a default kafka configuration. In the future this could become a config option.
@d-Rickyy-b

Copy link
Copy Markdown
Owner Author

This PR is a follow up to #72

@d-Rickyy-b
d-Rickyy-b merged commit 09c6af8 into dev Jul 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant