Files
motia/bitbylaw/steps/advoware_cal_sync/calendar_sync_all_step.md
2026-02-07 09:23:49 +00:00

2.4 KiB

type, category, name, version, status, tags, dependencies, emits, subscribes
type category name version status tags dependencies emits subscribes
step event Calendar Sync All 1.0.0 active
calendar
sync
event
cascade
services/advoware.py
redis
calendar_sync_employee
calendar_sync_all

Calendar Sync All Step

Zweck

Fetcht alle Mitarbeiter von Advoware und emittiert calendar_sync_employee Event pro Mitarbeiter. Ermöglicht parallele Verarbeitung.

Config

{
    'type': 'event',
    'name': 'Calendar Sync All',
    'subscribes': ['calendar_sync_all'],
    'emits': ['calendar_sync_employee'],
    'flows': ['advoware_cal_sync']
}

Input Event

{
  "topic": "calendar_sync_all",
  "data": {}
}

Verhalten

  1. Fetch Employees von Advoware API:

    employees = await advoware.api_call('/employees')
    
  2. Filter Debug-Liste (wenn konfiguriert):

    if Config.CALENDAR_SYNC_DEBUG_KUERZEL:
        employees = [e for e in employees if e['kuerzel'] in debug_list]
    
  3. Set Lock pro Employee:

    lock_key = f'calendar_sync:lock:{kuerzel}'
    redis.set(lock_key, '1', nx=True, ex=300)
    
  4. Emit Event pro Employee:

    await context.emit({
        'topic': 'calendar_sync_employee',
        'data': {
            'kuerzel': kuerzel,
            'full_content': True
        }
    })
    

Debug-Modus

# Only sync specific employees
export CALENDAR_SYNC_DEBUG_KUERZEL=SB,AI,RO

# Sync all (production)
export CALENDAR_SYNC_DEBUG_KUERZEL=

Error Handling

  • Advoware API Fehler: Loggen, aber nicht crashen
  • Lock-Fehler: Employee skippen (bereits in Sync)
  • Event Emission Fehler: Loggen und fortfahren

Output Events

Multiple calendar_sync_employee events, z.B.:

[
  {"topic": "calendar_sync_employee", "data": {"kuerzel": "SB", "full_content": true}},
  {"topic": "calendar_sync_employee", "data": {"kuerzel": "AI", "full_content": true}},
  ...
]

Performance

  • ~10 employees: <1s für Fetch + Event Emission
  • Lock-Setting: <10ms pro Employee
  • Keine Blockierung (async events)

Monitoring

[INFO] Fetching employees from Advoware
[INFO] Found 10 employees
[INFO] Emitting calendar_sync_employee for SB
[INFO] Emitting calendar_sync_employee for AI
...