Skip to content

POC for Message.getSchema() - #13

Closed
eolivelli wants to merge 17 commits into
masterfrom
impl/message-getschema
Closed

eolivelli wants to merge 17 commits into
masterfrom
impl/message-getschema

Conversation

@eolivelli

@eolivelli eolivelli commented Apr 30, 2021 •

Copy link
Copy Markdown
Owner
  • rename MessageImpl and TopicMessageImpl getSchema to getSchemaInternal
  • introduce Optional<Schema<?>> Message.getSchema()
  • introduce Schema.atSchemaVersion, that allows to get a Schema at a specific "version", this is needed for AutoConsumeSchema

The schema returned by Message.getSchema has these properties:

  • SchemaInfo it what is stored on the Registry
  • getNativeSchema returns the original AVRO Schema as expected
  • it can be used for "decoding" payloads
  • it cannot be used for "encoding" payloads

BoynChan and others added 2 commits April 30, 2021 11:10
I found some wrong typing in doc when i using golang client. Most of them are package name missioning.
this.schemaInfoProvider = schemaInfoProvider;
}

public Schema<?> atSchemaVersion(byte[] schemaVersion) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asI understand, unknown schema version will result in an exception. In current implementation in RuntimeException wrapping outcome of getSchemaByVersion.

I'd make it more explicit, add "throws", throw typed exception to force code upstream handle that.

Also MultiVersionSchemaInfoProvider's loadSchema does o -> o.orElse(null) so it can return null, I don't think it is explicitly anticipated.

Please add unit tests for this case.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added explicit documentation for edge cases:

  • null schemaVersion
  • unknown schemaVersion

Also I have enhanced the default implementation, in case of support for multi version this method must be overridden.

* @return the schema at that specific version
*/
default Schema<?> atSchemaVersion(byte[] schemaVersion) {
return this;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ok if supportSchemaVersioning() == true and schema versions mismatch?
What's the contract for the case when schema at this version cannot be found? null, exception, whatever other schema version we find?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I am adding "throws SchemaSerializationException" (that is the common Schema related exception for problems with the registry)

return Optional.empty();
}
byte[] schemaVersion = getSchemaVersion();
return Optional.of(schema.atSchemaVersion(schemaVersion));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on what happens with unknown schema version, this can throw exception or may need .ofNullable

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we are consuming a Message, so if we have a version this version must exist

I believe it is good to see a RuntimeException in this impossible case

merlimat and others added 8 commits April 30, 2021 13:53
…che#10391)

* PIP-45: Implement load managers locks using coordination service

* Handle executor rejected exception when shutting down

* Fixed SimpleLoadManager still updating the load report on zk client

* Removed unused import

* Fixed imports order

* Simplified listLocks calls

* Addressed comments

* Removed updateOrCreate

* Remove additional put method that's not needed anymore

* Removed unused import

* Fixed LoadBalanceTest

* Fixed ModularLoadManagerImplTest
…onfiguration (apache#10441)

* using ObjectMapper to parse sink config
fixed minor issue in closing some of the PulsarClientImpl resources

* using ObjectMapper to parse source config

* code review changes

* removed unused import
* Improved in max-pending-bytes mechanism for broker

* Fixed imports

* Switched to LongAdder
@eolivelli
eolivelli force-pushed the impl/message-getschema branch from 58121f6 to a1d4530 Compare May 3, 2021 07:17
@eolivelli eolivelli closed this May 3, 2021
@eolivelli eolivelli reopened this May 3, 2021
@eolivelli eolivelli closed this May 3, 2021
@eolivelli

eolivelli commented May 3, 2021 •

Copy link
Copy Markdown
Owner Author

@dlg99 I had to create a new PR because GH messed up this PR when I updated master branch on this fork
#14

eolivelli added a commit that referenced this pull request Nov 8, 2021
eolivelli added a commit that referenced this pull request Nov 9, 2021
eolivelli added a commit that referenced this pull request Nov 17, 2021
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.

7 participants