mirror of
https://github.com/hanzoai/notify.git
synced 2026-10-30 15:04:32 +00:00
Replaces the chi-based notifyd scaffold with the canonical
hanzoai/auto-style layout: hanzoai/base as the HTTP + SQLite + auth
substrate (via the platform plugin for IAM JWT validation and
X-Org-Id injection), hanzoai/tasks for durable async sends, and a
per-tenant Notifier resolver that pulls provider credentials from
KMS through platform.KMSClient.
Library at the module root stays untouched — all 33 provider impls
(plivo, twilio, ses, sendgrid, mail, whatsapp, discord, slack, …)
keep their existing public API. The service wraps them.
cmd/notifyd
- base.New + platform.MustRegister
- schema.MustRegister (6 collections: tenants, providers,
templates, events, messages, meter)
- tasks worker registered when TASKS_ADDR is set; sync path
runs the same Deliver activity directly when not
internal/
- boot/ thin platform.KMSClient wiring (env-driven)
- schema/ 6 base collections
- routes/ /v1/notify/{send,messages,providers,templates,events,metering,health}
+ convenience /send/{sms,email,voice,whatsapp}
- tenant/ KMS-backed resolver builds library Notifier per send
- template/ draft → pending → approved → published → archived
- event/ catalog routing (fills missing channel / template)
- metering/ per-send ledger writer + aggregate query
- tasks/ NotifySendWorkflow + Deliver activity (idempotent on
replay; reloads message row before resending)
- zaprpc/ procedure name constants (server impl follow-up)
pkg/
- client/ public HTTP SDK (Send / Message / Providers / Templates)
- types/ wire shapes shared by routes and client
cucloud: fmt.Errorf(msg) → errors.New(msg) for the go 1.26 vet pass
that landed with this dependency bump. Behaviour unchanged.
Boot smoke-tested locally:
- SQLite migrations apply cleanly
- /v1/notify/health returns {"service":"notify","status":"ok"}
- missing X-Org-Id returns 401 on every authenticated route
- send with stub tenant returns the expected base validation error
82 lines
2.2 KiB
YAML
82 lines
2.2 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: notifyd
|
|
labels:
|
|
app: notifyd
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app: notifyd
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxSurge: 1
|
|
maxUnavailable: 0
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: notifyd
|
|
spec:
|
|
containers:
|
|
- name: notifyd
|
|
image: notifyd
|
|
imagePullPolicy: IfNotPresent
|
|
args:
|
|
- serve
|
|
- --http
|
|
- 0.0.0.0:8090
|
|
- --dir
|
|
- /var/lib/notify
|
|
ports:
|
|
- name: http
|
|
containerPort: 8090
|
|
env:
|
|
- name: IAM_ENDPOINT
|
|
value: https://hanzo.id
|
|
- name: KMS_ENDPOINT
|
|
value: zap://kms.hanzo.svc.cluster.local:9999
|
|
- name: IAM_APP
|
|
value: hanzo-notify
|
|
- name: TASKS_ADDR
|
|
value: tasks.hanzo.svc.cluster.local:9999
|
|
- name: TASKS_NAMESPACE
|
|
value: notify
|
|
- name: TASKS_QUEUE
|
|
value: notify-send
|
|
envFrom:
|
|
# IAM_CLIENT_ID + IAM_CLIENT_SECRET come from a KMSSecret
|
|
# CR named notify-iam, populated by hanzoai/cloud's
|
|
# operator from KMS at boot.
|
|
- secretRef:
|
|
name: notify-iam
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /var/lib/notify
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /v1/notify/health
|
|
port: http
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 30
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /v1/notify/health
|
|
port: http
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 128Mi
|
|
limits:
|
|
cpu: 1000m
|
|
memory: 512Mi
|
|
volumes:
|
|
# The embedded SQLite lives in the pod's emptyDir for a
|
|
# baseline stateless rollout; switch to a PVC when retention
|
|
# of the meter ledger becomes a requirement.
|
|
- name: data
|
|
emptyDir: {}
|