@avalw/search-worker 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -25
- package/bin/cli.js +10 -10
- package/index.js +11 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -81,34 +81,11 @@ npm install -g @avalw/search-worker
|
|
|
81
81
|
npx @avalw/search-worker --token YOUR_TOKEN
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
## What's New in v2.
|
|
84
|
+
## What's New in v2.1.0
|
|
85
85
|
|
|
86
86
|
```
|
|
87
87
|
┌────────────────────────────────────────────────────────────────┐
|
|
88
|
-
│
|
|
89
|
-
├────────────────────────────────────────────────────────────────┤
|
|
90
|
-
│ │
|
|
91
|
-
│ Your worker now directly powers avalw.org search! │
|
|
92
|
-
│ │
|
|
93
|
-
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
94
|
-
│ │ Real-Time │ │ Instant │ │ Global │ │
|
|
95
|
-
│ │ Integration │ │ Cache │ │ Impact │ │
|
|
96
|
-
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
97
|
-
│ │
|
|
98
|
-
│ • Every search on avalw.org checks your worker first │
|
|
99
|
-
│ • Cache hits served in 1-2ms (vs 50-100ms from database) │
|
|
100
|
-
│ • Your cached results help millions of users │
|
|
101
|
-
│ • Cronos Browser users benefit from your contribution │
|
|
102
|
-
│ • See real-time stats on worker.avalw.org │
|
|
103
|
-
│ │
|
|
104
|
-
└────────────────────────────────────────────────────────────────┘
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Intelligent Cache System
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
┌────────────────────────────────────────────────────────────────┐
|
|
111
|
-
│ SMART CACHING FEATURES │
|
|
88
|
+
│ INTELLIGENT CACHE SYSTEM │
|
|
112
89
|
├────────────────────────────────────────────────────────────────┤
|
|
113
90
|
│ │
|
|
114
91
|
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
package/bin/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* AVALW Search Worker CLI v2.
|
|
4
|
+
* AVALW Search Worker CLI v2.3.2
|
|
5
5
|
* Distributed Cache Worker for AVALW Search Network
|
|
6
6
|
*
|
|
7
7
|
* Features:
|
|
@@ -54,7 +54,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
54
54
|
|
|
55
55
|
function showHelp() {
|
|
56
56
|
console.log(`
|
|
57
|
-
AVALW Search Worker v2.
|
|
57
|
+
AVALW Search Worker v2.1.0 - Intelligent Distributed Cache
|
|
58
58
|
|
|
59
59
|
USAGE:
|
|
60
60
|
npx @avalw/search-worker [options]
|
|
@@ -133,7 +133,7 @@ Or set environment variable:
|
|
|
133
133
|
// Print banner
|
|
134
134
|
console.log('');
|
|
135
135
|
console.log('===============================================================');
|
|
136
|
-
console.log(' AVALW SEARCH WORKER v2.
|
|
136
|
+
console.log(' AVALW SEARCH WORKER v2.3.2 - Intelligent Distributed Cache');
|
|
137
137
|
console.log('===============================================================');
|
|
138
138
|
console.log('');
|
|
139
139
|
|
|
@@ -184,14 +184,14 @@ const worker = new SearchWorker({
|
|
|
184
184
|
console.log(' [DISCONNECTED] Lost connection to coordinator');
|
|
185
185
|
},
|
|
186
186
|
|
|
187
|
-
onCacheHit: () => {
|
|
188
|
-
|
|
189
|
-
console.log(` [CACHE HIT] Served
|
|
187
|
+
onCacheHit: (key) => {
|
|
188
|
+
const query = key.split(':')[0];
|
|
189
|
+
console.log(` [CACHE HIT] Served: "${query.substring(0, 30)}..."`);
|
|
190
190
|
},
|
|
191
191
|
|
|
192
|
-
onCacheStore: () => {
|
|
193
|
-
|
|
194
|
-
console.log(` [CACHED] Stored
|
|
192
|
+
onCacheStore: (key) => {
|
|
193
|
+
const query = key.split(':')[0];
|
|
194
|
+
console.log(` [CACHED] Stored: "${query.substring(0, 30)}..."`);
|
|
195
195
|
},
|
|
196
196
|
|
|
197
197
|
onError: (err) => {
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @avalw/search-worker v2.2
|
|
2
|
+
* @avalw/search-worker v2.3.2
|
|
3
3
|
* Distributed Cache Worker for AVALW Search Network
|
|
4
4
|
*
|
|
5
5
|
* Workers connect to the coordinator via WebSocket and serve as
|
|
@@ -596,8 +596,7 @@ class SearchWorker {
|
|
|
596
596
|
// Invalidate a cache key
|
|
597
597
|
if (message.key) {
|
|
598
598
|
this.cache._evict(message.key, 'invalidate');
|
|
599
|
-
|
|
600
|
-
this.onLog(`Cache entry invalidated`);
|
|
599
|
+
this.onLog(`Cache invalidated: ${message.key.substring(0, 30)}...`);
|
|
601
600
|
}
|
|
602
601
|
break;
|
|
603
602
|
|
|
@@ -638,8 +637,7 @@ class SearchWorker {
|
|
|
638
637
|
value
|
|
639
638
|
});
|
|
640
639
|
|
|
641
|
-
|
|
642
|
-
this.onLog(`Cache HIT - served result #${this.stats.cacheHits}`);
|
|
640
|
+
this.onLog(`Cache HIT: ${key.substring(0, 30)}...`);
|
|
643
641
|
} else {
|
|
644
642
|
this.stats.cacheMisses++;
|
|
645
643
|
|
|
@@ -669,8 +667,7 @@ class SearchWorker {
|
|
|
669
667
|
this.onCacheStore(key);
|
|
670
668
|
|
|
671
669
|
const cacheStats = this.cache.getStats();
|
|
672
|
-
|
|
673
|
-
this.onLog(`Cached result #${this.stats.cacheStored} (${cacheStats.entries} entries, ${cacheStats.sizeFormatted})`);
|
|
670
|
+
this.onLog(`Cached: ${key.substring(0, 30)}... (${cacheStats.entries} entries, ${cacheStats.sizeFormatted})`);
|
|
674
671
|
}
|
|
675
672
|
|
|
676
673
|
// Send cache registry to coordinator
|
|
@@ -730,33 +727,30 @@ class SearchWorker {
|
|
|
730
727
|
|
|
731
728
|
// Send heartbeat to HTTP dashboard
|
|
732
729
|
_sendHttpHeartbeat(cpuUsage, systemInfo) {
|
|
733
|
-
const cacheStats = this.cache.getStats();
|
|
734
730
|
const data = JSON.stringify({
|
|
735
731
|
worker_token: this.workerToken,
|
|
736
732
|
system_info: {
|
|
737
733
|
...systemInfo,
|
|
738
734
|
cpu_usage: cpuUsage,
|
|
739
735
|
memory_usage: Math.round((1 - os.freemem() / os.totalmem()) * 100 * 10) / 10,
|
|
740
|
-
session_core_hours: this._calculateCoreHours()
|
|
741
|
-
// Cache stats for dashboard
|
|
742
|
-
cache_entries: cacheStats.entries,
|
|
743
|
-
cache_bytes: cacheStats.sizeBytes,
|
|
744
|
-
cache_served: this.stats.requestsServed
|
|
736
|
+
session_core_hours: this._calculateCoreHours()
|
|
745
737
|
}
|
|
746
738
|
});
|
|
747
739
|
|
|
748
740
|
const url = new URL('/api/worker/heartbeat', this.dashboardUrl);
|
|
749
741
|
const isHttps = url.protocol === 'https:';
|
|
750
742
|
|
|
743
|
+
const headers = {
|
|
744
|
+
'Content-Type': 'application/json',
|
|
745
|
+
'Content-Length': Buffer.byteLength(data)
|
|
746
|
+
};
|
|
747
|
+
|
|
751
748
|
const options = {
|
|
752
749
|
hostname: url.hostname,
|
|
753
750
|
port: url.port || (isHttps ? 443 : 80),
|
|
754
751
|
path: url.pathname,
|
|
755
752
|
method: 'POST',
|
|
756
|
-
headers
|
|
757
|
-
'Content-Type': 'application/json',
|
|
758
|
-
'Content-Length': Buffer.byteLength(data)
|
|
759
|
-
}
|
|
753
|
+
headers
|
|
760
754
|
};
|
|
761
755
|
|
|
762
756
|
const req = (isHttps ? https : http).request(options, (res) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalw/search-worker",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"description": "AVALW Distributed Cache Worker -
|
|
3
|
+
"version": "2.3.2",
|
|
4
|
+
"description": "AVALW Distributed Cache Worker - Intelligent caching with size limits and auto-cleanup",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"avalw-worker": "./bin/cli.js"
|