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

[Core AMQP] V2 - Remove DefaultDataTransformer from the exports #12320

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sdk/core/core-amqp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 2.0.0 (Unreleased)

### Breaking changes

- `DefaultDataTransformer` is no longer exported.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not exporting the DefaultDataTransformer, but continuing to export DataTransformer interface does not give us much. The main reason for us to do this is to keep the option open in the future to implement the "serializer" in any other way.

I would recommend removing the dataTransformer property from ConnectionContextBase to allow us to stop exporting this interface from core-amqp. This will result in copying the code in the DefaultDataTransformer to Service Bus and EventHubs and use it like a static class instead of using it from the context.

In the future when we have the common code between SB & EH without needing to expose it users from core-amqp, we can move this

[PR 12320](https://github.com/Azure/azure-sdk-for-js/pull/12320)

## 2.0.0-beta.1 (2020-11-03)

- `AmqpAnnotatedMessage` interface that closely represents the AMQP annotated message from the [AMQP spec](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format) has been added. New `AmqpMessageHeaders` and `AmqpMessageProperties` interfaces(properties with camelCasing) have been added in the place of re-exports from "rhea" library(properties with snake_casing).
Expand Down
6 changes: 0 additions & 6 deletions sdk/core/core-amqp/review/core-amqp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,6 @@ export interface DataTransformer {
encode: (body: any) => any;
}

// @public
export class DefaultDataTransformer implements DataTransformer {
decode(body: any): any;
encode(body: any): any;
}

// @public
export const defaultLock: AsyncLock;

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-amqp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

export { RequestResponseLink, SendRequestOptions } from "./requestResponseLink";
export { retry, RetryOptions, RetryConfig, RetryOperationType, RetryMode } from "./retry";
export { DataTransformer, DefaultDataTransformer } from "./dataTransformer";
export { DataTransformer } from "./dataTransformer";
export { TokenType } from "./auth/token";

export { ConnectionConfig, ConnectionConfigOptions } from "./connectionConfig/connectionConfig";
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/core-amqp/test/context.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import * as chai from "chai";
const should = chai.should();
import { CbsClient, ConnectionConfig, ConnectionContextBase, DefaultDataTransformer } from "../src";
import { CbsClient, ConnectionConfig, ConnectionContextBase } from "../src";
import { Connection } from "rhea-promise";
import { isNode } from "../src/util/utils";
import { DefaultDataTransformer } from "../src/dataTransformer";

describe("ConnectionContextBase", function() {
it("should be created with required parameters", function(done) {
Expand Down
13 changes: 6 additions & 7 deletions sdk/core/core-amqp/test/dataTransformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import * as chai from "chai";
const should = chai.should();
import * as assert from "assert";
import isBuffer from "is-buffer";

import { DefaultDataTransformer } from "../src";
import { DefaultDataTransformer } from "../src/dataTransformer";

describe("DataTransformer", function() {
const objectBody: any = {
Expand Down Expand Up @@ -38,7 +37,7 @@ describe("DataTransformer", function() {
const nullBody: null = null;
const undefinedBody: undefined = undefined;
const emptyStringBody: string = "";
const bufferbody: Buffer = Buffer.from("zzz", "utf8");
const bufferBody: Buffer = Buffer.from("zzz", "utf8");
const hexBufferBody: Buffer = Buffer.from("7468697320697320612074c3a97374", "hex");
const transformer = new DefaultDataTransformer();

Expand Down Expand Up @@ -115,11 +114,11 @@ describe("DataTransformer", function() {
});

it("should correctly encode/decode a buffer message body", function(done) {
const encoded: any = transformer.encode(bufferbody);
const encoded: any = transformer.encode(bufferBody);
encoded.typecode.should.equal(117);
isBuffer(encoded.content).should.equal(true);
const decoded: any = transformer.decode(encoded);
assert.deepEqual(decoded, bufferbody);
assert.deepEqual(decoded, bufferBody);
done();
});

Expand Down Expand Up @@ -184,8 +183,8 @@ describe("DataTransformer", function() {
});

it("should correctly decode a buffer message body", function(done) {
const decoded: any = transformer.decode(bufferbody);
assert.deepEqual(decoded, bufferbody);
const decoded: any = transformer.decode(bufferBody);
assert.deepEqual(decoded, bufferBody);
done();
});

Expand Down
7 changes: 5 additions & 2 deletions sdk/servicebus/service-bus/test/internal/unittestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ReceiverEvents,
ReceiverOptions
} from "rhea-promise";
import { DefaultDataTransformer, Constants } from "@azure/core-amqp";
import { Constants } from "@azure/core-amqp";
import { AccessToken } from "@azure/core-auth";
import { EventEmitter } from "events";
import { getUniqueName } from "../../src/util/utils";
Expand Down Expand Up @@ -88,7 +88,10 @@ export function createConnectionContextForTests(
},
async close(): Promise<void> {}
},
dataTransformer: new DefaultDataTransformer(),
dataTransformer: {
encode: (data: any) => data,
decode: (data: any) => data
},
tokenCredential: {
getToken() {
return {
Expand Down