1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.PropagationAPI = void 0;
|
19 | var global_utils_1 = require("../internal/global-utils");
|
20 | var NoopTextMapPropagator_1 = require("../propagation/NoopTextMapPropagator");
|
21 | var TextMapPropagator_1 = require("../propagation/TextMapPropagator");
|
22 | var context_helpers_1 = require("../baggage/context-helpers");
|
23 | var utils_1 = require("../baggage/utils");
|
24 | var diag_1 = require("./diag");
|
25 | var API_NAME = 'propagation';
|
26 | var NOOP_TEXT_MAP_PROPAGATOR = new NoopTextMapPropagator_1.NoopTextMapPropagator();
|
27 |
|
28 |
|
29 |
|
30 | var PropagationAPI = (function () {
|
31 |
|
32 | function PropagationAPI() {
|
33 | this.createBaggage = utils_1.createBaggage;
|
34 | this.getBaggage = context_helpers_1.getBaggage;
|
35 | this.setBaggage = context_helpers_1.setBaggage;
|
36 | this.deleteBaggage = context_helpers_1.deleteBaggage;
|
37 | }
|
38 |
|
39 | PropagationAPI.getInstance = function () {
|
40 | if (!this._instance) {
|
41 | this._instance = new PropagationAPI();
|
42 | }
|
43 | return this._instance;
|
44 | };
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 | PropagationAPI.prototype.setGlobalPropagator = function (propagator) {
|
51 | return global_utils_1.registerGlobal(API_NAME, propagator, diag_1.DiagAPI.instance());
|
52 | };
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | PropagationAPI.prototype.inject = function (context, carrier, setter) {
|
61 | if (setter === void 0) { setter = TextMapPropagator_1.defaultTextMapSetter; }
|
62 | return this._getGlobalPropagator().inject(context, carrier, setter);
|
63 | };
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | PropagationAPI.prototype.extract = function (context, carrier, getter) {
|
72 | if (getter === void 0) { getter = TextMapPropagator_1.defaultTextMapGetter; }
|
73 | return this._getGlobalPropagator().extract(context, carrier, getter);
|
74 | };
|
75 | |
76 |
|
77 |
|
78 | PropagationAPI.prototype.fields = function () {
|
79 | return this._getGlobalPropagator().fields();
|
80 | };
|
81 |
|
82 | PropagationAPI.prototype.disable = function () {
|
83 | global_utils_1.unregisterGlobal(API_NAME, diag_1.DiagAPI.instance());
|
84 | };
|
85 | PropagationAPI.prototype._getGlobalPropagator = function () {
|
86 | return global_utils_1.getGlobal(API_NAME) || NOOP_TEXT_MAP_PROPAGATOR;
|
87 | };
|
88 | return PropagationAPI;
|
89 | }());
|
90 | exports.PropagationAPI = PropagationAPI;
|
91 |
|
\ | No newline at end of file |