Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Naming Strategies (Issue #28) #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

flqw
Copy link

@flqw flqw commented Jan 22, 2020

Adds support for the different subject name strategies provided from confluent:

  • TopicNameStrategy (the one currently supported)
    Subject: ${topic}-${isKey ? 'key' : 'value'}
  • TopicRecordNameStrategy
    Subject: ${topic}-${recordName}
  • RecordNameStrategy
    Subject: recordName

Adds the following functions:

        encodeKeyBySchema: (strategy: string, schema: any, msg: any, parseOptions?: any) => Promise<Buffer>
        encodeMessageBySchema: (strategy: string, schema: any, msg: any, parseOptions?: any) => Promise<Buffer>
        encodeMessageByTopicRecordName: (topic: string, recordName: string, msg: any, parseOptions?: any) => Promise<Buffer>
        encodeMessageByRecordName: (recordName: string, msg: any, parseOptions?: any) => Promise<Buffer>
        getSchemaByTopicRecordName: (topic: string, recordName: string, parseOptions?: any) => Promise<{ id: number, parsedSchema: any }>
        getSchemaByRecordName: (recordName: string, parseOptions?: any) => Promise<{ id: number, parsedSchema: any }>

Strategy constants can be accessed via the registry object e.g. registry.Strategy.RecordNameStrategy.

All existing functions fall back to TopicNameStrategy to be backwards compatible.

I fixed the existing tests but did not write some for the new functions, i also have not updated the readme.

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