feat(render+identity): daily render-limit — consume on submit, refund on admin-stop
Build backend images / build content-svc (push) Failing after 51s
Build backend images / build file-svc (push) Failing after 53s
Build backend images / build gateway (push) Failing after 1m1s
Build backend images / build identity-svc (push) Failing after 48s
Build backend images / build notification-svc (push) Failing after 42s
Build backend images / build render-svc (push) Failing after 47s
Build backend images / build studio-svc (push) Failing after 1m13s
Build backend images / build content-svc (push) Failing after 51s
Build backend images / build file-svc (push) Failing after 53s
Build backend images / build gateway (push) Failing after 1m1s
Build backend images / build identity-svc (push) Failing after 48s
Build backend images / build notification-svc (push) Failing after 42s
Build backend images / build render-svc (push) Failing after 47s
Build backend images / build studio-svc (push) Failing after 1m13s
Business rule: each user has a daily render limit. Admin-stop refunds the used
charge (not the user's fault); a user's own cancel does not.
- identity: ConsumeRenderChargeAsync / RefundRenderChargeAsync on DailyRemainRenderCount
with lazy daily reset (mig 24: daily_renders_reset_at). Convention: max=0 ⇒ UNLIMITED,
so existing 0/0 users keep rendering until an admin sets a real limit.
- identity InternalController (service-token): POST /v1/internal/render-charge/{consume,refund}
- render-svc: identityclient + on Create consume (block 429 when limit reached, fail-open
on identity outage); on admin Stop refund the job owner; user /cancel unchanged
- compose: IDENTITY_URL for render-svc, ServiceToken for identity-svc
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/flatrender/render-svc/internal/db"
|
||||
"github.com/flatrender/render-svc/internal/handlers"
|
||||
"github.com/flatrender/render-svc/internal/identityclient"
|
||||
"github.com/flatrender/render-svc/internal/middleware"
|
||||
"github.com/flatrender/render-svc/internal/notifier"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -35,6 +36,7 @@ func main() {
|
||||
minioBucket := getEnv("MINIO_BUCKET", "flatrender-exports")
|
||||
minioTemplatesBucket := getEnv("MINIO_TEMPLATES_BUCKET", "flatrender-templates")
|
||||
notificationURL := getEnv("NOTIFICATION_URL", "http://localhost:8080")
|
||||
identityURL := getEnv("IDENTITY_URL", "")
|
||||
serviceToken := getEnv("SERVICE_TOKEN", "internal-service-secret")
|
||||
port := getEnv("PORT", "8080")
|
||||
|
||||
@@ -60,7 +62,8 @@ func main() {
|
||||
// ── Store + handlers ──────────────────────────────────────────────────────
|
||||
store := db.NewStore(pool)
|
||||
notifyClient := notifier.New(notificationURL, serviceToken)
|
||||
renderH := handlers.NewRenderHandler(store)
|
||||
identityClient := identityclient.New(identityURL, serviceToken)
|
||||
renderH := handlers.NewRenderHandler(store, identityClient)
|
||||
snapH := handlers.NewSnapshotHandler(store)
|
||||
exportH := handlers.NewExportHandler(store, mc, minioBucket)
|
||||
nodeH := handlers.NewNodeHandler(store)
|
||||
|
||||
Reference in New Issue
Block a user