
The configuration mechanism consists of the following concepts: Specification Specifies the available configuration parameters of a module, their names and their types. Param Specifies a parameter, its name and its type. Type Specifies the type of a configuration parameters; Bool, Size, Count, etc. Configuration Specifies the configuration values of a particular instance of the module. Configuration walks hand in hand with Specification, the latter specifies what the former should contain. A Specification is capable of configuring a Configuration from a MXS_CONFIG_PARAMETER, checking in the process that all parameters are of the correct type and that the required parameters are present. A Specification is capable of persisting itself so that it later can be read back. The mechanism is closed for modification but open for extension in the sense that if a module requires a custom parameter, all it needs to do is to derive one class from Param and another from Type. The canonical way for using this mechanism is as follows. Consider a module xyx that has three parameters; a parameter called "enabled" that is of boolean type, a parameter called "period" that is of duration type, and a parameter "cache" that is of size type. That would be declared as follows: // xyz.hh class XYZSession; class XYZ : public maxscale::Filter<XYZ, XYZSession> { public: static XYZ* create(const char* zName, MXS_CONFIG_PARAMETER* pParams); private: XYZ(); static config::Specification s_specification; static config::ParamBool s_enabled; static config::ParamDuration<std::chrono::seconds> s_period; static config::ParamSize s_cache; config::Configuration m_configuration; config::Bool m_enabled; config::Duration<std::chrono::seconds> m_period; config::Size m_cache; }; // xyz.cc config::Specification XYZ::s_specification(MXS_MODULE_NAME); config::ParamBool XYZ::s_enabled( &s_specification, "enabled", "Specifies whether ... should be enabled or not." ); config::ParamDuration<std::chrono::seconds> XYZ::s_period( &s_specification, "period", "Specifies the period. Rounded to the nearest second." ); config::ParamSize XYZ::s_cache( &s_specification, "cache", "Specifies the size of the internal cache." ); XYZ::XYZ() : m_configuration(&s_specification) , m_enabled(&m_configuration, &s_enabled) , m_period(&m_configuration, &s_period) , m_cache(&m_configuration, &s_cache) { } XYZ* XYZ::create(const char* zName, MXS_CONFIG_PARAMETER* pParams) { XYZ* pXyz = new XYZ; if (!s_specification.configure(pXyz->m_configuration, pParams)) { delete pXyz; pXyz = nullptr; } return pXyz; }
96 lines
4.8 KiB
CMake
96 lines
4.8 KiB
CMake
add_executable(profile_trxboundaryparser profile_trxboundaryparser.cc)
|
|
add_executable(test_adminusers test_adminusers.cc)
|
|
add_executable(test_atomic test_atomic.cc)
|
|
add_executable(test_buffer test_buffer.cc)
|
|
add_executable(test_config test_config.cc)
|
|
add_executable(test_config2 test_config2.cc)
|
|
add_executable(test_dcb test_dcb.cc)
|
|
add_executable(test_event test_event.cc)
|
|
add_executable(test_filter test_filter.cc)
|
|
add_executable(test_hint test_hint.cc)
|
|
add_executable(test_housekeeper test_housekeeper.cc)
|
|
add_executable(test_http test_http.cc)
|
|
add_executable(test_json test_json.cc)
|
|
add_executable(test_local_address test_local_address.cc)
|
|
add_executable(test_log test_log.cc)
|
|
add_executable(test_logorder test_logorder.cc)
|
|
add_executable(test_logthrottling test_logthrottling.cc)
|
|
add_executable(test_maxscalepcre2 test_maxscalepcre2.cc)
|
|
add_executable(test_modulecmd test_modulecmd.cc)
|
|
add_executable(test_modutil test_modutil.cc)
|
|
add_executable(test_poll test_poll.cc)
|
|
add_executable(test_server test_server.cc)
|
|
add_executable(test_service test_service.cc)
|
|
add_executable(test_trxcompare test_trxcompare.cc ../../../query_classifier/test/testreader.cc)
|
|
add_executable(test_trxtracking test_trxtracking.cc)
|
|
add_executable(test_users test_users.cc)
|
|
add_executable(test_utils test_utils.cc)
|
|
add_executable(test_session_track test_session_track.cc)
|
|
|
|
target_link_libraries(profile_trxboundaryparser maxscale-common)
|
|
target_link_libraries(test_adminusers maxscale-common)
|
|
target_link_libraries(test_atomic maxscale-common)
|
|
target_link_libraries(test_buffer maxscale-common)
|
|
target_link_libraries(test_config maxscale-common)
|
|
target_link_libraries(test_config2 maxscale-common)
|
|
target_link_libraries(test_dcb maxscale-common)
|
|
target_link_libraries(test_event maxscale-common)
|
|
target_link_libraries(test_filter maxscale-common)
|
|
target_link_libraries(test_hint maxscale-common)
|
|
target_link_libraries(test_housekeeper maxscale-common)
|
|
target_link_libraries(test_http maxscale-common)
|
|
target_link_libraries(test_json maxscale-common)
|
|
target_link_libraries(test_local_address maxscale-common)
|
|
target_link_libraries(test_log maxscale-common)
|
|
target_link_libraries(test_logorder maxscale-common)
|
|
target_link_libraries(test_logthrottling maxscale-common)
|
|
target_link_libraries(test_maxscalepcre2 maxscale-common)
|
|
target_link_libraries(test_modulecmd maxscale-common)
|
|
target_link_libraries(test_modutil maxscale-common)
|
|
target_link_libraries(test_poll maxscale-common)
|
|
target_link_libraries(test_server maxscale-common)
|
|
target_link_libraries(test_service maxscale-common)
|
|
target_link_libraries(test_trxcompare maxscale-common)
|
|
target_link_libraries(test_trxtracking maxscale-common)
|
|
target_link_libraries(test_users maxscale-common)
|
|
target_link_libraries(test_utils maxscale-common)
|
|
target_link_libraries(test_session_track mysqlcommon)
|
|
|
|
add_test(test_adminusers test_adminusers)
|
|
add_test(test_atomic test_atomic)
|
|
add_test(test_buffer test_buffer)
|
|
add_test(test_config test_config)
|
|
add_test(test_config2 test_config2)
|
|
add_test(test_dcb test_dcb)
|
|
add_test(test_event test_event)
|
|
add_test(test_filter test_filter)
|
|
add_test(test_hint test_hint)
|
|
add_test(test_housekeeper test_housekeeper)
|
|
add_test(test_http test_http)
|
|
add_test(test_json test_json)
|
|
add_test(test_log test_log)
|
|
add_test(NAME test_logorder COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/logorder.sh 200 0 1000 ${CMAKE_CURRENT_BINARY_DIR}/logorder.log)
|
|
add_test(test_logthrottling test_logthrottling)
|
|
add_test(NAME test_maxpasswd COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_maxpasswd.sh)
|
|
add_test(test_maxscalepcre2 test_maxscalepcre2)
|
|
add_test(test_modulecmd test_modulecmd)
|
|
add_test(test_modutil test_modutil)
|
|
add_test(test_poll test_poll)
|
|
add_test(test_server test_server)
|
|
add_test(test_service test_service)
|
|
add_test(test_trxcompare_create test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/create.test)
|
|
add_test(test_trxcompare_delete test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/delete.test)
|
|
add_test(test_trxcompare_insert test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/insert.test)
|
|
add_test(test_trxcompare_join test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/join.test)
|
|
add_test(test_trxcompare_select test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/select.test)
|
|
add_test(test_trxcompare_set test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/set.test)
|
|
add_test(test_trxcompare_update test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/update.test)
|
|
add_test(test_trxcompare_maxscale test_trxcompare ${CMAKE_CURRENT_SOURCE_DIR}/../../../query_classifier/test/maxscale.test)
|
|
add_test(test_trxtracking test_trxtracking)
|
|
add_test(test_users test_users)
|
|
add_test(test_utils test_utils)
|
|
add_test(test_session_track test_session_track)
|
|
|
|
add_subdirectory(rest-api)
|
|
add_subdirectory(canonical_tests)
|