Plugins provide services: hot-reload + state-saving via the registry
Re-expresses the old FSM-plugin hot-plug through the service layer, reusing the unchanged Plugin module (PluginManager, v2 serialize/ deserialize ABI, FileWatcher, atomic-rename install). Service/PluginService.hpp: PluginServiceBinding<I> resolves a plugin's exported service (extern "C" void_plugin_service(instance) -> IService*) via PluginManager::raw_symbol and registers it under interface I. The registry entry pins the plugin instance (and its mapped .so) so in-flight callers never see a freed object. enable_hot_reload() re-binds on each reload; the FSMs resolve I through their context, so a running FSM picks up the new implementation on its next service<I>() call with no code patched. I must derive IService (single inheritance) so the host recovers it from IService* by static_cast — no dynamic_cast across RTLD_LOCAL. Tests: ServicePluginV1/V2 (the plugin object is the service: IPlugin + ICalc : IService; v2 migrates v1 state via Json::MigrationChain). FsmServiceHotReload.cpp: an Orchestrator-launched FSM accumulates through the plugin service while a reloader thread flips v1<->v2 under load — state survives every migration, the FSM runs to completion, no crash; and a deterministic reload test proving the implementation swaps (version 1->2) with the running total migrated. Docs: CLAUDE.md/README updated for the new Fsm, Service, and Orchestrator (StateMachine row removed). 965 tests green, ASan+UBSan clean, stable across runs, -Werror clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5e53a4c75
commit
7b6cd7341a
8 files changed
+552
-5
No files matched your search
@@ -116,4 +116,25 @@ if(TARGET Void::Plugin)
|
||||
target_include_directories(VoidTests PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins")
|
||||
add_dependencies(VoidTests VoidStatefulPluginV1 VoidStatefulPluginV2)
|
||||
|
||||
# Service plugins (a plugin provides an IService-derived interface) for
|
||||
# the FSM x Service hot-reload integration test. Same plugin name; v2
|
||||
# migrates v1 state.
|
||||
if(TARGET Void::Service AND TARGET Void::Data)
|
||||
add_library(VoidServicePluginV1 SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins/ServicePluginV1.cpp")
|
||||
add_library(VoidServicePluginV2 SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins/ServicePluginV2.cpp")
|
||||
foreach(_sp VoidServicePluginV1 VoidServicePluginV2)
|
||||
target_link_libraries(${_sp}
|
||||
PRIVATE Void::Plugin Void::Service Void::Data)
|
||||
target_include_directories(${_sp} PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins")
|
||||
endforeach()
|
||||
target_compile_definitions(VoidTests PRIVATE
|
||||
"VOID_SERVICE_V1_PATH=\"$<TARGET_FILE:VoidServicePluginV1>\""
|
||||
"VOID_SERVICE_V2_PATH=\"$<TARGET_FILE:VoidServicePluginV2>\""
|
||||
)
|
||||
add_dependencies(VoidTests VoidServicePluginV1 VoidServicePluginV2)
|
||||
endif()
|
||||
endif()
|
||||
Reference in new issue
Block a user