iot_cloud/docs/endpoint.md
2026-01-13 11:56:02 +08:00

2.0 KiB
Raw Blame History

Endpoint数据结构

数据库表结构


CREATE TABLE `endpoint` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名称,路由时基于名称',
  `title` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '序列号',
  `type` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '类型',
  `config_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '配置信息基于json格式存储',
  `status` smallint NOT NULL DEFAULT '-1',
  `creator` smallint NOT NULL DEFAULT '0' COMMENT '创建人',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

config_json中的数据配置

http方式: type=http

token是可选的如果接收服务器端需要提供校验可以添加token字段校验算法采用的: $Sign = sha256(token + "post_body" + token), 有token的情况下
通过http推送的数据会增加一个header, 格式为 X-Signature: $Sign

{
  "url": "http(s)://www.test.com/api",
  "token": "ngyehngcohezqyabnlhollsfcnyqobmwfcfyvbzdbhuubucojcpeefpczruiccfw", 
  "pool_size":  10
}

mqtt方式, type=mqtt


{
  "host": "127.0.0.1",
  "port": 3361,
  "client_id": "ClientIdOfMqtt",
  "username": "root",
  "password": "Password1234",
  "topic": "mqtt_topic",
  "qos": 0
}

kafka方式, type=kafka

其中sasl_config可以不配置

{
  "bootstrap_servers": ["127.0.0.1:9090", "192.168.1.1:9090"],
  "topic": "KafkaTopic",
  "sasl_config": {
    "username": "root",    
    "password": "password1234",
    "mechanism": "sha_256|sha_512|plain" 
  }
}

关于name的规则说明

   边缘端的微服务在数据上传的时候需要指定routing_key, 服务器端收到数据后会根据 routing_key = name 对数据进行路由