mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
Full module path rebrand from Temporal to Hanzo Tasks: - go.mod module: github.com/hanzoai/tasks - All internal Go imports updated (1906 files) - cmd/server renamed to cmd/tasksd - Binary name: tasksd (was temporal-server) - Docker images: hanzoai/tasks (was temporalio/server) - README rewritten with Hanzo Tasks branding - LLM.md created with integration notes - Makefile, goreleaser, CI workflows updated - go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos) Fork of Temporal.io (MIT license).
74 lines
2.2 KiB
Go
74 lines
2.2 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
enumspb "go.temporal.io/api/enums/v1"
|
|
"github.com/hanzoai/tasks/common"
|
|
"github.com/hanzoai/tasks/common/log/tag"
|
|
"github.com/hanzoai/tasks/common/metrics"
|
|
"github.com/hanzoai/tasks/common/rpc/interceptor"
|
|
"github.com/hanzoai/tasks/service/history/consts"
|
|
historyi "github.com/hanzoai/tasks/service/history/interfaces"
|
|
)
|
|
|
|
func ValidateSignal(
|
|
ctx context.Context,
|
|
shard historyi.ShardContext,
|
|
mutableState historyi.MutableState,
|
|
signalPayloadSize int,
|
|
signalHeaderSize int,
|
|
operation string,
|
|
) error {
|
|
config := shard.GetConfig()
|
|
namespaceEntry := mutableState.GetNamespaceEntry()
|
|
namespaceID := namespaceEntry.ID().String()
|
|
namespaceName := namespaceEntry.Name().String()
|
|
workflowID := mutableState.GetExecutionInfo().WorkflowId
|
|
runID := mutableState.GetExecutionState().RunId
|
|
|
|
executionInfo := mutableState.GetExecutionInfo()
|
|
maxAllowedSignals := config.MaximumSignalsPerExecution(namespaceName)
|
|
blobSizeLimitWarn := config.BlobSizeLimitWarn(namespaceName)
|
|
blobSizeLimitError := config.BlobSizeLimitError(namespaceName)
|
|
|
|
metricsHandler := interceptor.GetMetricsHandlerFromContext(ctx, shard.GetLogger())
|
|
metrics.HeaderSize.With(metricsHandler.WithTags(metrics.HeaderCallsiteTag(operation))).Record(int64(signalHeaderSize))
|
|
if err := common.CheckEventBlobSizeLimit(
|
|
signalPayloadSize,
|
|
blobSizeLimitWarn,
|
|
blobSizeLimitError,
|
|
namespaceName,
|
|
workflowID,
|
|
runID,
|
|
metricsHandler.WithTags(
|
|
metrics.CommandTypeTag(enumspb.COMMAND_TYPE_UNSPECIFIED.String()),
|
|
),
|
|
shard.GetThrottledLogger(),
|
|
operation,
|
|
); err != nil {
|
|
return err
|
|
}
|
|
|
|
if maxAllowedSignals > 0 && int(executionInfo.SignalCount) >= maxAllowedSignals {
|
|
shard.GetLogger().Info("Execution limit reached for maximum signals",
|
|
tag.WorkflowNamespaceID(namespaceID),
|
|
tag.WorkflowID(workflowID),
|
|
tag.WorkflowRunID(runID),
|
|
tag.WorkflowSignalCount(executionInfo.SignalCount),
|
|
)
|
|
return consts.ErrSignalsLimitExceeded
|
|
}
|
|
|
|
if mutableState.IsWorkflowCloseAttempted() && mutableState.HasStartedWorkflowTask() {
|
|
shard.GetThrottledLogger().Info("Signal rejected because workflow is closing",
|
|
tag.WorkflowNamespaceID(namespaceID),
|
|
tag.WorkflowID(workflowID),
|
|
tag.WorkflowRunID(runID),
|
|
)
|
|
return consts.ErrWorkflowClosing
|
|
}
|
|
|
|
return nil
|
|
}
|