feat: set labels in NodeContext/Info
This commit is contained in:
@@ -9,23 +9,21 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
NodeContext ctx;
|
||||
NodeContext ctx({
|
||||
{"app", "base"},
|
||||
{"role", "demo"}
|
||||
});
|
||||
NetworkManager network(ctx);
|
||||
TaskManager taskManager(ctx);
|
||||
ClusterManager cluster(ctx, taskManager);
|
||||
ApiServer apiServer(ctx, taskManager, ctx.config.api_server_port);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// Setup WiFi first
|
||||
network.setupWiFi();
|
||||
|
||||
// Add example labels for this node
|
||||
auto it = ctx.memberList->find(ctx.hostname);
|
||||
if (it != ctx.memberList->end()) {
|
||||
it->second.labels["app"] = "base";
|
||||
it->second.labels["role"] = "demo";
|
||||
}
|
||||
|
||||
// Initialize and start all tasks
|
||||
taskManager.initialize();
|
||||
|
||||
|
||||
@@ -339,7 +339,12 @@ private:
|
||||
uint8_t brightness;
|
||||
};
|
||||
|
||||
NodeContext ctx;
|
||||
NodeContext ctx({
|
||||
{"app", "neopixel"},
|
||||
{"device", "light"},
|
||||
{"pixels", String(NEOPIXEL_COUNT)},
|
||||
{"pin", String(NEOPIXEL_PIN)}
|
||||
});
|
||||
NetworkManager network(ctx);
|
||||
TaskManager taskManager(ctx);
|
||||
ClusterManager cluster(ctx, taskManager);
|
||||
@@ -347,16 +352,9 @@ ApiServer apiServer(ctx, taskManager, ctx.config.api_server_port);
|
||||
NeoPixelService neoService(ctx, taskManager, NEOPIXEL_COUNT, NEOPIXEL_PIN, NEOPIXEL_TYPE);
|
||||
|
||||
void setup() {
|
||||
network.setupWiFi();
|
||||
Serial.begin(115200);
|
||||
|
||||
// Add example labels for this node
|
||||
auto it = ctx.memberList->find(ctx.hostname);
|
||||
if (it != ctx.memberList->end()) {
|
||||
it->second.labels["app"] = "neopixel";
|
||||
it->second.labels["device"] = "light";
|
||||
it->second.labels["pixels"] = String(NEOPIXEL_COUNT);
|
||||
it->second.labels["pin"] = String(NEOPIXEL_PIN);
|
||||
}
|
||||
network.setupWiFi();
|
||||
|
||||
taskManager.initialize();
|
||||
|
||||
|
||||
@@ -96,7 +96,11 @@ private:
|
||||
bool relayOn;
|
||||
};
|
||||
|
||||
NodeContext ctx;
|
||||
NodeContext ctx({
|
||||
{"app", "relay"},
|
||||
{"device", "actuator"},
|
||||
{"pin", String(RELAY_PIN)}
|
||||
});
|
||||
NetworkManager network(ctx);
|
||||
TaskManager taskManager(ctx);
|
||||
ClusterManager cluster(ctx, taskManager);
|
||||
@@ -104,17 +108,11 @@ ApiServer apiServer(ctx, taskManager, ctx.config.api_server_port);
|
||||
RelayService relayService(ctx, taskManager, RELAY_PIN);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// Setup WiFi first
|
||||
network.setupWiFi();
|
||||
|
||||
// Add example labels for this node
|
||||
auto it = ctx.memberList->find(ctx.hostname);
|
||||
if (it != ctx.memberList->end()) {
|
||||
it->second.labels["app"] = "relay";
|
||||
it->second.labels["device"] = "actuator";
|
||||
it->second.labels["pin"] = String(RELAY_PIN);
|
||||
}
|
||||
|
||||
// Initialize and start all tasks
|
||||
taskManager.initialize();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user