页:1 简体中文
阿里巴巴云事件 Bridge SDK
所需资源
- 节点.js >= 8.x
安装
如果您使用 npm 用于管理您的依赖,您可以使用以下命令:
$ npm install @alicloud/eventbridge -S
快速示例
在你开始之前,你需要报名 一个阿里巴巴云账户 并收回你的 全权证书。 。 。 .
演示
import Client, * as $eventbridge from "@alicloud/eventbridge"
import Util from "@alicloud/tea-util";
const config = new $eventbridge.Config();
config.endpoint = "your endpoint";
config.accessKeyId = "your access key id";
config.accessKeySecret = "your access key secret";
// init client
const client = new Client(config);
// init request
const event = new $eventbridge.CloudEvent();
event.datacontenttype = "application/json";
event.data = Util.toBytes("test");
event.id = "id";
event.source = "source";
event.specversion = "1.0";
event.type = "type";
event.time = "2020-08-24T13:54:05.965Asia/Shanghai";
event.subject = "1.0";
event.extensions = {
"aliyuneventbusname": "demo-bus"
};
// call api
const resp = client.putEvents([event]);
参数规格
const config = {
AccessKeyId: "AccessKeyId", // AccessKey Id
AccessKeySecret: "AccessKeySecret", // AccessKey Secret
Credential: credential.Credential, // // credential,If you have any questions, please refer to it https://github.com/aliyun/credentials-nodejs/
SecurityToken: "SecurityToken", // Security Token
Endpoint: "Endpoint", // endpoint
Protocol: "Protocol", // http or https
RegionId: "RegionId", // region
ReadTimeout: "ReadTimeout", // read timeout
ConnectTimeout: "ConnectTimeout", // connect tiemout
HttpProxy: "HttpProxy", // http proxy
HttpsProxy: "HttpsProxy", // https proxy
NoProxy: "NoProxy", // agent whitelist
MaxIdleConns: "MaxIdleConns", // maximum number of connections
};
const RuntimeOptions = {
Autoretry: "Autoretry", // whether to enable retry
IgnoreSSL: "IgnoreSSL", // whether SSL validation is ignored
MaxAttempts: "MaxAttempts", // maximum number of retries, defaut: 3
BackoffPolicy: "BackoffPolicy", // retry the sleep strategy, default: no
BackoffPeriod: "BackoffPeriod", // retry the sleep time,default: 1
ReadTimeout: "ReadTimeout", // read timeout
ConnectTimeout: "ConnectTimeout", // connect timeout
LocalAddr: "LocalAddr", // the local network adapter ip
HttpProxy: "HttpProxy", // http proxy
HttpsProxy: "HttpsProxy", // https proxy
NoProxy: "NoProxy", // agent whitelist
MaxIdleConns: "MaxIdleConns", // maximum number of connections
Socks5Proxy: "Socks5Proxy", // socks5 proxy
Socks5NetWork: "Socks5NetWork" // socks5 agency agreement
};
问题
开 幕 问 题,不符合准则的问题可立即结案.
参考资料
许可证
版权 (c) 2009年至今,阿里巴巴云 版权所有.