Skip to content

API Events

Licensing không có bề mặt messaging bất đồng bộ. Application.configureComponents() chỉ đăng ký một Redis cache (useCacheRedis). Không có Kafka producer/consumer, không queue BullMQ, và không WebSocket emitter. Phụ thuộc @platformatic/kafkabullmq trong package.json không được dùng.

1. Inbound - Kafka

TopicProducerHandlerIdempotency KeyFailure Mode
Không----

2. Outbound - Kafka

TopicTriggerConsumersPayload Schema
Không---

3. Inbound - BullMQ

QueueJob TypeProducerHandlerConcurrency
Không----

4. Outbound - BullMQ

QueueJob TypeTriggerConsumer Service
Không---

5. WebSocket Emissions

TopicRoomTriggerAction Enum
Không---

6. Payload Schemas

Payload xuyên service duy nhất là chứng chỉ license ghi vào Redis. Nó không phải sự kiện message-bus - nó là một key mà consumer kéo theo nhu cầu qua LicenseMiddleware của @nx/core.

Kênh chứng chỉ Redis

Khía cạnhGiá trị
ProducerLicensingBaseService.publishCertificate() - redis.client.set(key, cert, 'EX', certTtl)
Consumer@nx/core LicenseProvider (tức LicenseMiddleware) - redis.client.get(key)
Keylic:certs:<entityType>:<entityId> (vd lic:certs:Merchant:123)
ValueEnvelope chuỗi Base64 (payload AES-256-GCM + chữ ký Ed25519)
TTLAPP_ENV_LICENSING_CERT_TTL_SECONDS (mặc định 86400)
ts
// Payload chứng chỉ đã giải mã - ILicenseCertificatePayload (@nx/core)
export interface ILicenseCertificatePayload<FeaturesType = Record<string, unknown>> {
  license: { id: string; key: string };
  entity: { type: string; id: string };
  status: string;             // LicenseStatuses
  tier: string;               // policy.type (PolicyTypes)
  features: FeaturesType;      // map PolicyFeature đã giải (đã merge override)
  activation: { limit: number } | null;
  expiresAt: string | null;
  issuedAt: string;
  certExpiresAt: string;       // độc lập với license.expiresAt - điều khiển Redis EX
}
ts
// Envelope trên đường truyền - ICertificateEnvelope (@nx/core)
export interface ICertificateEnvelope {
  enc: string;  // ciphertext AES-256-GCM của JSON payload
  sig: string;  // chữ ký Ed25519 (base64url) trên "MESSAGE_PREFIX:enc"
  alg: string;  // "aes-256-gcm+ed25519"
}

7. Idempotency & Thứ tự

Bề mặtDeliveryThứ tựPhục hồi
Chứng chỉ Redislast-write-wins (một key mỗi entity)n/a (chỉ trạng thái mới nhất)Re-publish mỗi mutation vòng đời; hết hạn sau TTL → consumer thấy null (fail-open) cho tới khi re-issue

Khi cert thiếu hoặc xác minh thất bại, LicenseMiddlewarefail-open: nó đặt license context thành null (coi là "unknown", không phải "unlicensed").

8. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.