Effectuer une étape parallèle avec le workflow secondaire intégré
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Inclut le code source d'un workflow secondaire directement dans le workflow principal pour une meilleure lisibilité.
En savoir plus
Pour obtenir une documentation détaillée incluant cet exemple de code, consultez les articles suivants :
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[],[],null,["# Perform a parallel step with the secondary workflow inlined\n\nIncludes the source code for a secondary workflow directly within the main workflow for easier readability.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Replace experimental function with parallel step](/workflows/docs/migrate-function-to-parallel)\n\nCode sample\n-----------\n\n### YAML\n\n main:\n params: [args]\n steps:\n - init:\n assign:\n - workflow_id: \"translate\"\n - texts_to_translate:\n - text: \"hello world!\"\n source: \"en\"\n target: \"fr\"\n - text: \"你好 世界!\"\n source: \"zh-CN\"\n target: \"en\"\n - text: \"No hablo español!\"\n source: \"es\"\n target: \"en\"\n - translated: [\"\", \"\", \"\"]\n - parallel_translate:\n parallel:\n shared: [translated] # to write to this variable, you must share it\n for:\n range: ${[0, len(texts_to_translate) - 1]}\n value: i\n steps:\n - basic_translate:\n call: googleapis.translate.v2.translations.translate\n args:\n body:\n q: ${args.text}\n target: ${args.target}\n format: \"text\"\n source: ${args.source}\n result: r\n - set_result:\n assign:\n - translated[i]: ${r}\n - return:\n return: ${translated}\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=workflows)."]]