Repository navigation
Add PulsarTableViewFactory for creating table views - #1559
Open
sharanggupta wants to merge 1 commit into
Open
sharanggupta wants to merge 1 commit into
sharanggupta wants to merge 1 commit into
Conversation
Resolves spring-projects#503 The framework has factories for the producers, consumers and readers of the Pulsar client, but no counterpart for its TableView API, so a table view had to be built from the raw client in every application. * Add `PulsarTableViewFactory` and `DefaultPulsarTableViewFactory`, which create a `TableView` from a topic and a schema, like the reader factory: the customizers of the default configuration apply to every table view, the customizers passed in to a single one, non-fully-qualified topic names are qualified with the `PulsarTopicBuilder`, and a `PulsarClientException` is wrapped in a `PulsarException` * Add `TableViewBuilderCustomizer` to customize the `TableViewBuilder` * Document the factory in the message consumption chapter Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
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.
Resolves #503
This adds the
TableViewFactorythat was discussed on the issue as the first step for TableView support, following the shape ofPulsarReaderFactory/DefaultPulsarReaderFactory.What it adds
PulsarTableViewFactory<T>withcreateTableView(topic, schema, customizers), andDefaultPulsarTableViewFactory<T>: theTableViewBuilderCustomizers of the default configuration are applied to every table view, the customizers passed in to that single table view (applied last, like the reader factory), a topic passed in overrides the one of the default configuration, non-fully-qualified topic names are qualified when aPulsarTopicBuilderis set, and aPulsarClientExceptionis wrapped in aPulsarException.TableViewBuilderCustomizer<T>, the counterpart ofReaderBuilderCustomizer.PulsarTableViewFactorybean andspring.pulsar.table-view.*defaults next to the reader ones.I did not include the
@PulsarTableViewannotation idea from the issue: the factory is the piece everything else builds on, and the annotation deserves its own discussion.Testing
Developed test first: the new tests do not compile against
main, and pass with the change.DefaultPulsarTableViewFactoryTestsagainst the Pulsar Testcontainers broker: the table view holds the latest value per key, follows the topic after creation, and uses the topic of the factory defaults; aPulsarTopicBuilderqualifies the topic.DefaultPulsarTableViewFactoryUnitTestswith a mockedPulsarClient: the default customizers, the topic and the call customizers are applied in that order, no topic is set when none is given, aPulsarClientExceptionfromcreate()is wrapped, and the schema is required../gradlew :spring-pulsar:checkon JDK 25 with Docker: the new tests pass againstapachepulsar/pulsar:4.2.0, as docheckFormat, Checkstyle and Javadoc. In that run, 27 reader and observation tests failed after the shared broker container stopped accepting connections partway through. I reran those packages on their own and they pass.