mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What Use the gRPC principal to classify workers as system workers at upsert time, falling back to task queue prefix matching when principal is not available. ## Why Principal-based classification is more robust than string matching on task queue names and works correctly when principal propagation is enabled. ## How did you test it? Unit tests covering three scenarios: - temporal principal marks worker as system - non-temporal principal overrides task queue prefix - nil principal falls back to prefix matching --------- Co-authored-by: Hanzo Dev <[email protected]>
30 lines
1012 B
Go
30 lines
1012 B
Go
package workers
|
|
|
|
import (
|
|
commonpb "go.temporal.io/api/common/v1"
|
|
workerpb "go.temporal.io/api/worker/v1"
|
|
"go.temporal.io/server/common/namespace"
|
|
)
|
|
|
|
type (
|
|
// ListWorkersParams contains parameters for listing workers.
|
|
ListWorkersParams struct {
|
|
Query string
|
|
PageSize int
|
|
NextPageToken []byte // Opaque token from a previous response to resume pagination.
|
|
IncludeSystemWorkers bool
|
|
}
|
|
|
|
// ListWorkersResponse contains the result of listing workers.
|
|
ListWorkersResponse struct {
|
|
Workers []*workerpb.WorkerHeartbeat
|
|
NextPageToken []byte // Opaque token for the next page; nil if no more results.
|
|
}
|
|
|
|
Registry interface {
|
|
RecordWorkerHeartbeats(nsID namespace.ID, nsName namespace.Name, principal *commonpb.Principal, workerHeartbeat []*workerpb.WorkerHeartbeat)
|
|
ListWorkers(nsID namespace.ID, params ListWorkersParams) (ListWorkersResponse, error)
|
|
DescribeWorker(nsID namespace.ID, workerInstanceKey string) (*workerpb.WorkerHeartbeat, error)
|
|
}
|
|
)
|