feat(ipcclient): Add clientOnly mode to prevent clients from auto-starting servers and improve registration/reconnect behavior
This commit is contained in:
29
readme.md
29
readme.md
@@ -238,6 +238,33 @@ await client.connect({
|
||||
});
|
||||
```
|
||||
|
||||
### 🛑 Client-Only Mode (No Auto-Start)
|
||||
|
||||
In some setups (CLI + long-running daemon), you want clients to fail fast when no server is available, rather than implicitly becoming the server. Enable client-only mode to prevent the “client becomes server” fallback for Unix domain sockets and Windows named pipes.
|
||||
|
||||
```typescript
|
||||
// Strict client that never auto-starts a server on connect failure
|
||||
const client = SmartIpc.createClient({
|
||||
id: 'my-service',
|
||||
socketPath: '/tmp/my-service.sock',
|
||||
clientId: 'my-cli',
|
||||
clientOnly: true, // NEW: disable auto-start fallback
|
||||
connectRetry: { enabled: false } // optional: fail fast
|
||||
});
|
||||
|
||||
try {
|
||||
await client.connect();
|
||||
} catch (err) {
|
||||
// With clientOnly: true, errors become descriptive
|
||||
// e.g. "Server not available (ENOENT); clientOnly prevents auto-start"
|
||||
console.error(err.message);
|
||||
}
|
||||
```
|
||||
|
||||
- Default: `clientOnly` is `false` to preserve backward compatibility.
|
||||
- Env override: set `SMARTIPC_CLIENT_ONLY=1` to enforce client-only behavior without code changes.
|
||||
- Note: `SmartIpc.waitForServer()` internally uses `clientOnly: true` for safe probing.
|
||||
|
||||
### 💓 Graceful Heartbeat Monitoring
|
||||
|
||||
Keep connections alive without crashing on timeouts:
|
||||
@@ -594,4 +621,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
Reference in New Issue
Block a user