Skip to content

Commit a6a534c

Browse files
authored
[Schema Registry Avro] Prepare release (Azure#20315)
* [Schema Registry Avro] Prepare release * rename to AvroEncoder * update changelog entry * more renames
1 parent 34823ef commit a6a534c

File tree

12 files changed

+36
-38
lines changed

12 files changed

+36
-38
lines changed

sdk/schemaregistry/schema-registry-avro/CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
# Release History
22

3-
## 1.0.0-beta.6 (2022-02-09)
3+
## 1.0.0-beta.6 (2022-02-10)
44

55
### Features Added
66

77
- The encoder APIs have been revamped to work on messages instead of buffers where the payload is the pure encoded-data. The schema ID became part of the content type of that message. This change will improve the experience of using this encoder with the other messaging clients (e.g. Event Hubs, Service Bus, and Event Grid clients). The encoder also supports decoding messages with payloads that follow the old format where the schema ID was part of the payload.
88
- `decodeMessageData` now supports decoding using a different but compatible schema
99

1010
### Breaking Changes
11-
- The `SchemaRegistryAvroSerializer` class has been renamed to `SchemaRegistryAvroEncoder`
11+
- The `SchemaRegistryAvroSerializer` class has been renamed to `AvroEncoder`
1212
- The `serialize` method has been renamed to `encodeMessageData` and it now returns a message
1313
- The `deserialize` method has been renamed to `decodeMessageData` and it now takes a message as input
1414

15-
### Bugs Fixed
16-
1715
### Other Changes
1816
- The internal cache has been updated to be an LRU one with a max entries count of 128
1917

sdk/schemaregistry/schema-registry-avro/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npm install @azure/schema-registry-avro
3131

3232
## Key concepts
3333

34-
### SchemaRegistryAvroEncoder
34+
### AvroEncoder
3535

3636
Provides API to encode to and decode from Avro Binary Encoding wrapped in a message
3737
with a content type field containing the schema ID. Uses
@@ -76,13 +76,13 @@ This backward compatibility is temporary and will be removed in v1.0.0.
7676
const { DefaultAzureCredential } = require("@azure/identity");
7777
import { createEventDataAdapter } from "@azure/event-hubs";
7878
const { SchemaRegistryClient } = require("@azure/schema-registry");
79-
const { SchemaRegistryAvroEncoder } = require("@azure/schema-registry-avro");
79+
const { AvroEncoder } = require("@azure/schema-registry-avro");
8080

8181
const client = new SchemaRegistryClient(
8282
"<fully qualified namespace>",
8383
new DefaultAzureCredential()
8484
);
85-
const encoder = new SchemaRegistryAvroEncoder(client, {
85+
const encoder = new AvroEncoder(client, {
8686
groupName: "<group>",
8787
messageAdapter: createEventDataAdapter(),
8888
});

sdk/schemaregistry/schema-registry-avro/review/schema-registry-avro.api.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66

77
import { SchemaRegistry } from '@azure/schema-registry';
88

9+
// @public
10+
export class AvroEncoder<MessageT = MessageWithMetadata> {
11+
constructor(client: SchemaRegistry, options?: AvroEncoderOptions<MessageT>);
12+
decodeMessageData(message: MessageT, options?: DecodeMessageDataOptions): Promise<unknown>;
13+
encodeMessageData(value: unknown, schema: string): Promise<MessageT>;
14+
}
15+
16+
// @public
17+
export interface AvroEncoderOptions<MessageT> {
18+
autoRegisterSchemas?: boolean;
19+
groupName?: string;
20+
messageAdapter?: MessageAdapter<MessageT>;
21+
}
22+
923
// @public
1024
export interface DecodeMessageDataOptions {
1125
schema?: string;
@@ -23,20 +37,6 @@ export interface MessageWithMetadata {
2337
contentType: string;
2438
}
2539

26-
// @public
27-
export class SchemaRegistryAvroEncoder<MessageT = MessageWithMetadata> {
28-
constructor(client: SchemaRegistry, options?: SchemaRegistryAvroEncoderOptions<MessageT>);
29-
decodeMessageData(message: MessageT, options?: DecodeMessageDataOptions): Promise<unknown>;
30-
encodeMessageData(value: unknown, schema: string): Promise<MessageT>;
31-
}
32-
33-
// @public
34-
export interface SchemaRegistryAvroEncoderOptions<MessageT> {
35-
autoRegisterSchemas?: boolean;
36-
groupName?: string;
37-
messageAdapter?: MessageAdapter<MessageT>;
38-
}
39-
4040
// (No @packageDocumentation comment for this package)
4141

4242
```

sdk/schemaregistry/schema-registry-avro/samples-dev/schemaRegistryAvroSample.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { DefaultAzureCredential } from "@azure/identity";
99
import { SchemaRegistryClient, SchemaDescription } from "@azure/schema-registry";
10-
import { SchemaRegistryAvroEncoder } from "@azure/schema-registry-avro";
10+
import { AvroEncoder } from "@azure/schema-registry-avro";
1111

1212
// Load the .env file if it exists
1313
import * as dotenv from "dotenv";
@@ -66,7 +66,7 @@ export async function main() {
6666
await client.registerSchema(schemaDescription);
6767

6868
// Create a new encoder backed by the client
69-
const encoder = new SchemaRegistryAvroEncoder(client, { groupName });
69+
const encoder = new AvroEncoder(client, { groupName });
7070

7171
// encode an object that matches the schema and put it in a message
7272
const value: User = { firstName: "Jane", lastName: "Doe" };

sdk/schemaregistry/schema-registry-avro/samples-dev/withEventHubsBufferedProducerClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { DefaultAzureCredential } from "@azure/identity";
99
import { SchemaRegistryClient, SchemaDescription } from "@azure/schema-registry";
10-
import { SchemaRegistryAvroEncoder } from "@azure/schema-registry-avro";
10+
import { AvroEncoder } from "@azure/schema-registry-avro";
1111
import { EventHubBufferedProducerClient, createEventDataAdapter } from "@azure/event-hubs";
1212

1313
// Load the .env file if it exists
@@ -74,7 +74,7 @@ export async function main() {
7474
await schemaRegistryClient.registerSchema(schemaDescription);
7575

7676
// Create a new encoder backed by the client
77-
const encoder = new SchemaRegistryAvroEncoder(schemaRegistryClient, {
77+
const encoder = new AvroEncoder(schemaRegistryClient, {
7878
groupName,
7979
messageAdapter: createEventDataAdapter(),
8080
});

sdk/schemaregistry/schema-registry-avro/samples-dev/withEventHubsConsumerClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { DefaultAzureCredential } from "@azure/identity";
99
import { SchemaRegistryClient, SchemaDescription } from "@azure/schema-registry";
10-
import { SchemaRegistryAvroEncoder } from "@azure/schema-registry-avro";
10+
import { AvroEncoder } from "@azure/schema-registry-avro";
1111
import {
1212
EventHubConsumerClient,
1313
earliestEventPosition,
@@ -74,7 +74,7 @@ export async function main() {
7474
await schemaRegistryClient.registerSchema(schemaDescription);
7575

7676
// Create a new encoder backed by the client
77-
const encoder = new SchemaRegistryAvroEncoder(schemaRegistryClient, {
77+
const encoder = new AvroEncoder(schemaRegistryClient, {
7878
groupName,
7979
messageAdapter: createEventDataAdapter(),
8080
});

sdk/schemaregistry/schema-registry-avro/samples-dev/withEventHubsProducerClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { DefaultAzureCredential } from "@azure/identity";
99
import { SchemaRegistryClient, SchemaDescription } from "@azure/schema-registry";
10-
import { SchemaRegistryAvroEncoder } from "@azure/schema-registry-avro";
10+
import { AvroEncoder } from "@azure/schema-registry-avro";
1111
import { EventHubProducerClient, createEventDataAdapter } from "@azure/event-hubs";
1212

1313
// Load the .env file if it exists
@@ -73,7 +73,7 @@ export async function main() {
7373
await schemaRegistryClient.registerSchema(schemaDescription);
7474

7575
// Create a new encoder backed by the client
76-
const encoder = new SchemaRegistryAvroEncoder(schemaRegistryClient, {
76+
const encoder = new AvroEncoder(schemaRegistryClient, {
7777
groupName,
7878
messageAdapter: createEventDataAdapter(),
7979
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export { SchemaRegistryAvroEncoder } from "./schemaRegistryAvroEncoder";
4+
export { AvroEncoder } from "./schemaRegistryAvroEncoder";
55

66
export * from "./models";

sdk/schemaregistry/schema-registry-avro/src/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface MessageAdapter<MessageT> {
3333
/**
3434
* Options for Schema
3535
*/
36-
export interface SchemaRegistryAvroEncoderOptions<MessageT> {
36+
export interface AvroEncoderOptions<MessageT> {
3737
/**
3838
* When true, register new schemas passed to encodeMessageData. Otherwise, and by
3939
* default, fail if schema has not already been registered.

sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroEncoder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
DecodeMessageDataOptions,
99
MessageAdapter,
1010
MessageWithMetadata,
11-
SchemaRegistryAvroEncoderOptions,
11+
AvroEncoderOptions,
1212
} from "./models";
1313
import { SchemaDescription, SchemaRegistry } from "@azure/schema-registry";
1414
import { isMessageWithMetadata } from "./utility";
@@ -32,14 +32,14 @@ const cacheOptions: LRUCacheOptions<string, any> = {
3232
* Avro encoder that obtains schemas from a schema registry and does not
3333
* pack schemas into its payloads.
3434
*/
35-
export class SchemaRegistryAvroEncoder<MessageT = MessageWithMetadata> {
35+
export class AvroEncoder<MessageT = MessageWithMetadata> {
3636
/**
3737
* Creates a new encoder.
3838
*
3939
* @param client - Schema Registry where schemas are registered and obtained.
4040
* Usually this is a SchemaRegistryClient instance.
4141
*/
42-
constructor(client: SchemaRegistry, options?: SchemaRegistryAvroEncoderOptions<MessageT>) {
42+
constructor(client: SchemaRegistry, options?: AvroEncoderOptions<MessageT>) {
4343
this.registry = client;
4444
this.schemaGroup = options?.groupName;
4545
this.autoRegisterSchemas = options?.autoRegisterSchemas ?? false;

0 commit comments

Comments
 (0)