Resumen de Providers de Eventos
Introducción
Sección titulada «Introducción»Los Providers de Eventos permiten que tu trabajador digital responda a triggers externos más allá de la mensajería. Se encargan de:
- Webhooks de servicios externos
- Tareas programadas (timers/cron)
- Notificaciones por correo electrónico
- Notificaciones por SMS
Providers disponibles
Sección titulada «Providers disponibles» Webhook Recibir webhooks HTTP de servicios externos
Timer Programar tareas con expresiones cron
Correo electrónico (SendGrid) Enviar correos electrónicos transaccionales mediante SendGrid
SMS (Twilio) Enviar mensajes SMS mediante Twilio
Arquitectura
Sección titulada «Arquitectura»External Service / Timer │ ▼ HTTP / Schedule┌─────────────────────────────────────────┐│ Events Ingress ││ (Process incoming event) │└─────────────────────────────────────────┘ │ ▼ Normalized Event┌─────────────────────────────────────────┐│ NATS Bus ││ greentic.events.{env}.{tenant}.{type}│└─────────────────────────────────────────┘ │ ▼┌─────────────────────────────────────────┐│ Flow Executor ││ (Process with event flows) │└─────────────────────────────────────────┘Normalización de eventos
Sección titulada «Normalización de eventos»Todos los eventos se normalizan a un formato común:
pub struct Event { pub id: String, pub event_type: String, pub source: String, pub timestamp: u64, pub payload: Value, pub metadata: Option<Value>,}Configuración
Sección titulada «Configuración»En el bundle
Sección titulada «En el bundle»providers: events-webhook: pack: "providers/events/events-webhook.gtpack"
events-timer: pack: "providers/events/events-timer.gtpack"Event flows
Sección titulada «Event flows»name: handle_eventversion: "1.0"
nodes: - id: process type: script config: script: | // Process the event let payload = event.payload; process_payload(payload) next: respond
triggers: - type: event event_type: "order.created" target: processSubjects de NATS
Sección titulada «Subjects de NATS»Los eventos fluyen a través de NATS:
| Subject | Propósito |
|---|---|
greentic.events.{env}.{tenant}.{type} | Notificaciones de eventos |
greentic.events.{env}.{tenant}.{type}.result | Resultados del procesamiento de eventos |
Patrones comunes
Sección titulada «Patrones comunes»Notificaciones impulsadas por eventos
Sección titulada «Notificaciones impulsadas por eventos»nodes: - id: on_order type: branch config: conditions: - expression: "event.event_type == 'order.created'" next: send_confirmation - expression: "event.event_type == 'order.shipped'" next: send_trackingTareas programadas
Sección titulada «Tareas programadas»nodes: - id: daily_report type: http config: method: GET url: "https://api.example.com/reports/daily" next: send_email
triggers: - type: timer cron: "0 9 * * *" # 9 AM daily target: daily_report