Welcome to kpipe Discussions! #75
eschizoid
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Type-Safe Registry Modernization Proposal
Objective
Improve compile-time safety and developer experience when registering and using message processors and sinks.
Ideas for Improving Type Safety in KPipe Registries
The current implementation of
MessageProcessorRegistryandMessageSinkRegistryrelies heavily onStringidentifiers and
byte[]orObject(viaMap<String, Object>orGenericRecord) for message processing. While thisprovides flexibility, it sacrifices compile-time type safety.
1. Typed Registry Keys (Type-Safe Identifiers)
Instead of using plain
Stringnames, introduce a typedRegistryKey<T>class. This ensures that when you retrieve aprocessor or sink, you know exactly what data type it operates on.
2. Fluent "Builder" for Pipelines
Create a fluent API that guides the user through the pipeline construction based on types. This prevents mixing
incompatible processors (e.g., trying to use an Avro operator in a JSON pipeline).
3. Strongly Typed Sink Registry
The
MessageSinkRegistrycan be made safer by requiring the key and value types at registration time.4. Sealed Interface for Message Formats
Since
MessageFormatis currently anenum, it's hard to attach specific type information to each format. Moving to asealed class/interface hierarchy would allow better type bounds.
5. Annotation Processing or Record-Based Mapping
For users who prefer POJOs over
MaporGenericRecord, provide a way to register processors based on Java records orclasses.
6. Enum-Based Registry (Static Type Safety)
If the set of processors is known at compile-time, using an
Enumthat implements an interface is the ultimate way toensure type safety.
Roadmap
Phase 1: Foundation (Type-Safe Identifiers)
RegistryKey<T>record to replaceStringnames inMessageProcessorRegistryandMessageSinkRegistry.registerandgetmethods to acceptRegistryKey<T>.Stringregistration methods.Phase 2: Pipeline Safety
PipelineBuilderthat usesRegistryKey<T>to ensure only compatible operators are chained.MessageFormatfrom anenumto asealed interfacehierarchy.Phase 3: Sink & POJO Support
MessageSinkRegistryto require key and value type verification at registration time.MaporGenericRecord.Success Metrics
ClassCastExceptionat runtime when accessing registered components.Beta Was this translation helpful? Give feedback.
All reactions