-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhot_reload_example.cpp
More file actions
92 lines (79 loc) · 5.11 KB
/
hot_reload_example.cpp
File metadata and controls
92 lines (79 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
╔═════════════════════════════════════════════════════════════════════╗
║ ThemisDB - Hybrid Database System ║
╠═════════════════════════════════════════════════════════════════════╣
File: hot_reload_example.cpp ║
Version: 0.0.34 ║
Last Modified: 2026-03-09 03:52:18 ║
Author: unknown ║
╠═════════════════════════════════════════════════════════════════════╣
Quality Metrics: ║
• Maturity Level: 🟢 PRODUCTION-READY ║
• Quality Score: 100.0/100 ║
• Total Lines: 91 ║
• Open Issues: TODOs: 0, Stubs: 0 ║
╠═════════════════════════════════════════════════════════════════════╣
Revision History: ║
• 2a1fb0423 2026-03-03 Merge branch 'develop' into copilot/audit-src-module-docu... ║
• a629043ab 2026-02-22 Audit: document gaps found - benchmarks and stale annotat... ║
╠═════════════════════════════════════════════════════════════════════╣
Status: ✅ Production Ready ║
╚═════════════════════════════════════════════════════════════════════╝
*/
// Example: Using the Release Manifest Service
#include "updates/release_manifest.h"
#include "updates/manifest_database.h"
#include "updates/hot_reload_engine.h"
#include <iostream>
using namespace themis;
int main() {
// 1. Create a release manifest
updates::ReleaseManifest manifest;
manifest.version = "1.2.0";
manifest.tag_name = "v1.2.0";
manifest.release_notes = "Security fixes and performance improvements";
manifest.is_critical = true;
manifest.build_commit = "abc123";
// Add files to the manifest
updates::ReleaseFile file1;
file1.path = "bin/themis_server";
file1.type = "executable";
file1.sha256_hash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
file1.size_bytes = 1024000;
file1.platform = "linux";
file1.architecture = "x64";
file1.permissions = "0755";
file1.download_url = "https://github.com/makr-code/ThemisDB/releases/download/v1.2.0/themis_server";
manifest.files.push_back(file1);
// Calculate manifest hash
manifest.manifest_hash = manifest.calculateHash();
// 2. Serialize to JSON
auto manifest_json = manifest.toJson();
std::cout << "Manifest JSON:\n" << manifest_json.dump(2) << "\n\n";
// 3. Parse from JSON
auto parsed_manifest = updates::ReleaseManifest::fromJson(manifest_json);
if (parsed_manifest) {
std::cout << "Successfully parsed manifest for version: "
<< parsed_manifest->version << "\n\n";
}
// 4. Example: Hot-reload workflow
std::cout << "Hot-Reload Workflow Example:\n";
std::cout << "1. Download release: POST /api/updates/download/1.2.0\n";
std::cout << "2. Verify release: POST /api/updates/apply/1.2.0 (verify_only=true)\n";
std::cout << "3. Apply update: POST /api/updates/apply/1.2.0\n";
std::cout << "4. If needed: POST /api/updates/rollback/rollback_xyz\n\n";
// 5. Example manifest database usage
std::cout << "Manifest Database Operations:\n";
std::cout << "- Store manifest: manifest_db->storeManifest(manifest)\n";
std::cout << "- Retrieve manifest: manifest_db->getManifest(\"1.2.0\")\n";
std::cout << "- List versions: manifest_db->listVersions()\n";
std::cout << "- Verify manifest: manifest_db->verifyManifest(manifest)\n\n";
// 6. Example hot-reload engine usage
std::cout << "Hot-Reload Engine Operations:\n";
std::cout << "- Download: engine->downloadRelease(\"1.2.0\")\n";
std::cout << "- Verify: engine->verifyRelease(manifest)\n";
std::cout << "- Apply: engine->applyHotReload(\"1.2.0\")\n";
std::cout << "- Rollback: engine->rollback(rollback_id)\n";
std::cout << "- List rollbacks: engine->listRollbackPoints()\n";
return 0;
}