Skip to content

Commit 1e12a40

Browse files
committed
some more cleanup
1 parent 40ec2d9 commit 1e12a40

9 files changed

Lines changed: 15 additions & 250 deletions

File tree

cmd/hatchet-migrate/migrate/migrations/20260531213452_batching_consolidated_v1_0_111.sql.sql renamed to cmd/hatchet-migrate/migrate/migrations/20260612000000_batching_consolidated_v1_0_118.sql.sql

File renamed without changes.

cmd/hatchet-migrate/migrate/migrations/20260608000000_v1_0_116_batch_broadcast_output.sql renamed to cmd/hatchet-migrate/migrate/migrations/20260612000000_v1_0_118_batch_broadcast_output.sql

File renamed without changes.

internal/services/dispatcher/dispatcher.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ func (d *DispatcherImpl) handleTaskBulkAssignedTask(ctx context.Context, msg *ms
509509
// load the step runs from the database
510510
taskIds := make([]int64, 0)
511511

512-
for _, ids := range innerMsg.WorkerIdToTaskIds {
513-
taskIds = append(taskIds, ids...)
512+
for _, tasks := range innerMsg.WorkerIdToTaskIds {
513+
taskIds = append(taskIds, tasks...)
514514
}
515515

516516
taskIdToData, err := d.populateTaskData(ctx, requeue, msg.TenantID, taskIds)
@@ -520,13 +520,11 @@ func (d *DispatcherImpl) handleTaskBulkAssignedTask(ctx context.Context, msg *ms
520520
continue
521521
}
522522

523-
for workerId, ids := range innerMsg.WorkerIdToTaskIds {
524-
if len(ids) == 0 {
525-
continue
526-
}
523+
for workerId, taskIds := range innerMsg.WorkerIdToTaskIds {
524+
workerId := workerId
527525

528526
outerEg.Go(func() error {
529-
return d.sendTasksToWorker(ctx, requeue, msg.TenantID, workerId, ids, taskIdToData)
527+
return d.sendTasksToWorker(ctx, requeue, msg.TenantID, workerId, taskIds, taskIdToData)
530528
})
531529
}
532530
}
@@ -680,12 +678,7 @@ func (d *DispatcherImpl) populateTaskData(
680678
}
681679
}
682680

683-
bulkV1Tasks := make([]*sqlcv1.V1Task, len(bulkDatas))
684-
for i, task := range bulkDatas {
685-
bulkV1Tasks[i] = task
686-
}
687-
688-
parentDataMap, err := d.repov1.Tasks().ListTaskParentOutputs(ctx, tenantId, bulkV1Tasks)
681+
parentDataMap, err := d.repov1.Tasks().ListTaskParentOutputs(ctx, tenantId, bulkDatas)
689682

690683
if err != nil {
691684
for _, task := range bulkDatas {
@@ -1144,10 +1137,7 @@ func (d *DispatcherImpl) handleTaskCancelled(ctx context.Context, msg *msgqueue.
11441137
task, ok := taskIdsToTasks[msg.TaskId]
11451138

11461139
if !ok {
1147-
d.l.Warn().Ctx(ctx).Msgf("task %d not found in retry counts", msg.TaskId)
1148-
continue
1149-
}
1150-
if task == nil {
1140+
d.l.Warn().Ctx(ctx).Msgf("task %d not found", msg.TaskId)
11511141
continue
11521142
}
11531143

pkg/repository/sqlcv1/tasks.sql

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,9 @@ SELECT
272272
t.concurrency_strategy_ids,
273273
t.concurrency_keys,
274274
t.retry_backoff_factor,
275-
t.retry_max_backoff,
276-
tr.batch_id AS runtime_batch_id,
277-
tr.batch_size AS runtime_batch_size,
278-
tr.batch_index AS runtime_batch_index,
279-
tr.worker_id AS runtime_worker_id,
280-
tr.timeout_at AS runtime_timeout_at
275+
t.retry_max_backoff
281276
FROM
282277
v1_task t
283-
LEFT JOIN
284-
v1_task_runtime tr ON tr.task_id = t.id
285-
AND tr.task_inserted_at = t.inserted_at
286-
AND tr.retry_count = t.retry_count
287-
AND tr.tenant_id = t.tenant_id
288-
AND t.batch_key IS NOT NULL
289278
WHERE
290279
t.tenant_id = @tenantId::uuid
291280
AND t.id = ANY(@ids::bigint[]);

pkg/repository/sqlcv1/tasks.sql.go

Lines changed: 7 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/worker/batch.go

Lines changed: 0 additions & 153 deletions
This file was deleted.

pkg/worker/context.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ type HatchetContext interface {
127127
TriggeringEventId() *string
128128

129129
TriggeringEventKey() *string
130-
131-
// BatchId returns the batch ID if this step run is part of a batch task, or nil otherwise.
132-
BatchId() *string
133-
134-
// BatchIndex returns the index of this item within the batch, or nil if not a batch item.
135-
BatchIndex() *int32
136130
}
137131

138132
// DurableEvictionHook observes waiting state transitions for a durable run so an
@@ -418,14 +412,6 @@ func (h *hatchetContext) DurableTaskInvocationCount() int32 {
418412
return 0
419413
}
420414

421-
func (h *hatchetContext) BatchId() *string {
422-
return h.a.BatchId
423-
}
424-
425-
func (h *hatchetContext) BatchIndex() *int32 {
426-
return h.a.BatchIndex
427-
}
428-
429415
func (h *hatchetContext) SetDurableEvictionHook(hook DurableEvictionHook) {
430416
h.evictionHookMu.Lock()
431417
defer h.evictionHookMu.Unlock()

pkg/worker/middleware_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,6 @@ func (c *testHatchetContext) WorkerId() string {
182182
panic("not implemented")
183183
}
184184

185-
func (c *testHatchetContext) BatchId() *string {
186-
return nil
187-
}
188-
189-
func (c *testHatchetContext) BatchIndex() *int32 {
190-
return nil
191-
}
192-
193185
func TestAddMiddleware(t *testing.T) {
194186
m := middlewares{}
195187
middlewareFunc := func(ctx HatchetContext, next func(HatchetContext) error) error {

pkg/worker/worker.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,6 @@ type Worker struct {
141141
id *string
142142

143143
panicHandler func(ctx HatchetContext, recovered any)
144-
145-
// batchFns maps actionId → BatchWrappedFn for batch task processing.
146-
batchFns sync.Map
147-
148-
// batchStates maps batchId → *batchGroupState for in-flight batch tracking.
149-
batchStates sync.Map
150144
}
151145

152146
// Deprecated: WorkerOpt is an internal type used by the new Go SDK.
@@ -467,17 +461,6 @@ func (w *Worker) On(t triggerConverter, workflow workflowConverter) error {
467461
return svc.(*Service).On(t, workflow)
468462
}
469463

470-
// RegisterBatchAction registers a batch action function for the given action ID.
471-
// When a batch step run arrives, the worker buffers it and calls fn with all items once the batch is ready.
472-
func (w *Worker) RegisterBatchAction(actionId string, fn BatchWrappedFn) error {
473-
w.batchFns.Store(actionId, fn)
474-
475-
// Register a regular action whose sole job is to enqueue this item and wait for the batch result.
476-
return w.RegisterAction(actionId, func(ctx HatchetContext) (interface{}, error) {
477-
return w.handleBatchItem(ctx, actionId)
478-
})
479-
}
480-
481464
// Deprecated: RegisterAction is an internal method used by the new Go SDK.
482465
// Use the new Go SDK at github.com/hatchet-dev/hatchet/sdks/go instead of calling this directly. Migration guide: https://docs.hatchet.run/home/migration-guide-go
483466
//
@@ -679,12 +662,6 @@ func (w *Worker) executeAction(ctx context.Context, assignedAction *client.Actio
679662
return w.cancelStepRun(ctx, assignedAction)
680663
case client.ActionTypeStartGetGroupKey:
681664
return w.startGetGroupKey(ctx, assignedAction)
682-
case client.ActionTypeStartBatch:
683-
if assignedAction.BatchId == nil || assignedAction.BatchStart == nil {
684-
return fmt.Errorf("START_BATCH action missing batch ID or batch start payload")
685-
}
686-
w.handleStartBatch(assignedAction.ActionId, *assignedAction.BatchId, assignedAction.BatchStart.ExpectedSize)
687-
return nil
688665
default:
689666
return fmt.Errorf("unknown action type: %s", assignedAction.ActionType)
690667
}

0 commit comments

Comments
 (0)