Files
tasks/common/persistence/sql/sqlplugin/matching_task_v1.go
ba33c258f7 Matching task fairness SQL support (#8099)
## What changed?
Add SQL support for matching task fairness.

Based on #8043 with some changes to reduce code duplication (can be
applied to cassandra later).

## Why?
Support all persistence implementations.

## How did you test it?
- [x] covered by existing tests
- [x] added new unit test(s)

---------

Co-authored-by: sivagirish81 <[email protected]>
2025-07-31 05:01:00 -07:00

42 lines
1.3 KiB
Go

package sqlplugin
import (
"context"
"database/sql"
)
type (
// TasksRow represents a row in tasks table
TasksRow struct {
RangeHash uint32
TaskQueueID []byte
TaskID int64
Data []byte
DataEncoding string
}
// TasksFilter contains the column names within tasks table that
// can be used to filter results through a WHERE clause
TasksFilter struct {
RangeHash uint32
TaskQueueID []byte
InclusiveMinTaskID *int64
ExclusiveMaxTaskID *int64
Limit *int
PageSize *int
}
// MatchingTask is the SQL persistence interface for v1 matching tasks
MatchingTask interface {
InsertIntoTasks(ctx context.Context, rows []TasksRow) (sql.Result, error)
// SelectFromTasks retrieves one or more rows from the tasks table
// Required filter params - {namespaceID, taskqueueName, taskType, inclusiveMinTaskID, exclusiveMaxTaskID, pageSize}
SelectFromTasks(ctx context.Context, filter TasksFilter) ([]TasksRow, error)
// DeleteFromTasks deletes multiple rows from tasks table
// Required filter params:
// - {namespaceID, taskqueueName, taskType, exclusiveMaxTaskID, limit }
// - this will delete upto limit number of tasks less than the given max task id
DeleteFromTasks(ctx context.Context, filter TasksFilter) (sql.Result, error)
}
)