Skip to content

Add PulsarTableViewFactory for creating table views - #1559

Open
sharanggupta wants to merge 1 commit into
spring-projects:mainfrom
sharanggupta:gh-503-table-view-factory
Open

sharanggupta wants to merge 1 commit into
spring-projects:mainfrom
sharanggupta:gh-503-table-view-factory

Conversation

@sharanggupta

Copy link
Copy Markdown

Resolves #503

This adds the TableViewFactory that was discussed on the issue as the first step for TableView support, following the shape of PulsarReaderFactory / DefaultPulsarReaderFactory.

What it adds

  • PulsarTableViewFactory<T> with createTableView(topic, schema, customizers), and DefaultPulsarTableViewFactory<T>: the TableViewBuilderCustomizers 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 a PulsarTopicBuilder is set, and a PulsarClientException is wrapped in a PulsarException.
  • TableViewBuilderCustomizer<T>, the counterpart of ReaderBuilderCustomizer.
  • A "Pulsar TableView Support" section in the message consumption chapter, with the note that the caller closes the table view and that Spring Boot does not auto-configure the factory yet. If this goes in, I can follow up in Spring Boot with the PulsarTableViewFactory bean and spring.pulsar.table-view.* defaults next to the reader ones.

I did not include the @PulsarTableView annotation 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.

  • DefaultPulsarTableViewFactoryTests against 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; a PulsarTopicBuilder qualifies the topic.
  • DefaultPulsarTableViewFactoryUnitTests with a mocked PulsarClient: the default customizers, the topic and the call customizers are applied in that order, no topic is set when none is given, a PulsarClientException from create() is wrapped, and the schema is required.
  • ./gradlew :spring-pulsar:check on JDK 25 with Docker: the new tests pass against apachepulsar/pulsar:4.2.0, as do checkFormat, 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.

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>
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.

Consider adding support for TableView

1 participant