@@ -184,7 +184,8 @@ struct InstanceRegistry::Impl {
184184 cwd TEXT NOT NULL,
185185 config_path TEXT NOT NULL,
186186 status TEXT NOT NULL DEFAULT 'healthy',
187- created_at INTEGER DEFAULT (strftime('%s', 'now'))
187+ created_at INTEGER DEFAULT (strftime('%s', 'now')),
188+ params TEXT
188189 );
189190
190191 CREATE INDEX IF NOT EXISTS idx_instances_heartbeat ON instances(last_heartbeat);
@@ -283,7 +284,7 @@ struct InstanceRegistry::Impl {
283284 }
284285 }
285286
286- void registerInstance (int port, const Settings &settings) {
287+ void registerInstance (int port, int watchInterval, const Settings &settings) {
287288 std::lock_guard<std::mutex> lock (dbMutex_);
288289
289290 const auto [now, nowStr] = curTimestamp ();
@@ -293,8 +294,8 @@ struct InstanceRegistry::Impl {
293294 const char *insertSQL = R"(
294295 INSERT OR REPLACE INTO instances
295296 (id, pid, port, host, project_id, name, started_at, started_at_str,
296- last_heartbeat, last_heartbeat_str, cwd, config_path, status)
297- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
297+ last_heartbeat, last_heartbeat_str, cwd, config_path, status, params )
298+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
298299 )" ;
299300
300301 SqliteStmt stmt (db_);
@@ -311,17 +312,21 @@ struct InstanceRegistry::Impl {
311312 sqlite3_bind_int (stmt.ref (), 3 , port);
312313 sqlite3_bind_text (stmt.ref (), 4 , " localhost" , -1 , SQLITE_STATIC);
313314 auto projectId = settings.getProjectId ();
314- sqlite3_bind_text (stmt.ref (), 5 , projectId.c_str (), -1 , SQLITE_STATIC );
315- sqlite3_bind_text (stmt.ref (), 6 , name.c_str (), -1 , SQLITE_STATIC );
315+ sqlite3_bind_text (stmt.ref (), 5 , projectId.c_str (), -1 , SQLITE_TRANSIENT );
316+ sqlite3_bind_text (stmt.ref (), 6 , name.c_str (), -1 , SQLITE_TRANSIENT );
316317 sqlite3_bind_int64 (stmt.ref (), 7 , now);
317- sqlite3_bind_text (stmt.ref (), 8 , nowStr.c_str (), -1 , SQLITE_STATIC );
318+ sqlite3_bind_text (stmt.ref (), 8 , nowStr.c_str (), -1 , SQLITE_TRANSIENT );
318319 sqlite3_bind_int64 (stmt.ref (), 9 , now);
319- sqlite3_bind_text (stmt.ref (), 10 , nowStr.c_str (), -1 , SQLITE_STATIC );
320+ sqlite3_bind_text (stmt.ref (), 10 , nowStr.c_str (), -1 , SQLITE_TRANSIENT );
320321 std::string cwd = std::filesystem::current_path ().string ();
321322 std::string absConfig = std::filesystem::absolute (settings.configPath ()).string ();
322323 sqlite3_bind_text (stmt.ref (), 11 , cwd.c_str (), -1 , SQLITE_TRANSIENT);
323324 sqlite3_bind_text (stmt.ref (), 12 , absConfig.c_str (), -1 , SQLITE_TRANSIENT);
324325 sqlite3_bind_text (stmt.ref (), 13 , " healthy" , -1 , SQLITE_STATIC);
326+ nlohmann::json jsonParams;
327+ jsonParams[" watch_interval" ] = watchInterval;
328+ auto paramsText = jsonParams.dump ();
329+ sqlite3_bind_text (stmt.ref (), 14 , paramsText.c_str (), -1 , SQLITE_TRANSIENT);
325330 rc = sqlite3_step (stmt.ref ());
326331 if (rc != SQLITE_DONE) {
327332 LOG_MSG << " Failed to register instance: " << sqlite3_errmsg (db_);
@@ -402,7 +407,7 @@ struct InstanceRegistry::Impl {
402407 const char *selectSQL = R"(
403408 SELECT id, pid, port, host, project_id, name, started_at,
404409 started_at_str, last_heartbeat, last_heartbeat_str,
405- cwd, config_path, status
410+ cwd, config_path, status, params
406411 FROM instances
407412 WHERE (strftime('%s', 'now') - last_heartbeat) < 30
408413 ORDER BY last_heartbeat DESC
@@ -432,6 +437,7 @@ struct InstanceRegistry::Impl {
432437 instance[" cwd" ] = stmt.getStr (j++);
433438 instance[" config" ] = stmt.getStr (j++);
434439 instance[" status" ] = stmt.getStr (j++);
440+ instance[" params" ] = stmt.getStr (j++);
435441 active.push_back (instance);
436442 }
437443 return active;
@@ -443,18 +449,18 @@ InstanceRegistry::InstanceRegistry(const std::string ®istryPath)
443449{
444450}
445451
446- InstanceRegistry::InstanceRegistry (int port, const Settings &settings, const std::string ®istryPath)
452+ InstanceRegistry::InstanceRegistry (int port, int watchInterval, const Settings &settings, const std::string ®istryPath)
447453 : imp(std::make_unique<Impl>(registryPath))
448454{
449455 imp->bRegistered_ = true ;
450- registerInstance (port, settings);
456+ registerInstance (port, watchInterval, settings);
451457}
452458
453459InstanceRegistry::~InstanceRegistry () = default ;
454460
455- void InstanceRegistry::registerInstance (int port, const Settings &settings)
461+ void InstanceRegistry::registerInstance (int port, int watchInterval, const Settings &settings)
456462{
457- imp->registerInstance (port, settings);
463+ imp->registerInstance (port, watchInterval, settings);
458464}
459465
460466void InstanceRegistry::unregister ()
0 commit comments