Skip to content

feat: add AllocationCreated and AllocationCompleted events#14

Merged
diptanu merged 1 commit intomainfrom
feat/allocation-events-pr-2042
Jan 16, 2026
Merged

feat: add AllocationCreated and AllocationCompleted events#14
diptanu merged 1 commit intomainfrom
feat/allocation-events-pr-2042

Conversation

@diptanu
Copy link
Contributor

@diptanu diptanu commented Jan 16, 2026

Summary

This PR refactors request state change events to clearly separate two distinct lifecycles, aligning with tensorlakeai/indexify PR #2042:

  1. Function Run lifecycle - the logical unit of work (may have multiple execution attempts)
  2. Allocation lifecycle - a single physical execution attempt on an executor

Changes

New Event Types

  • AllocationCreated - Event emitted when an allocation (execution attempt) is created and assigned to an executor
  • AllocationCompleted - Event emitted when an allocation (execution attempt) completes with an outcome

Modified Event Type

  • FunctionRunCompleted - Now represents when a function run reaches its final outcome (after all retries exhausted or success). No longer contains allocation_id since it represents the logical function run, not a specific execution attempt.

Backward Compatibility

  • FunctionRunAssigned kept as a type alias to AllocationCreated
  • Legacy FunctionRunAssigned variant in the enum deserializes to AllocationCreated

Example Event Flow

With retry after executor removal:

RequestStarted(req-123)
├─ FunctionRunCreated(run-1, fn_a)
│  ├─ AllocationCreated(alloc-1, run-1, executor-A)
│  ├─ AllocationCompleted(alloc-1, failure/ExecutorRemoved)
│  ├─ AllocationCreated(alloc-2, run-1, executor-B)  ← retry
│  ├─ AllocationCompleted(alloc-2, success)
│  └─ FunctionRunCompleted(run-1, success)  ← final outcome
└─ RequestFinished(success)

Testing

  • All existing tests pass
  • cargo check passes

@diptanu diptanu force-pushed the feat/allocation-events-pr-2042 branch from cea6107 to dc0f9e0 Compare January 16, 2026 21:54
Refactors request state change events to clearly separate two distinct lifecycles:
- Function Run lifecycle: the logical unit of work (may have multiple execution attempts)
- Allocation lifecycle: a single physical execution attempt on an executor

Changes:
- Add AllocationCreated event (renamed from FunctionRunAssigned)
- Add AllocationCompleted event for when an execution attempt finishes
- Update FunctionRunCompleted to represent final function run outcome
- Keep allocation_id as optional in FunctionRunCompleted for backward compatibility
- Maintain backward compatibility with FunctionRunAssigned type alias
- Update RequestStateChangeEvent enum and all helper methods
- Add comprehensive backward compatibility tests

Backward compatibility:
- Old servers sending FunctionRunAssigned → deserializes correctly
- Old servers sending FunctionRunCompleted (with allocation_id) → deserializes correctly
- New servers sending AllocationCreated/AllocationCompleted → works as expected

This aligns with tensorlakeai/indexify PR #2042.
@diptanu diptanu force-pushed the feat/allocation-events-pr-2042 branch from dc0f9e0 to b4f6122 Compare January 16, 2026 21:58
@diptanu diptanu merged commit 722f796 into main Jan 16, 2026
2 checks passed
@diptanu diptanu deleted the feat/allocation-events-pr-2042 branch January 16, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants