architect/_archive/2025-11-13-before-restructure/platform-projects/projects/cifra/10_WORKFLOWS_AND_AUTOMATION.md

CIFRA — Workflows и автоматизация

Версия: 2.0.0
Дата: 2025-11-10


Workflow Builder

workflows:
  deal_pipeline:
    trigger: entity.Deal.stage_changed

    steps:
      - name: Send notification
        when: stage == 'won'
        action: send_notification
        params:
          template: deal_won

      - name: Create invoice
        when: stage == 'won'
        action: create_entity
        params:
          entity: Invoice

Process Engine (BPMN)

processes:
  order_fulfillment:
    start: order_created

    tasks:
      - id: validate_payment
        type: service

      - id: reserve_inventory
        type: service

      - id: ship_order
        type: service

    end: order_shipped

Background Jobs

from cifra.tasks import task

@task
async def send_email(to: str, subject: str, body: str):
    await email_service.send(to, subject, body)

# Enqueue
await send_email.delay(
    to='user@example.com',
    subject='Welcome',
    body='Hello!'
)

Scheduled tasks (Cron)

from cifra.tasks import scheduled_task

@scheduled_task(cron='0 2 * * *')  # 2 AM daily
async def daily_backup():
    await backup_service.backup_database()

Retry policies

@task(retry=3, retry_delay=60)
async def api_call_with_retry(url: str):
    try:
        response = await http_client.get(url)
        return response.json()
    except HTTPError:
        raise TaskRetry()

Следующий документ: DATA_MANAGEMENT.md →