翻译修改为队列

This commit is contained in:
2025-05-28 09:30:01 +08:00
parent 86b7b0c608
commit d809b9f666
6 changed files with 556 additions and 148 deletions
+12
View File
@@ -3,6 +3,8 @@
namespace app\service;
use app\util\Xunfei;
use support\Log;
use Webman\RedisQueue\Redis;
class TranslatorService
{
@@ -39,4 +41,14 @@ class TranslatorService
}
return $location;
}
public function queue($field,$sourceLang,$type,$id) {
// 队列名
$queue = 'translator';
// 数据,可以直接传数组,无需序列化
$data = ['entityType' => $type, 'sourceFields' => $field, 'sourceLang' => $sourceLang, 'locale' => 'hello', 'id' => $id];
// 投递消息
Redis::send($queue, $data);
return true;
}
}