Beacon/activities/activities.go
2025-06-24 22:10:31 +08:00

30 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package activities
import (
"beacon/pkg/pb"
"context"
"fmt"
"math/rand"
)
// AddSuffixActivity appends a fixed suffix to the input data.
func AddSuffixActivity(ctx context.Context, data string) (string, error) {
suffixes := []string{
"-one", "-two", "-three", "-four", "-five",
"-six", "-seven", "-eight", "-nine", "-ten",
}
suffix := suffixes[rand.Intn(len(suffixes))]
result := fmt.Sprintf("%s%s", data, suffix)
fmt.Println("Go Activity: Modified data to:", result)
return result, nil
}
// LoadCompositeCaseSteps 辅助 Activity 用于加载复合案例步骤定义 (可选,如果 Workflow 输入不包含完整定义)
func LoadCompositeCaseSteps(ctx context.Context, compositeCaseId string) ([]*pb.CompositeCaseStepDefinition, error) {
// 这是一个 Activity它可以在 Python Worker 或一个 Go Activity Worker 中实现
// 这个 Activity 负责从数据库加载 composite_case_steps 表中的数据
// 并将其转换为 Protobuf 列表返回
// 请确保你在 Python Worker 或另一个 Go Worker 中注册并实现了这个 Activity
return nil, fmt.Errorf("activity not implemented yet") // 仅作示例
}