refactor(infra): split de drivers pesados a subpaquetes + fix TestSSEHandler
Mueve duckdb_open, clickhouse_open, postgres_open, matrix_* y keyring_token_store
del paquete monolitico functions/infra a subpaquetes propios
(functions/infra/{duckdb,clickhouse,postgres,matrix,keyring}). El paquete infra ya
no importa los drivers (go-duckdb, clickhouse-go, pgx, mautrix, go-keyring), por lo
que las apps que solo usan funciones ligeras (process, cron, http, sqlite) dejan de
arrastrarlos. Reduccion de binarios: dag_engine 72->10MB, registry_api 70->8.7MB,
services_api 70->9MB, call_monitor 68->6.6MB, sqlite_api 70->8.9MB.
Los IDs del registry se mantienen estables (domain: infra en frontmatter). Se
preservan los build tags goolm/libolm de matrix_crypto_init.
Tambien corrige TestSSEHandler: el test leia el body con un unico Read() que con
HTTP chunked solo capturaba el primer evento; ahora usa io.ReadAll hasta EOF.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
//go:build !noclickhouse
|
||||
|
||||
package infra
|
||||
package clickhouse
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
@@ -29,7 +29,7 @@ output: "conexion sql.DB abierta a ClickHouse con ping verificado"
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "functions/infra/clickhouse_open.go"
|
||||
file_path: "functions/infra/clickhouse/clickhouse_open.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
@@ -1,6 +1,4 @@
|
||||
//go:build !noduckdb
|
||||
|
||||
package infra
|
||||
package duckdb
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
@@ -21,7 +21,7 @@ output: "conexion sql.DB abierta a DuckDB"
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "functions/infra/duckdb_open.go"
|
||||
file_path: "functions/infra/duckdb/duckdb_open.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package keyring
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+2
-2
@@ -54,8 +54,8 @@ tests:
|
||||
- "Save then Delete then Load returns ErrNotFound"
|
||||
- "Delete nonexistent is idempotent"
|
||||
- "Save twice overwrites with second token"
|
||||
test_file_path: "functions/infra/keyring_token_store_test.go"
|
||||
file_path: "functions/infra/keyring_token_store.go"
|
||||
test_file_path: "functions/infra/keyring/keyring_token_store_test.go"
|
||||
file_path: "functions/infra/keyring/keyring_token_store.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package keyring
|
||||
|
||||
import (
|
||||
"errors"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
+2
-2
@@ -38,8 +38,8 @@ tests:
|
||||
- "Whoami 401 token invalido"
|
||||
- "EnableCrypto true devuelve error not implemented"
|
||||
- "StoreDir se crea con permisos 0700"
|
||||
test_file_path: "functions/infra/matrix_client_init_test.go"
|
||||
file_path: "functions/infra/matrix_client_init.go"
|
||||
test_file_path: "functions/infra/matrix/matrix_client_init_test.go"
|
||||
file_path: "functions/infra/matrix/matrix_client_init.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//go:build goolm || libolm
|
||||
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
+2
-2
@@ -38,8 +38,8 @@ tests:
|
||||
- "directorio del store se crea con permisos 0700"
|
||||
- "input valido Init exito helper no nil"
|
||||
- "Synapse 401 en keys upload devuelve error"
|
||||
test_file_path: "functions/infra/matrix_crypto_init_test.go"
|
||||
file_path: "functions/infra/matrix_crypto_init.go"
|
||||
test_file_path: "functions/infra/matrix/matrix_crypto_init_test.go"
|
||||
file_path: "functions/infra/matrix/matrix_crypto_init.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//go:build goolm || libolm
|
||||
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
+2
-2
@@ -53,8 +53,8 @@ tests:
|
||||
- "SendReply client nil devuelve error"
|
||||
- "EditMessage client nil devuelve error"
|
||||
- "SendReaction client nil devuelve error"
|
||||
test_file_path: "functions/infra/matrix_message_send_test.go"
|
||||
file_path: "functions/infra/matrix_message_send.go"
|
||||
test_file_path: "functions/infra/matrix/matrix_message_send_test.go"
|
||||
file_path: "functions/infra/matrix/matrix_message_send.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -30,8 +30,8 @@ tests:
|
||||
- "IsDirect set correctamente segun m.direct"
|
||||
- "IsEncrypted set segun presencia de m.room.encryption"
|
||||
- "client nil devuelve error"
|
||||
test_file_path: "functions/infra/matrix_room_list_test.go"
|
||||
file_path: "functions/infra/matrix_room_list.go"
|
||||
test_file_path: "functions/infra/matrix/matrix_room_list_test.go"
|
||||
file_path: "functions/infra/matrix/matrix_room_list.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
+2
-2
@@ -36,8 +36,8 @@ tests:
|
||||
- "Error401NoExit"
|
||||
- "StopIdempotente"
|
||||
- "CtxCancelCierraChannels"
|
||||
test_file_path: "functions/infra/matrix_sync_service_test.go"
|
||||
file_path: "functions/infra/matrix_sync_service.go"
|
||||
test_file_path: "functions/infra/matrix/matrix_sync_service_test.go"
|
||||
file_path: "functions/infra/matrix/matrix_sync_service.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//go:build goolm
|
||||
|
||||
package infra
|
||||
package matrix
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package infra
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
@@ -31,7 +31,7 @@ output: "conexion sql.DB abierta a PostgreSQL"
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "functions/infra/postgres_open.go"
|
||||
file_path: "functions/infra/postgres/postgres_open.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
@@ -2,6 +2,7 @@ package infra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
@@ -210,9 +211,16 @@ func TestSSEHandler(t *testing.T) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
buf := make([]byte, 4096)
|
||||
n, _ := resp.Body.Read(buf)
|
||||
body := string(buf[:n])
|
||||
// Leer el body completo hasta EOF. El canal se cierra antes de la
|
||||
// peticion, asi que el handler envia ambos eventos y termina, cerrando
|
||||
// el stream. Un unico Read podria devolver solo el primer chunk
|
||||
// (event: first), porque io.Reader.Read no garantiza llenar el buffer;
|
||||
// io.ReadAll consume todos los chunks emitidos por el handler.
|
||||
raw, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("read body failed: %v", err)
|
||||
}
|
||||
body := string(raw)
|
||||
|
||||
for _, want := range []string{"event: first", "event: second", "data: 1", "data: 2"} {
|
||||
if !strings.Contains(body, want) {
|
||||
|
||||
Reference in New Issue
Block a user