add Logos instance id to registry url (#20)

Allows multiple Logos core instances to run on the same machine by giving appending a unique instance identifier to each registry url.
This commit is contained in:
Eric
2026-03-16 10:43:39 -04:00
committed by GitHub
parent 95f763b48d
commit a4bd66cd6e
4 changed files with 38 additions and 4 deletions
+2 -2
View File
@@ -3,6 +3,7 @@
#include "logos_api_client.h"
#include "token_manager.h"
#include "logos_mode.h"
#include "logos_instance.h"
#include "plugin_registry.h"
#include <QRemoteObjectNode>
#include <QRemoteObjectReplica>
@@ -11,12 +12,11 @@
#include <QUrl>
#include <QMetaObject>
#include <QTime>
#include <string>
LogosAPIConsumer::LogosAPIConsumer(const QString& module_to_talk_to, const QString& origin_module, TokenManager* token_manager, QObject *parent)
: QObject(parent)
, m_node(nullptr)
, m_registryUrl(QString("local:logos_%1").arg(module_to_talk_to))
, m_registryUrl(LogosInstance::id(module_to_talk_to))
, m_connected(false)
, m_token_manager(token_manager)
{
+3 -1
View File
@@ -2,16 +2,18 @@
#include "module_proxy.h"
#include "logos_api.h"
#include "logos_mode.h"
#include "logos_instance.h"
#include "plugin_registry.h"
#include <QRemoteObjectRegistryHost>
#include <QDebug>
#include <QUrl>
#include <QMetaObject>
#include <QString>
LogosAPIProvider::LogosAPIProvider(const QString& module_name, QObject *parent)
: QObject(parent)
, m_registryHost(nullptr)
, m_registryUrl(QString("local:logos_%1").arg(module_name))
, m_registryUrl(LogosInstance::id(module_name))
, m_moduleProxy(nullptr)
{
}
+32
View File
@@ -0,0 +1,32 @@
#ifndef LOGOS_INSTANCE_H
#define LOGOS_INSTANCE_H
#include <QDebug>
#include <QString>
#include <QUuid>
/**
* @brief LogosInstance provides a shared identifier for all processes launched
* by Logos core
*
* The root process generates a UUID-based ID and exports it via the
* LOGOS_INSTANCE_ID environment variable. Child processes inherit the variable
* and return the same ID, so all processes in the application tree share one
* ID. Used by both provider and consumer to build matching registry URLs.
*/
namespace LogosInstance {
inline const QString id() {
const QByteArray inherited = qgetenv("LOGOS_INSTANCE_ID");
if (!inherited.isEmpty())
return QString::fromUtf8(inherited);
const QString newId = QUuid::createUuid().toString(QUuid::Id128).left(12);
qputenv("LOGOS_INSTANCE_ID", newId.toUtf8());
return newId;
}
inline QString id(const QString& moduleName) {
return QString("local:logos_%1_%2").arg(moduleName).arg(id());
}
}
#endif // LOGOS_INSTANCE_H