- Add Spore class as unified interface for all core framework functionality - Implement setup() and begin() methods for flexible initialization pattern - Add service registration with addService() for both raw and smart pointers - Provide accessor methods for core components (getTaskManager, getContext, etc.) - Automatically include core services (Node, Network, Cluster, Task) - Update all examples to use simplified Spore framework approach - Fix circular dependency issues in include structure - Remove setHostname and setApiPort configuration methods - Add comprehensive documentation and usage examples The Spore class encapsulates all core functionality from the base example and provides a clean, unified API for the entire framework. Examples now use just spore.setup() -> add services -> spore.begin() -> spore.loop().
30 lines
848 B
C++
30 lines
848 B
C++
#pragma once
|
|
#include "NodeContext.h"
|
|
#include "NodeInfo.h"
|
|
#include "TaskManager.h"
|
|
#include <Arduino.h>
|
|
#include <ESP8266WiFi.h>
|
|
#include <ArduinoJson.h>
|
|
#include <ESP8266HTTPClient.h>
|
|
#include <map>
|
|
|
|
class ClusterManager {
|
|
public:
|
|
ClusterManager(NodeContext& ctx, TaskManager& taskMgr);
|
|
void registerTasks();
|
|
void sendDiscovery();
|
|
void listenForDiscovery();
|
|
void addOrUpdateNode(const String& nodeHost, IPAddress nodeIP);
|
|
void updateAllNodeStatuses();
|
|
void removeDeadNodes();
|
|
void printMemberList();
|
|
const std::map<String, NodeInfo>& getMemberList() const { return *ctx.memberList; }
|
|
void fetchNodeInfo(const IPAddress& ip);
|
|
void updateLocalNodeResources();
|
|
void heartbeatTaskCallback();
|
|
void updateAllMembersInfoTaskCallback();
|
|
private:
|
|
NodeContext& ctx;
|
|
TaskManager& taskManager;
|
|
};
|