feat(device-plane): add universal adapter acceptance boundary
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
import { createCoreDiscoveryClient } from "./core-client.mjs";
|
||||
import {
|
||||
DEVICE_ADAPTER_CATALOG,
|
||||
} from "../../../packages/device-adapter-catalog/src/index.mjs";
|
||||
import { createCoreGatewayClient } from "./core-client.mjs";
|
||||
import { createDeviceGatewayRuntime } from "./runtime.mjs";
|
||||
|
||||
const config = await readConfig();
|
||||
const onDiscovery = config.listenEnabled
|
||||
? createCoreDiscoveryClient({
|
||||
const coreClient = config.listenEnabled
|
||||
? createCoreGatewayClient({
|
||||
coreUrl: config.coreUrl,
|
||||
gatewayToken: config.gatewayToken,
|
||||
timeoutMs: config.coreTimeoutMs,
|
||||
@@ -14,17 +17,25 @@ const onDiscovery = config.listenEnabled
|
||||
const runtime = createDeviceGatewayRuntime({
|
||||
listenEnabled: config.listenEnabled,
|
||||
publicIngressEnabled: config.publicIngressEnabled,
|
||||
coreChannelAuthenticated: false,
|
||||
adapterRegistry: DEVICE_ADAPTER_CATALOG.registry,
|
||||
protocolProfileRef: config.protocolProfileRef,
|
||||
edgeRef: config.edgeRef,
|
||||
routeRef: config.routeRef,
|
||||
healthHost: config.healthHost,
|
||||
healthPort: config.healthPort,
|
||||
tcpHost: config.tcpHost,
|
||||
tcpPort: config.tcpPort,
|
||||
maxBufferedBytes: config.maxBufferedBytes,
|
||||
maxAggregateBufferedBytes: config.maxAggregateBufferedBytes,
|
||||
maxConcurrentSessions: config.maxConcurrentSessions,
|
||||
maxSessionsPerAddress: config.maxSessionsPerAddress,
|
||||
maxConnectionsPerMinutePerAddress:
|
||||
config.maxConnectionsPerMinutePerAddress,
|
||||
maxTrackedSourceAddresses: config.maxTrackedSourceAddresses,
|
||||
sessionTimeoutMs: config.sessionTimeoutMs,
|
||||
onDiscovery,
|
||||
onDiscovery: coreClient?.observeDiscovery,
|
||||
onMessage: coreClient?.acceptMessage,
|
||||
});
|
||||
|
||||
const addresses = await runtime.start();
|
||||
@@ -33,7 +44,7 @@ console.log(JSON.stringify({
|
||||
health: addresses.healthAddress,
|
||||
tcp: addresses.tcpAddress,
|
||||
publicIngress: config.publicIngressEnabled
|
||||
? "discovery-only"
|
||||
? "telemetry-ingest"
|
||||
: "disabled",
|
||||
commandTransport: "disabled",
|
||||
}));
|
||||
@@ -58,6 +69,17 @@ async function readConfig() {
|
||||
return {
|
||||
listenEnabled,
|
||||
publicIngressEnabled,
|
||||
protocolProfileRef: String(
|
||||
process.env.DEVICE_GATEWAY_PROTOCOL_PROFILE_REF
|
||||
|| DEVICE_ADAPTER_CATALOG.defaultProfileRef,
|
||||
),
|
||||
edgeRef: listenEnabled
|
||||
? requiredValue(
|
||||
process.env.DEVICE_GATEWAY_EDGE_REF,
|
||||
"device_gateway_edge_ref_required",
|
||||
)
|
||||
: "edge:disabled",
|
||||
routeRef: String(process.env.DEVICE_GATEWAY_ROUTE_REF || ""),
|
||||
healthHost: String(
|
||||
process.env.DEVICE_GATEWAY_HEALTH_HOST || "127.0.0.1",
|
||||
),
|
||||
@@ -71,17 +93,25 @@ async function readConfig() {
|
||||
process.env.DEVICE_GATEWAY_MAX_BUFFERED_BYTES,
|
||||
65536,
|
||||
),
|
||||
maxAggregateBufferedBytes: parsePositiveInt(
|
||||
process.env.DEVICE_GATEWAY_MAX_AGGREGATE_BUFFERED_BYTES,
|
||||
32 * 1024 * 1024,
|
||||
),
|
||||
maxConcurrentSessions: parsePositiveInt(
|
||||
process.env.DEVICE_GATEWAY_MAX_SESSIONS,
|
||||
100,
|
||||
128,
|
||||
),
|
||||
maxSessionsPerAddress: parsePositiveInt(
|
||||
process.env.DEVICE_GATEWAY_MAX_SESSIONS_PER_ADDRESS,
|
||||
10,
|
||||
16,
|
||||
),
|
||||
maxConnectionsPerMinutePerAddress: parsePositiveInt(
|
||||
process.env.DEVICE_GATEWAY_MAX_CONNECTIONS_PER_MINUTE_PER_ADDRESS,
|
||||
30,
|
||||
60,
|
||||
),
|
||||
maxTrackedSourceAddresses: parsePositiveInt(
|
||||
process.env.DEVICE_GATEWAY_MAX_TRACKED_SOURCE_ADDRESSES,
|
||||
2048,
|
||||
),
|
||||
sessionTimeoutMs: parsePositiveInt(
|
||||
process.env.DEVICE_GATEWAY_SESSION_TIMEOUT_MS,
|
||||
|
||||
Reference in New Issue
Block a user