Skip to content

Commit 0250455

Browse files
committed
Add member tags, network scaling, and webhook reliability improvements
Registry: member tags per network, configurable webhook retry backoff, improved replication protocol, directory sync enhancements, stale node reap threshold increased to 5 minutes. Daemon: webhook HTTP timeout and retry backoff configuration, member tags IPC commands, policy runner improvements, tunnel peer management. Driver: DialAddrTimeout for deadline-aware connections, MemberTagsSet and MemberTagsGet IPC methods.
1 parent 2065ea9 commit 0250455

16 files changed

Lines changed: 1665 additions & 311 deletions

File tree

docs/SPEC.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Socket address includes a port: `1:0001.F291.0004:1000`
3535
| `0:0000.0000.0001` | Registry |
3636
| `0:0000.0000.0002` | Beacon |
3737
| `0:0000.0000.0003` | Nameserver |
38-
| `X:FFFF.FFFF.FFFF` | Broadcast on network X |
38+
| `X:XXXX.FFFF.FFFF` | Broadcast on network X (XXXX = X in hex, node = all-ones) |
3939

4040
---
4141

@@ -66,6 +66,7 @@ Socket address includes a port: `1:0001.F291.0004:1000`
6666
| 1001 | Data exchange | Typed frames (text, binary, JSON, file) |
6767
| 1002 | Event stream | Pub/sub with topic filtering |
6868
| 1003 | Task submit | Task submission and lifecycle |
69+
| 1004 | Managed score | Polo score exchange for managed networks |
6970

7071
---
7172

@@ -300,6 +301,8 @@ Maximum message size: 1 MB (1,048,576 bytes).
300301
| 0x20 | NetworkOK | Daemon -> Driver | `[NB JSON]` |
301302
| 0x21 | Health | Driver -> Daemon | (empty) |
302303
| 0x22 | HealthOK | Daemon -> Driver | `[NB JSON]` |
304+
| 0x23 | Managed | Driver -> Daemon | `[1B sub-cmd][NB payload]` |
305+
| 0x24 | ManagedOK | Daemon -> Driver | `[NB JSON]` |
303306

304307
### 6.2 Network Sub-Commands
305308

@@ -315,6 +318,18 @@ The Network command (0x1F) uses a sub-command byte as the first byte of the payl
315318
| 0x06 | PollInvites | (empty) |
316319
| 0x07 | RespondInvite | `[2B network_id][1B accept]` |
317320

321+
### 6.3 Managed Sub-Commands
322+
323+
The Managed command (0x23) uses a sub-command byte as the first byte of the payload:
324+
325+
| Sub-Cmd | Name | Payload |
326+
|---------|------|---------|
327+
| 0x01 | Score | `[2B network_id][4B node_id][4B delta][NB topic]` |
328+
| 0x02 | Status | `[2B network_id]` |
329+
| 0x03 | Rankings | `[2B network_id]` |
330+
| 0x04 | Cycle | `[2B network_id]` |
331+
| 0x05 | Policy | `[2B network_id][NB JSON]` |
332+
318333
---
319334

320335
## 7. Wire Examples

internal/fsutil/fsutil.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
package fsutil
22

3-
import "os"
3+
import (
4+
"fmt"
5+
"os"
6+
)
7+
8+
// AppendSync appends data to a file and fsyncs it. Used by the WAL for
9+
// durable, sequential writes. The file is opened in append mode.
10+
func AppendSync(path string, data []byte) error {
11+
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
12+
if err != nil {
13+
return fmt.Errorf("open: %w", err)
14+
}
15+
if _, err := f.Write(data); err != nil {
16+
f.Close()
17+
return fmt.Errorf("write: %w", err)
18+
}
19+
if err := f.Sync(); err != nil {
20+
f.Close()
21+
return fmt.Errorf("sync: %w", err)
22+
}
23+
return f.Close()
24+
}
425

526
// AtomicWrite writes data to a file atomically using a temp file + rename.
627
// This ensures the target file is never left in a truncated state.

pkg/beacon/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Server struct {
4343
done chan struct{} // closed on shutdown
4444
}
4545

46-
const relayQueueSize = 4096 // buffered relay jobs before backpressure
46+
const relayQueueSize = 32768 // buffered relay jobs before backpressure (increased for 1M-node scale)
4747

4848
func New() *Server {
4949
return NewWithPeers(0, nil)

0 commit comments

Comments
 (0)