Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
break;
}
if (sqlRuleActionExpression !== undefined) {
ruleDescription["sql-rule-action"] = {
expression: String(sqlRuleActionExpression)
};
}
const request: AmqpMessage = {
body: {
"rule-name": types.wrap_string(ruleName),
"rule-description": types.wrap_map(ruleDescription)
},
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.addRule
}
};
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] Add Rule request body: %O.",
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);
await defaultLock.acquire(this.managementLock, () => {
return this._init();
});if (lastUpdatedTime && !(lastUpdatedTime instanceof Date)) {
throw new Error("'lastUpdatedTime' must be of type 'Date'.");
}
if (!lastUpdatedTime) {
lastUpdatedTime = new Date(Date.now() - defaultLastUpdatedTimeForListingSessions);
}
try {
const messageBody: any = {};
messageBody["last-updated-time"] = lastUpdatedTime;
messageBody["skip"] = types.wrap_int(skip);
messageBody["top"] = types.wrap_int(top);
const request: AmqpMessage = {
body: messageBody,
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.enumerateSessions
}
};
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] List sessions request body: %O.",
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);
await defaultLock.acquire(this.managementLock, () => {
return this._init();
});
const response = await this._mgmtReqResLink!.sendRequest(request);throwTypeErrorIfParameterMissing(this._context.namespace.connectionId, "ruleName", ruleName);
ruleName = String(ruleName);
throwTypeErrorIfParameterIsEmptyString(
this._context.namespace.connectionId,
"ruleName",
ruleName
);
try {
const request: AmqpMessage = {
body: {
"rule-name": types.wrap_string(ruleName)
},
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.removeRule
}
};
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] Remove Rule request body: %O.",
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);
await defaultLock.acquire(this.managementLock, () => {
return this._init();
});async getRules(): Promise {
throwErrorIfConnectionClosed(this._context.namespace);
try {
const request: AmqpMessage = {
body: {
top: types.wrap_int(max32BitNumber),
skip: types.wrap_int(0)
},
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.enumerateRules
}
};
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] Get rules request body: %O.",
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);
await defaultLock.acquire(this.managementLock, () => {
return this._init();
});const messageList: ReceivedMessageInfo[] = [];
try {
const messageBody: any = {};
messageBody[Constants.fromSequenceNumber] = types.wrap_long(
Buffer.from(fromSequenceNumber.toBytesBE())
);
messageBody[Constants.messageCount] = types.wrap_int(maxMessageCount);
if (sessionId != undefined) {
messageBody[Constants.sessionIdMapKey] = sessionId;
}
const request: AmqpMessage = {
body: messageBody,
message_id: generate_uuid(),
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.peekMessage
}
};
const associatedLinkName = this._getAssociatedReceiverName(this._context, sessionId);
if (associatedLinkName) {
request.application_properties![Constants.associatedLinkName] = associatedLinkName;
}
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] Peek by sequence number request body: %O.",
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);async getSessionState(sessionId: string): Promise {
throwErrorIfConnectionClosed(this._context.namespace);
try {
const messageBody: any = {};
messageBody[Constants.sessionIdMapKey] = sessionId;
const request: AmqpMessage = {
body: messageBody,
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.getSessionState
}
};
const associatedLinkName = this._getAssociatedReceiverName(this._context, sessionId);
if (associatedLinkName) {
request.application_properties![Constants.associatedLinkName] = associatedLinkName;
}
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] Get session state request body: %O.",
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);error = translate(err);
}
log.error(
"An error occurred while encoding the item at position %d in the messages array" + ": %O",
i,
error
);
throw error;
}
}
try {
const request: AmqpMessage = {
body: { messages: messageBody },
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.scheduleMessage
}
};
if (this._context.sender) {
request.application_properties![Constants.associatedLinkName] = this._context.sender!.name;
}
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] Schedule messages request body: %O.",
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);
await defaultLock.acquire(this.managementLock, () => {