Plugin: publish reloadable module contract

This commit is contained in:
faumaray committed 2026-07-28 23:04:26 +03:00
1 parent 16d94a174a
commit 35bf05b3e1
4 files changed
+59 -2

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
build*/
.cache/
+3
View File
@@ -41,9 +41,12 @@ add_library(EchoionUrlShortenerInternalPlugin MODULE
target_include_directories(EchoionUrlShortenerInternalPlugin PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(EchoionUrlShortenerInternalPlugin PRIVATE cxx_std_26)
target_compile_definitions(EchoionUrlShortenerInternalPlugin PRIVATE
"ECHOION_COMPONENT_VERSION=\"${PROJECT_VERSION}\"")
target_link_libraries(EchoionUrlShortenerInternalPlugin PRIVATE
Echoion::ApiPlugin
Echoion::ApiConfig
Echoion::ApiModuleAbi
Echoion::ApiPluginSdk
Void::ShortUrl
Void::Data
+14
View File
@@ -0,0 +1,14 @@
{
"schemaVersion": 1,
"contractId": "echoion.plugin.url-shortener-internal",
"descriptor": "Void::Plugin::ModuleDescriptor",
"moduleId": "url-shortener-internal",
"activationPolicy": "reloadable",
"services": [
{
"id": "void.short-url",
"version": 1,
"type": "Void::ShortUrl::IShortener"
}
]
}
+40 -2
View File
@@ -1,4 +1,5 @@
#include <echoion/api/plugin/ShortUrlSupport.hpp>
#include <echoion/api/module/Module.hpp>
#include <echoion/plugins/short_url/InternalStore.hpp>
#include <ExtensionPlugin.hpp>
@@ -23,7 +24,7 @@ namespace Echoion::Plugins::ShortUrl
namespace
{
constexpr std::string_view kPluginId{"url-shortener-internal"};
constexpr std::string_view kPluginVersion{"1.0.0"};
constexpr std::string_view kPluginVersion{ECHOION_COMPONENT_VERSION};
[[nodiscard]] const Void::Json::Value&
settingsObject(const Void::Json::Value& root) noexcept
@@ -372,10 +373,47 @@ namespace Echoion::Plugins::ShortUrl
std::unique_ptr<InternalStore> store_;
};
std::unique_ptr<Void::Plugin::IModule> createModule()
{
return std::make_unique<InternalShortenerPlugin>();
}
const Void::Plugin::ModuleDescriptor& moduleDescriptor()
{
static const Void::Plugin::ModuleDescriptor descriptor{
.module_id = "url-shortener-internal",
.component_version = {.major = 2, .minor = 0, .patch = 0},
.abi_hash =
"sha256:68e338e9fd65bfad73364587af7e1c95f6ce98fe2ab08922113d9d240a4c8a39",
.abi_contract = Void::Json::object({
{"schemaVersion", 1},
{"contractId", "echoion.plugin.url-shortener-internal"},
{"descriptor", "Void::Plugin::ModuleDescriptor"},
}),
.dependencies =
{
{
.module_id = "EchoionApi",
.version_range = "^2.0.0",
.abi_hash =
"sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3",
},
},
.activation_policy = Void::Plugin::ActivationPolicy::Reloadable,
.create = createModule,
};
return descriptor;
}
} // namespace Echoion::Plugins::ShortUrl
extern "C" {
const Void::Plugin::ModuleDescriptor* echoion_module_query()
{
return &Echoion::Plugins::ShortUrl::moduleDescriptor();
}
void* void_plugin_create()
{
return std::make_unique<
@@ -395,7 +433,7 @@ Void::Plugin::PluginInfo void_plugin_info()
return {
.abi_version = Void::Plugin::ABI_VERSION,
.name = "url-shortener-internal",
.plugin_version = "1.0.0",
.plugin_version = ECHOION_COMPONENT_VERSION,
.description = "Persistent Echoion-hosted URL shortener",
};
}