47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.9 KiB
1.9 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ws_broadcast | function | go | infra | 1.0.0 | impure | func WSBroadcast(hub *WSHub, msg []byte) error | Envia bytes al canal Broadcast del hub para que se entreguen a todos los clientes WebSocket conectados. La entrega real la hace el loop Run() del hub. Bloqueante hasta que el canal Broadcast tenga espacio (capacidad 256 por defecto). Retorna error si el hub es nil. |
|
|
false | error_go_core |
|
|
error si hub es nil. Nil si el mensaje se encolo en el canal Broadcast (la entrega es asincrona). | true |
|
functions/infra/ws_test.go | functions/infra/ws_broadcast.go |
Ejemplo
hub := NewWSHub()
go hub.Run()
defer hub.Stop()
// Notificar a todos los clientes conectados
msg, _ := json.Marshal(WSMessage{
Type: "step_complete",
Payload: []byte(`{"step":"build","status":"ok"}`),
SenderID: "pipeline_runner",
Ts: time.Now().UnixMilli(),
})
WSBroadcast(hub, msg)
Notas
Bloqueante con backpressure controlado: si el canal Broadcast se llena (256 mensajes pendientes), la llamada se bloquea hasta que el hub procese alguno. Esto da feedback natural al productor cuando el sistema esta saturado.
La entrega a clientes individuales es no bloqueante (clientes lentos se desconectan automaticamente). Si necesitas semantica at-least-once con retry, montar la logica encima.