Events Providers 概要
Events Providers を使うと、digital worker は messaging 以外の external trigger にも応答できるようになります。扱えるものは次のとおりです。
- external service からの webhook
- scheduled task(timer/cron)
- email notification
- SMS notification
利用可能な provider
Section titled “利用可能な provider” Webhook external service から HTTP webhook を受け取る
Timer cron expression で task をスケジュールする
Email (SendGrid) SendGrid 経由で transactional email を送信する
SMS (Twilio) Twilio 経由で SMS message を送信する
アーキテクチャ
Section titled “アーキテクチャ”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) │└─────────────────────────────────────────┘Event の正規化
Section titled “Event の正規化”すべての event は共通フォーマットに正規化されます。
pub struct Event { pub id: String, pub event_type: String, pub source: String, pub timestamp: u64, pub payload: Value, pub metadata: Option<Value>,}bundle 内
Section titled “bundle 内”providers: events-webhook: pack: "providers/events/events-webhook.gtpack"
events-timer: pack: "providers/events/events-timer.gtpack"Event Flows
Section titled “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: processNATS Subject
Section titled “NATS Subject”event は NATS を通って流れます。
| Subject | Purpose |
|---|---|
greentic.events.{env}.{tenant}.{type} | event notification |
greentic.events.{env}.{tenant}.{type}.result | event processing result |
よくあるパターン
Section titled “よくあるパターン”Event-Driven Notification
Section titled “Event-Driven Notification”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_trackingScheduled Tasks
Section titled “Scheduled Tasks”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