Skip to content

Commit 8636898

Browse files
author
npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta
committed
Wire Postgres search backend through chart
Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co>
1 parent 9181b88 commit 8636898

23 files changed

Lines changed: 232 additions & 116 deletions

‎crates/buzz-relay/src/config.rs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl Config {
159159
"BUZZ_SEARCH_BACKEND={bad:?} (expected `typesense`, `postgres`, or `disabled`)"
160160
))
161161
})?,
162-
Err(_) => buzz_search::SearchBackend::Typesense,
162+
Err(_) => buzz_search::SearchBackend::Postgres,
163163
};
164164

165165
let relay_url =
@@ -562,17 +562,21 @@ mod tests {
562562
}
563563

564564
#[test]
565-
fn search_backend_defaults_to_typesense() {
565+
fn search_backend_defaults_to_postgres() {
566566
let _guard = ENV_MUTEX.lock().unwrap();
567567
std::env::remove_var("BUZZ_SEARCH_BACKEND");
568568
let config = Config::from_env().expect("default config");
569-
assert_eq!(config.search_backend, buzz_search::SearchBackend::Typesense);
569+
assert_eq!(config.search_backend, buzz_search::SearchBackend::Postgres);
570570
}
571571

572572
#[test]
573-
fn search_backend_parses_postgres_and_disabled() {
573+
fn search_backend_parses_typesense_postgres_and_disabled() {
574574
let _guard = ENV_MUTEX.lock().unwrap();
575575

576+
std::env::set_var("BUZZ_SEARCH_BACKEND", "typesense");
577+
let config = Config::from_env().expect("config");
578+
assert_eq!(config.search_backend, buzz_search::SearchBackend::Typesense);
579+
576580
std::env::set_var("BUZZ_SEARCH_BACKEND", "postgres");
577581
let config = Config::from_env().expect("config");
578582
assert_eq!(config.search_backend, buzz_search::SearchBackend::Postgres);

‎crates/buzz-relay/src/handlers/event.rs‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,13 +1250,21 @@ mod tests {
12501250
.await
12511251
.expect("pubsub manager"),
12521252
);
1253-
let audit = buzz_audit::AuditService::new(pool);
1253+
let audit = buzz_audit::AuditService::new(pool.clone());
12541254
let auth = buzz_auth::AuthService::new(config.auth.clone());
1255-
let search = buzz_search::SearchService::new(buzz_search::SearchConfig {
1256-
url: config.typesense_url.clone(),
1257-
api_key: config.typesense_key.clone(),
1258-
collection: "events".to_string(),
1259-
});
1255+
let search = match config.search_backend {
1256+
buzz_search::SearchBackend::Typesense => {
1257+
buzz_search::SearchService::new(buzz_search::SearchConfig {
1258+
url: config.typesense_url.clone(),
1259+
api_key: config.typesense_key.clone(),
1260+
collection: "events".to_string(),
1261+
})
1262+
}
1263+
buzz_search::SearchBackend::Postgres => {
1264+
buzz_search::SearchService::with_postgres(pool.clone())
1265+
}
1266+
buzz_search::SearchBackend::Disabled => buzz_search::SearchService::disabled(),
1267+
};
12601268
let workflow_engine = Arc::new(buzz_workflow::WorkflowEngine::new(
12611269
db.clone(),
12621270
buzz_workflow::WorkflowConfig::default(),

‎crates/buzz-relay/src/handlers/identity_archive.rs‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,21 @@ mod tests {
443443
.await
444444
.ok()?,
445445
);
446-
let audit = buzz_audit::AuditService::new(pool);
446+
let audit = buzz_audit::AuditService::new(pool.clone());
447447
let auth = buzz_auth::AuthService::new(config.auth.clone());
448-
let search = buzz_search::SearchService::new(buzz_search::SearchConfig {
449-
url: config.typesense_url.clone(),
450-
api_key: config.typesense_key.clone(),
451-
collection: "events".to_string(),
452-
});
448+
let search = match config.search_backend {
449+
buzz_search::SearchBackend::Typesense => {
450+
buzz_search::SearchService::new(buzz_search::SearchConfig {
451+
url: config.typesense_url.clone(),
452+
api_key: config.typesense_key.clone(),
453+
collection: "events".to_string(),
454+
})
455+
}
456+
buzz_search::SearchBackend::Postgres => {
457+
buzz_search::SearchService::with_postgres(pool.clone())
458+
}
459+
buzz_search::SearchBackend::Disabled => buzz_search::SearchService::disabled(),
460+
};
453461
let workflow_engine = Arc::new(buzz_workflow::WorkflowEngine::new(
454462
db.clone(),
455463
buzz_workflow::WorkflowConfig::default(),

‎crates/buzz-relay/src/handlers/mesh_signaling.rs‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,21 @@ mod tests {
507507
.await
508508
.expect("pubsub manager"),
509509
);
510-
let audit = buzz_audit::AuditService::new(pool);
510+
let audit = buzz_audit::AuditService::new(pool.clone());
511511
let auth = buzz_auth::AuthService::new(config.auth.clone());
512-
let search = buzz_search::SearchService::new(buzz_search::SearchConfig {
513-
url: config.typesense_url.clone(),
514-
api_key: config.typesense_key.clone(),
515-
collection: "events".to_string(),
516-
});
512+
let search = match config.search_backend {
513+
buzz_search::SearchBackend::Typesense => {
514+
buzz_search::SearchService::new(buzz_search::SearchConfig {
515+
url: config.typesense_url.clone(),
516+
api_key: config.typesense_key.clone(),
517+
collection: "events".to_string(),
518+
})
519+
}
520+
buzz_search::SearchBackend::Postgres => {
521+
buzz_search::SearchService::with_postgres(pool.clone())
522+
}
523+
buzz_search::SearchBackend::Disabled => buzz_search::SearchService::disabled(),
524+
};
517525
let workflow_engine = std::sync::Arc::new(buzz_workflow::WorkflowEngine::new(
518526
db.clone(),
519527
buzz_workflow::WorkflowConfig::default(),

‎deploy/charts/buzz/README.md‎

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Buzz Helm Chart
22

3-
[Buzz](https://github.com/block/buzz) is a Nostr-based messaging platform for human–agent collaboration: a single relay binary serving WebSocket + REST + web UI, backed by PostgreSQL, Redis, Typesense, and S3-compatible object storage.
3+
[Buzz](https://github.com/block/buzz) is a Nostr-based messaging platform for human–agent collaboration: a single relay binary serving WebSocket + REST + web UI, backed by PostgreSQL, Redis, and S3-compatible object storage. NIP-50 search defaults to Postgres full-text search, with Typesense available as a fallback backend.
44

55
This chart has two operating profiles selected by values:
66

77
| Profile | When | What you get |
88
|---|---|---|
9-
| **Production** (default) | Self-hosted multi-tenant, regulated, or GitOps-managed | External managed Postgres/Redis/Typesense/S3, `secrets.existingSecret:`, no chart-side autogen, HA-capable (`replicaCount ≥ 2`) |
10-
| **Quickstart** (eval) | Eval, single-node, one-off demo | In-cluster Postgres + Redis + MinIO + Typesense subcharts/Deployments, chart auto-generates relay + service secrets, single replica |
9+
| **Production** (default) | Self-hosted multi-tenant, regulated, or GitOps-managed | External managed Postgres/Redis/S3, Postgres FTS search by default, `secrets.existingSecret:`, no chart-side autogen, HA-capable (`replicaCount ≥ 2`) |
10+
| **Quickstart** (eval) | Eval, single-node, one-off demo | In-cluster Postgres + Redis + MinIO, chart auto-generates relay + service secrets, single replica |
1111

1212
## Quickstart (eval only)
1313

@@ -18,18 +18,18 @@ helm install buzz oci://ghcr.io/block/buzz/charts/buzz --version 0.1.0 \
1818
--set postgresql.enabled=true \
1919
--set redis.enabled=true \
2020
--set minio.enabled=true \
21-
--set typesense.enabled=true \
2221
--set relayUrl=wss://buzz.example.com \
2322
--set ownerPubkey=<64-char-hex-pubkey>
2423
```
2524

26-
This brings up **everything in-cluster** — Postgres, Redis, MinIO (with its
27-
bucket created by a post-install Job), and Typesense — and composes the relay's
28-
`BUZZ_S3_ENDPOINT` / `TYPESENSE_URL` plus autogenerated credentials
29-
automatically. No external services required. The `quickstart=true` flag is an
30-
intent marker surfaced in NOTES.txt; the bundled services are opted in via the
31-
four `*.enabled` flags above (see `ci/quickstart-values.yaml` for the exact set
32-
CI installs). Eval-only: every bundled service is a single replica with no HA.
25+
This brings up the required quickstart dependencies in-cluster — Postgres,
26+
Redis, and MinIO (with its bucket created by a post-install Job) — and composes
27+
the relay's `BUZZ_S3_ENDPOINT` plus autogenerated credentials automatically.
28+
Search defaults to Postgres FTS (`search.backend=postgres`), so no Typesense
29+
service is required. The `quickstart=true` flag is an intent marker surfaced in
30+
NOTES.txt; the bundled services are opted in via the per-service `*.enabled`
31+
flags (see `ci/quickstart-values.yaml` for the exact set CI installs).
32+
Eval-only: every bundled service is a single replica with no HA.
3333

3434
## Production (GitOps)
3535

@@ -50,7 +50,7 @@ See:
5050
| `relayUrl` | Public `wss://` URL clients connect to | Always |
5151
| `ownerPubkey` | 64-char lowercase hex Nostr pubkey of the relay operator | When `relay.requireRelayMembership=true` (default) |
5252
| `secrets.existingSecret` | Name of pre-created Secret | Production / GitOps |
53-
| `externalPostgresql.url` / `externalRedis.url` / `typesense.url` / `s3.endpoint` | External service URLs | Production — when the matching bundled service is disabled (the default) |
53+
| `externalPostgresql.url` / `externalRedis.url` / `s3.endpoint` | External service URLs | Production — when the matching bundled service is disabled (the default) |
5454

5555
The chart fails at `helm install` / `helm template` time with a clear message if any of these are missing or malformed (see `templates/_validate.tpl`).
5656

@@ -81,17 +81,21 @@ Save these. Losing any of them is data loss. See NOTES.txt printed by `helm inst
8181

8282
## Honest limitations (v1)
8383

84-
- **Bundled MinIO + Typesense are eval-only.** The quickstart profile runs an
85-
in-cluster MinIO and Typesense (single replica, no HA, `lookup`-autogenerated
86-
credentials) so the relay starts with zero external services. Production
87-
leaves `minio.enabled` / `typesense.enabled` off and points `s3.endpoint` +
88-
`typesense.url` (or `BUZZ_S3_*` / `TYPESENSE_URL` in `existingSecret`) at
89-
managed S3-compatible storage and Typesense. The bundled Deployments are not
90-
GitOps-safe and are not intended for production traffic.
84+
- **Bundled MinIO is eval-only.** The quickstart profile runs an in-cluster MinIO
85+
(single replica, no HA, `lookup`-autogenerated credentials) so the relay starts
86+
with zero external object-storage dependencies. Production leaves
87+
`minio.enabled` off and points `s3.endpoint` (or `BUZZ_S3_*` in
88+
`existingSecret`) at managed S3-compatible storage. The bundled Deployment is
89+
not GitOps-safe and is not intended for production traffic.
90+
- **Typesense is a fallback search backend.** Default search is Postgres FTS
91+
(`search.backend=postgres`). To use Typesense instead, set
92+
`search.backend=typesense` and provide either `typesense.url`/`apiKey`,
93+
`TYPESENSE_URL`/`TYPESENSE_API_KEY` in `secrets.existingSecret`, or
94+
`typesense.enabled=true` for eval-only in-cluster Typesense.
9195
- **Minimal-mode is not yet supported.** The relay's `BUZZ_PUBSUB=local` /
92-
`BUZZ_SEARCH=pg` / filesystem media paths are upstream work in progress —
93-
even quickstart currently stands up real Redis, Typesense, and S3 rather than
94-
the relay's single-node fallbacks.
96+
filesystem media paths are upstream work in progress — even quickstart
97+
currently stands up real Redis and S3 rather than the relay's single-node
98+
fallbacks.
9599
- **OCI publish to GHCR + cosign signing** is a follow-up PR. For now, install the chart from source: `helm install buzz ./deploy/charts/buzz` after cloning the repo.
96100

97101
## Development

‎deploy/charts/buzz/ci/quickstart-values.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Quickstart / eval: subcharts on, autogen secrets, single replica.
22
# This is the scenario `ct install` exercises against a kind cluster — it
3-
# spins up postgres + redis + minio + typesense in-cluster so the relay can
4-
# actually start and pass its S3 conformance probe.
3+
# spins up postgres + redis + minio in-cluster so the relay can actually
4+
# start and pass its S3 conformance probe. Search defaults to Postgres FTS, so
5+
# the quickstart no longer needs in-cluster Typesense unless explicitly testing
6+
# search.backend=typesense.
57
quickstart: true
68
postgresql:
79
enabled: true
810
redis:
911
enabled: true
1012
minio:
1113
enabled: true
12-
typesense:
13-
enabled: true
1414
relayUrl: wss://buzz.test.local
1515
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000001"
1616
relay:

‎deploy/charts/buzz/examples/argocd-app.yaml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ spec:
3737
externalRedis:
3838
url: ""
3939
40-
typesense:
41-
url: "http://typesense.buzz.svc.cluster.local:8108"
42-
# apiKey lives in buzz-secrets
40+
search:
41+
backend: postgres
4342
4443
s3:
4544
endpoint: "https://s3.us-east-1.amazonaws.com"

‎deploy/charts/buzz/examples/flux-helmrelease.yaml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ spec:
3737
secrets:
3838
existingSecret: buzz-secrets
3939

40-
typesense:
41-
url: "http://typesense.buzz.svc.cluster.local:8108"
42-
# apiKey lives in buzz-secrets
40+
search:
41+
backend: postgres
4342

4443
s3:
4544
endpoint: "https://s3.us-east-1.amazonaws.com"

‎deploy/charts/buzz/examples/secret-sample.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# REDIS_URL — redis://... (required when replicaCount > 1)
1212
# TYPESENSE_URL
1313
# TYPESENSE_API_KEY
14+
# Only required when Helm value search.backend=typesense.
1415
# BUZZ_S3_ACCESS_KEY
1516
# BUZZ_S3_SECRET_KEY
1617
apiVersion: v1

‎deploy/charts/buzz/templates/NOTES.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@
2626
──────────────────────────────────────────────────────────────────────────────
2727
Profile
2828
──────────────────────────────────────────────────────────────────────────────
29-
{{ if or .Values.postgresql.enabled .Values.redis.enabled .Values.minio.enabled .Values.typesense.enabled }}
29+
{{ if or .Values.postgresql.enabled .Values.redis.enabled .Values.minio.enabled (and .Values.typesense.enabled (eq (include "buzz.searchBackend" .) "typesense")) }}
3030
⚠ QUICKSTART / EVALUATION PROFILE
3131
{{ if .Values.postgresql.enabled }}- In-cluster Postgres subchart (CloudPirates){{ end }}
3232
{{ if .Values.redis.enabled }}- In-cluster Redis subchart (CloudPirates){{ end }}
3333
{{ if .Values.minio.enabled }}- In-cluster MinIO (eval-only, single replica; bucket "{{ .Values.s3.bucket }}" created by post-install Job){{ end }}
34-
{{ if .Values.typesense.enabled }}- In-cluster Typesense (eval-only, single replica){{ end }}
34+
{{ if and .Values.typesense.enabled (eq (include "buzz.searchBackend" .) "typesense") }}- In-cluster Typesense (eval-only, single replica){{ end }}
3535
- Chart auto-generates secrets via the `lookup` pattern. This is NOT
3636
GitOps-safe — secrets will silently rotate under ArgoCD/Flux. For
3737
production, see examples/argocd-app.yaml or examples/flux-helmrelease.yaml.
3838

3939
{{ else }}
4040
✓ PRODUCTION PROFILE
41-
External Postgres, Redis (if enabled), Typesense, S3.
41+
External Postgres, Redis (if enabled), S3; search backend: {{ include "buzz.searchBackend" . }}.
4242
{{ if .Values.secrets.existingSecret }}- Secrets sourced from: {{ .Values.secrets.existingSecret }}{{ end }}
4343
{{ end }}
4444

0 commit comments

Comments
 (0)