@azure/eventgrid
Advanced tools
Comparing version 3.0.0-alpha.20200929.1 to 3.0.0-alpha.20201002.1
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import { __awaiter } from "tslib"; | ||
import { createPipelineFromOptions, generateUuid } from "@azure/core-http"; | ||
@@ -8,2 +9,5 @@ import { createEventGridCredentialPolicy } from "./eventGridAuthenticationPolicy"; | ||
import { GeneratedClient } from "./generated/generatedClient"; | ||
import { cloudEventDistributedTracingEnricherPolicy } from "./cloudEventDistrubtedTracingEnricherPolicy"; | ||
import { createSpan } from "./tracing"; | ||
import { CanonicalCode } from "@opentelemetry/api"; | ||
/** | ||
@@ -45,2 +49,3 @@ * Client class for publishing events to the Event Grid Service. | ||
const pipeline = createPipelineFromOptions(options, authPolicy); | ||
pipeline.requestPolicyFactories.push(cloudEventDistributedTracingEnricherPolicy()); | ||
this.client = new GeneratedClient(pipeline); | ||
@@ -55,8 +60,15 @@ this.apiVersion = this.client.apiVersion; | ||
sendEvents(events, options) { | ||
return this.client | ||
.publishEvents(this.endpointUrl, (events || []).map(convertEventGridEventToModelType), options) | ||
.then((r) => { | ||
return { | ||
_response: r._response | ||
}; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { span, updatedOptions } = createSpan("EventGridPublisherClient-sendEvents", options || {}); | ||
try { | ||
const r = yield this.client.publishEvents(this.endpointUrl, (events || []).map(convertEventGridEventToModelType), updatedOptions); | ||
return buildResponse(r); | ||
} | ||
catch (e) { | ||
span.setStatus({ code: CanonicalCode.UNKNOWN, message: e.message }); | ||
throw e; | ||
} | ||
finally { | ||
span.end(); | ||
} | ||
}); | ||
@@ -70,8 +82,15 @@ } | ||
sendCloudEvents(events, options) { | ||
return this.client | ||
.publishCloudEventEvents(this.endpointUrl, (events || []).map(convertCloudEventToModelType), options) | ||
.then((r) => { | ||
return { | ||
_response: r._response | ||
}; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { span, updatedOptions } = createSpan("EventGridPublisherClient-sendCloudEvents", options || {}); | ||
try { | ||
const r = yield this.client.publishCloudEventEvents(this.endpointUrl, (events || []).map(convertCloudEventToModelType), updatedOptions); | ||
return buildResponse(r); | ||
} | ||
catch (e) { | ||
span.setStatus({ code: CanonicalCode.UNKNOWN, message: e.message }); | ||
throw e; | ||
} | ||
finally { | ||
span.end(); | ||
} | ||
}); | ||
@@ -85,11 +104,25 @@ } | ||
sendCustomSchemaEvents(events, options) { | ||
return this.client | ||
.publishCustomEventEvents(this.endpointUrl, events || [], options) | ||
.then((r) => { | ||
return { | ||
_response: r._response | ||
}; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { span, updatedOptions } = createSpan("EventGridPublisherClient-sendCustomSchemaEvents", options || {}); | ||
try { | ||
const r = yield this.client.publishCustomEventEvents(this.endpointUrl, events || [], updatedOptions); | ||
return buildResponse(r); | ||
} | ||
catch (e) { | ||
span.setStatus({ code: CanonicalCode.UNKNOWN, message: e.message }); | ||
throw e; | ||
} | ||
finally { | ||
span.end(); | ||
} | ||
}); | ||
} | ||
} | ||
function buildResponse(r) { | ||
const ret = { _response: r._response }; | ||
Object.defineProperty(ret, "_response", { | ||
enumerable: false | ||
}); | ||
return ret; | ||
} | ||
/** | ||
@@ -96,0 +129,0 @@ * @internal |
@@ -6,3 +6,3 @@ { | ||
"description": "An isomorphic client library for the Azure Event Grid service.", | ||
"version": "3.0.0-alpha.20200929.1", | ||
"version": "3.0.0-alpha.20201002.1", | ||
"keywords": [ | ||
@@ -9,0 +9,0 @@ "node", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1273659
49
15598