998 lines
No EOL
40 KiB
HTML
998 lines
No EOL
40 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
|
||
<html lang="fr" data-content_root="../../" >
|
||
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
|
||
<title>Modèle asynchrone et codes de retour — Documentation two 0.1.0</title>
|
||
|
||
|
||
|
||
<script data-cfasync="false">
|
||
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
|
||
document.documentElement.dataset.theme = localStorage.getItem("theme") || "";
|
||
</script>
|
||
<!--
|
||
this give us a css class that will be invisible only if js is disabled
|
||
-->
|
||
<noscript>
|
||
<style>
|
||
.pst-js-only { display: none !important; }
|
||
|
||
</style>
|
||
</noscript>
|
||
|
||
<!-- Loaded before other Sphinx assets -->
|
||
<link href="../../_static/styles/theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
|
||
<link href="../../_static/styles/pydata-sphinx-theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
|
||
|
||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=8f2a1f02" />
|
||
<link rel="stylesheet" type="text/css" href="../../_static/styles/sphinx-book-theme.css?v=3c74b3bc" />
|
||
|
||
<!-- So that users can add custom icons -->
|
||
<script src="../../_static/scripts/fontawesome.js?digest=8878045cc6db502f8baf"></script>
|
||
<!-- Pre-loaded scripts that we'll load fully later -->
|
||
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
|
||
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
|
||
|
||
<script src="../../_static/documentation_options.js?v=57395fb6"></script>
|
||
<script src="../../_static/doctools.js?v=fd6eb6e6"></script>
|
||
<script src="../../_static/sphinx_highlight.js?v=6ffebe34"></script>
|
||
<script src="../../_static/scripts/sphinx-book-theme.js?v=fab101a9"></script>
|
||
<script src="../../_static/translations.js?v=e6b791cb"></script>
|
||
<script src="https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js"></script>
|
||
<script type="module">import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11.12.1/dist/mermaid.esm.min.mjs";
|
||
|
||
|
||
|
||
|
||
|
||
const initStyles = () => {
|
||
const defaultStyle = document.createElement('style');
|
||
defaultStyle.textContent = `pre.mermaid {
|
||
/* Same as .mermaid-container > pre */
|
||
display: block;
|
||
width: 100%;
|
||
}
|
||
|
||
pre.mermaid > svg {
|
||
/* Same as .mermaid-container > pre > svg */
|
||
height: 500px;
|
||
width: 100%;
|
||
max-width: 100% !important;
|
||
}`;
|
||
document.head.appendChild(defaultStyle);
|
||
|
||
const fullscreenStyle = document.createElement('style');
|
||
fullscreenStyle.textContent = `.mermaid-container {
|
||
display: flex;
|
||
flex-direction: row;
|
||
width: 100%;
|
||
}
|
||
|
||
.mermaid-container > pre {
|
||
display: block;
|
||
width: 100%;
|
||
}
|
||
|
||
.mermaid-container > pre > svg {
|
||
height: 500px;
|
||
width: 100%;
|
||
max-width: 100% !important;
|
||
}
|
||
|
||
.mermaid-fullscreen-btn {
|
||
width: 28px;
|
||
height: 28px;
|
||
background: rgba(255, 255, 255, 0.95);
|
||
border: 1px solid rgba(0, 0, 0, 0.3);
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
transition: all 0.2s;
|
||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
|
||
font-size: 14px;
|
||
line-height: 1;
|
||
padding: 0;
|
||
color: #333;
|
||
}
|
||
|
||
.mermaid-fullscreen-btn:hover {
|
||
opacity: 100% !important;
|
||
background: rgba(255, 255, 255, 1);
|
||
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
|
||
transform: scale(1.1);
|
||
}
|
||
|
||
.mermaid-fullscreen-btn.dark-theme {
|
||
background: rgba(50, 50, 50, 0.95);
|
||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||
color: #e0e0e0;
|
||
}
|
||
|
||
.mermaid-fullscreen-btn.dark-theme:hover {
|
||
background: rgba(60, 60, 60, 1);
|
||
box-shadow: 0 3px 10px rgba(255, 255, 255, 0.2);
|
||
}
|
||
|
||
.mermaid-fullscreen-modal {
|
||
display: none;
|
||
position: fixed !important;
|
||
top: 0 !important;
|
||
left: 0 !important;
|
||
width: 95vw;
|
||
height: 100vh;
|
||
background: rgba(255, 255, 255, 0.98);
|
||
z-index: 9999;
|
||
padding: 20px;
|
||
overflow: auto;
|
||
}
|
||
|
||
.mermaid-fullscreen-modal.dark-theme {
|
||
background: rgba(0, 0, 0, 0.98);
|
||
}
|
||
|
||
.mermaid-fullscreen-modal.active {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.mermaid-container-fullscreen {
|
||
position: relative;
|
||
width: 95vw;
|
||
height: 90vh;
|
||
max-width: 95vw;
|
||
max-height: 90vh;
|
||
background: white;
|
||
border-radius: 8px;
|
||
padding: 20px;
|
||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
|
||
overflow: auto;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.mermaid-container-fullscreen.dark-theme {
|
||
background: #1a1a1a;
|
||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
|
||
}
|
||
|
||
.mermaid-container-fullscreen pre.mermaid {
|
||
width: 100%;
|
||
height: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.mermaid-container-fullscreen .mermaid svg {
|
||
height: 100% !important;
|
||
width: 100% !important;
|
||
cursor: grab;
|
||
}
|
||
|
||
.mermaid-fullscreen-close {
|
||
position: fixed !important;
|
||
top: 20px !important;
|
||
right: 20px !important;
|
||
width: 40px;
|
||
height: 40px;
|
||
background: rgba(255, 255, 255, 0.95);
|
||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||
border-radius: 50%;
|
||
cursor: pointer;
|
||
z-index: 10000;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||
transition: all 0.2s;
|
||
font-size: 24px;
|
||
line-height: 1;
|
||
color: #333;
|
||
}
|
||
|
||
.mermaid-fullscreen-close:hover {
|
||
background: white;
|
||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
|
||
transform: scale(1.1);
|
||
}
|
||
|
||
.mermaid-fullscreen-close.dark-theme {
|
||
background: rgba(50, 50, 50, 0.95);
|
||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||
color: #e0e0e0;
|
||
}
|
||
|
||
.mermaid-fullscreen-close.dark-theme:hover {
|
||
background: rgba(60, 60, 60, 1);
|
||
box-shadow: 0 6px 16px rgba(255, 255, 255, 0.2);
|
||
}
|
||
|
||
.mermaid-fullscreen-modal .mermaid-fullscreen-btn {
|
||
display: none !important;
|
||
}`;
|
||
document.head.appendChild(fullscreenStyle);
|
||
}
|
||
|
||
// Detect if page has dark background
|
||
const isDarkTheme = () => {
|
||
// We use a set of heuristics:
|
||
// 1. Check for common dark mode classes or attributes
|
||
// 2. Check computed background color brightness
|
||
if (document.documentElement.classList.contains('dark') ||
|
||
document.documentElement.getAttribute('data-theme') === 'dark' ||
|
||
document.body.classList.contains('dark') ||
|
||
document.body.getAttribute('data-theme') === 'dark') {
|
||
// console.log("Dark theme detected via class/attribute");
|
||
return true;
|
||
}
|
||
if (document.documentElement.classList.contains('light') ||
|
||
document.documentElement.getAttribute('data-theme') === 'light' ||
|
||
document.body.classList.contains('light') ||
|
||
document.body.getAttribute('data-theme') === 'light') {
|
||
// console.log("Light theme detected via class/attribute");
|
||
return false;
|
||
}
|
||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||
// console.log("Dark theme detected via prefers-color-scheme");
|
||
return true;
|
||
}
|
||
const bgColor = window.getComputedStyle(document.body).backgroundColor;
|
||
const match = bgColor.match(/rgb\((\d+),\s*(\d+),\s*(\d+)/);
|
||
if (match) {
|
||
const r = parseInt(match[1]);
|
||
const g = parseInt(match[2]);
|
||
const b = parseInt(match[3]);
|
||
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
||
// console.log("Background color brightness:", brightness);
|
||
return brightness < 128;
|
||
}
|
||
// console.log("No dark or light theme detected, defaulting to light theme");
|
||
return false;
|
||
};
|
||
|
||
let darkTheme = isDarkTheme();
|
||
let modal = null;
|
||
let modalContent = null;
|
||
let previousScrollOffset = [window.scrollX, window.scrollY];
|
||
|
||
const runMermaid = async (rerun) => {
|
||
console.log("Running mermaid diagrams, rerun =", rerun);
|
||
// clear all existing mermaid charts
|
||
let all_mermaids = document.querySelectorAll(".mermaid");
|
||
|
||
if (rerun) {
|
||
all_mermaids.forEach((el) => {
|
||
if(!el.hasAttribute("data-original-code")) {
|
||
// store original code
|
||
// console.log(`Storing original code for first run: `, el.innerHTML);
|
||
el.setAttribute('data-original-code', el.innerHTML);
|
||
}
|
||
if(el.getAttribute("data-processed") === "true") {
|
||
// remove and restore original
|
||
el.removeAttribute("data-processed");
|
||
// console.log(`Restoring original code for re-run: `, el.getAttribute('data-original-code'));
|
||
el.innerHTML = el.getAttribute('data-original-code');
|
||
} else {
|
||
// store original code
|
||
// console.log(`Storing original code for re-run: `, el.innerHTML);
|
||
el.setAttribute('data-original-code', el.innerHTML);
|
||
}
|
||
});
|
||
await mermaid.run();
|
||
}
|
||
|
||
all_mermaids = document.querySelectorAll(".mermaid");
|
||
const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
|
||
|
||
if ("False" === "True") {
|
||
const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
|
||
if(mermaids_to_add_zoom > 0) {
|
||
var svgs = d3.selectAll("");
|
||
if(all_mermaids.length !== mermaids_processed.length) {
|
||
setTimeout(() => runMermaid(false), 200);
|
||
return;
|
||
} else if(svgs.size() !== mermaids_to_add_zoom) {
|
||
setTimeout(() => runMermaid(false), 200);
|
||
return;
|
||
} else {
|
||
svgs.each(function() {
|
||
var svg = d3.select(this);
|
||
svg.html("<g class='wrapper'>" + svg.html() + "</g>");
|
||
var inner = svg.select("g");
|
||
var zoom = d3.zoom().on("zoom", function(event) {
|
||
inner.attr("transform", event.transform);
|
||
});
|
||
svg.call(zoom);
|
||
});
|
||
}
|
||
}
|
||
} else if(all_mermaids.length !== mermaids_processed.length) {
|
||
// Wait for mermaid to process all diagrams
|
||
setTimeout(() => runMermaid(false), 200);
|
||
return;
|
||
}
|
||
|
||
// Stop here if not adding fullscreen capability
|
||
if ("True" !== "True") return;
|
||
|
||
if (modal !== null ) {
|
||
// Destroy existing modal
|
||
modal.remove();
|
||
modal = null;
|
||
modalContent = null;
|
||
}
|
||
|
||
modal = document.createElement('div');
|
||
modal.className = 'mermaid-fullscreen-modal' + (darkTheme ? ' dark-theme' : '');
|
||
modal.setAttribute('role', 'dialog');
|
||
modal.setAttribute('aria-modal', 'true');
|
||
modal.setAttribute('aria-label', 'Fullscreen diagram viewer');
|
||
modal.innerHTML = `
|
||
<button class="mermaid-fullscreen-close${darkTheme ? ' dark-theme' : ''}" aria-label="Close fullscreen">✕</button>
|
||
<div class="mermaid-container-fullscreen${darkTheme ? ' dark-theme' : ''}"></div>
|
||
`;
|
||
document.body.appendChild(modal);
|
||
|
||
modalContent = modal.querySelector('.mermaid-container-fullscreen');
|
||
const closeBtn = modal.querySelector('.mermaid-fullscreen-close');
|
||
|
||
const closeModal = () => {
|
||
modal.classList.remove('active');
|
||
modalContent.innerHTML = '';
|
||
document.body.style.overflow = ''
|
||
window.scrollTo({left: previousScrollOffset[0], top: previousScrollOffset[1], behavior: 'instant'});
|
||
};
|
||
|
||
closeBtn.addEventListener('click', closeModal);
|
||
modal.addEventListener('click', (e) => {
|
||
if (e.target === modal) closeModal();
|
||
});
|
||
document.addEventListener('keydown', (e) => {
|
||
if (e.key === 'Escape' && modal.classList.contains('active')) {
|
||
closeModal();
|
||
}
|
||
});
|
||
|
||
document.querySelectorAll('.mermaid').forEach((mermaidDiv) => {
|
||
if (mermaidDiv.parentNode.classList.contains('mermaid-container') ||
|
||
mermaidDiv.closest('.mermaid-fullscreen-modal')) {
|
||
// Already processed, adjust button class if needed
|
||
const existingBtn = mermaidDiv.parentNode.querySelector('.mermaid-fullscreen-btn');
|
||
if (existingBtn) {
|
||
existingBtn.className = 'mermaid-fullscreen-btn' + (darkTheme ? ' dark-theme' : '');
|
||
}
|
||
return;
|
||
}
|
||
|
||
const container = document.createElement('div');
|
||
container.className = 'mermaid-container';
|
||
mermaidDiv.parentNode.insertBefore(container, mermaidDiv);
|
||
container.appendChild(mermaidDiv);
|
||
|
||
const fullscreenBtn = document.createElement('button');
|
||
fullscreenBtn.className = 'mermaid-fullscreen-btn' + (darkTheme ? ' dark-theme' : '');
|
||
fullscreenBtn.setAttribute('aria-label', 'View diagram in fullscreen');
|
||
fullscreenBtn.textContent = '⛶';
|
||
fullscreenBtn.style.opacity = '50%';
|
||
|
||
// Calculate dynamic position based on diagram's margin and padding
|
||
const diagramStyle = window.getComputedStyle(mermaidDiv);
|
||
const marginTop = parseFloat(diagramStyle.marginTop) || 0;
|
||
const marginRight = parseFloat(diagramStyle.marginRight) || 0;
|
||
const paddingTop = parseFloat(diagramStyle.paddingTop) || 0;
|
||
const paddingRight = parseFloat(diagramStyle.paddingRight) || 0;
|
||
fullscreenBtn.style.top = `${marginTop + paddingTop + 4}px`;
|
||
fullscreenBtn.style.right = `${marginRight + paddingRight + 4}px`;
|
||
|
||
fullscreenBtn.addEventListener('click', () => {
|
||
previousScrollOffset = [window.scroll, window.scrollY];
|
||
const clone = mermaidDiv.cloneNode(true);
|
||
modalContent.innerHTML = '';
|
||
modalContent.appendChild(clone);
|
||
|
||
const svg = clone.querySelector('svg');
|
||
if (svg) {
|
||
svg.removeAttribute('width');
|
||
svg.removeAttribute('height');
|
||
svg.style.width = '100%';
|
||
svg.style.height = 'auto';
|
||
svg.style.maxWidth = '100%';
|
||
svg.style.sdisplay = 'block';
|
||
|
||
if ("False" === "True") {
|
||
setTimeout(() => {
|
||
const g = svg.querySelector('g');
|
||
if (g) {
|
||
var svgD3 = d3.select(svg);
|
||
svgD3.html("<g class='wrapper'>" + svgD3.html() + "</g>");
|
||
var inner = svgD3.select("g");
|
||
var zoom = d3.zoom().on("zoom", function(event) {
|
||
inner.attr("transform", event.transform);
|
||
});
|
||
svgD3.call(zoom);
|
||
}
|
||
}, 100);
|
||
}
|
||
}
|
||
|
||
modal.classList.add('active');
|
||
document.body.style.overflow = 'hidden';
|
||
});
|
||
container.appendChild(fullscreenBtn);
|
||
});
|
||
};
|
||
|
||
const load = async () => {
|
||
initStyles();
|
||
|
||
await runMermaid(true);
|
||
|
||
const reRunIfThemeChanges = async () => {
|
||
const newDarkTheme = isDarkTheme();
|
||
if (newDarkTheme !== darkTheme) {
|
||
darkTheme = newDarkTheme;
|
||
console.log("Theme change detected, re-running mermaid with", darkTheme ? "dark" : "default", "theme");
|
||
await mermaid.initialize(
|
||
{...JSON.parse(
|
||
`{"startOnLoad": false}`
|
||
),
|
||
...{ darkMode: darkTheme, theme: darkTheme ? 'dark' : 'default' },
|
||
}
|
||
);
|
||
await runMermaid(true);
|
||
}
|
||
};
|
||
|
||
// Update theme classes when theme changes
|
||
const themeObserver = new MutationObserver(reRunIfThemeChanges);
|
||
themeObserver.observe(document.documentElement, {
|
||
attributes: true,
|
||
attributeFilter: ['class', 'style', 'data-theme']
|
||
});
|
||
themeObserver.observe(document.body, {
|
||
attributes: true,
|
||
attributeFilter: ['class', 'style', 'data-theme']
|
||
});
|
||
};
|
||
|
||
|
||
|
||
|
||
|
||
console.log("Initializing mermaid with", darkTheme ? "dark" : "default", "theme");
|
||
mermaid.initialize(
|
||
{...JSON.parse(
|
||
`{"startOnLoad": false}`
|
||
),
|
||
...{ darkMode: darkTheme, theme: darkTheme ? 'dark' : 'default' },
|
||
}
|
||
);
|
||
|
||
window.addEventListener("load", load);
|
||
window.runMermaid = runMermaid;</script>
|
||
<script>DOCUMENTATION_OPTIONS.pagename = 'exploitation/api-agent/asynchronisme';</script>
|
||
<script>
|
||
DOCUMENTATION_OPTIONS.theme_version = '0.16.1';
|
||
DOCUMENTATION_OPTIONS.theme_switcher_json_url = '../switcher.json';
|
||
DOCUMENTATION_OPTIONS.theme_switcher_version_match = 'main';
|
||
DOCUMENTATION_OPTIONS.show_version_warning_banner =
|
||
false;
|
||
</script>
|
||
<link rel="index" title="Index" href="../../genindex.html" />
|
||
<link rel="search" title="Recherche" href="../../search.html" />
|
||
<link rel="next" title="Référence" href="reference.html" />
|
||
<link rel="prev" title="API de l’agent" href="index.html" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
<meta name="docsearch:language" content="fr"/>
|
||
<meta name="docsearch:version" content="0.1" />
|
||
</head>
|
||
|
||
|
||
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">
|
||
|
||
|
||
|
||
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Passer au contenu principal</a></div>
|
||
|
||
<div id="pst-scroll-pixel-helper"></div>
|
||
|
||
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
|
||
<i class="fa-solid fa-arrow-up"></i>Haut de page</button>
|
||
|
||
|
||
<dialog id="pst-search-dialog">
|
||
|
||
<form class="bd-search d-flex align-items-center"
|
||
action="../../search.html"
|
||
method="get">
|
||
<i class="fa-solid fa-magnifying-glass"></i>
|
||
<input type="search"
|
||
class="form-control"
|
||
name="q"
|
||
placeholder="Search..."
|
||
aria-label="Search..."
|
||
autocomplete="off"
|
||
autocorrect="off"
|
||
autocapitalize="off"
|
||
spellcheck="false"/>
|
||
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
|
||
</form>
|
||
</dialog>
|
||
|
||
<div class="pst-async-banner-revealer d-none">
|
||
<aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Alerte de version"></aside>
|
||
</div>
|
||
|
||
|
||
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
|
||
</header>
|
||
|
||
|
||
<div class="bd-container">
|
||
<div class="bd-container__inner bd-page-width">
|
||
|
||
|
||
|
||
<dialog id="pst-primary-sidebar-modal"></dialog>
|
||
<div id="pst-primary-sidebar" class="bd-sidebar-primary bd-sidebar">
|
||
|
||
|
||
|
||
<div class="sidebar-header-items sidebar-primary__section">
|
||
|
||
|
||
|
||
|
||
</div>
|
||
|
||
<div class="sidebar-primary-items__start sidebar-primary__section">
|
||
<div class="sidebar-primary-item">
|
||
|
||
|
||
|
||
|
||
|
||
<a class="navbar-brand logo" href="../../index.html">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<p class="title logo__title">Documentation two 0.1.0</p>
|
||
|
||
</a></div>
|
||
<div class="sidebar-primary-item"><ul class="navbar-icon-links"
|
||
aria-label="Icon Links">
|
||
<li class="nav-item">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<a href="https://git.g3e.fr/syonad/two" title="Dépôt" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-solid fa-code-branch fa-lg" aria-hidden="true"></i>
|
||
<span class="sr-only">Dépôt</span></a>
|
||
</li>
|
||
</ul></div>
|
||
<div class="sidebar-primary-item">
|
||
<div class="version-switcher__container dropdown pst-js-only">
|
||
<button id="pst-version-switcher-button-2"
|
||
type="button"
|
||
class="version-switcher__button btn btn-sm dropdown-toggle"
|
||
data-bs-toggle="dropdown"
|
||
aria-haspopup="listbox"
|
||
aria-controls="pst-version-switcher-list-2"
|
||
aria-label="Version switcher list"
|
||
>
|
||
Choose version <!-- this text may get changed later by javascript -->
|
||
<span class="caret"></span>
|
||
</button>
|
||
<div id="pst-version-switcher-list-2"
|
||
class="version-switcher__menu dropdown-menu list-group-flush py-0"
|
||
role="listbox" aria-labelledby="pst-version-switcher-button-2">
|
||
<!-- dropdown will be populated by javascript on page load -->
|
||
</div>
|
||
</div></div>
|
||
<div class="sidebar-primary-item">
|
||
|
||
<button class="btn search-button-field search-button__button pst-js-only" title="Recherche" aria-label="Recherche" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<i class="fa-solid fa-magnifying-glass"></i>
|
||
<span class="search-button__default-text">Recherche</span>
|
||
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
|
||
</button></div>
|
||
<div class="sidebar-primary-item"><nav class="bd-links bd-docs-nav" aria-label="Main">
|
||
<div class="bd-toc-item navbar-nav active">
|
||
|
||
<ul class="nav bd-sidenav bd-sidenav__home-link">
|
||
<li class="toctree-l1">
|
||
<a class="reference internal" href="../../index.html">
|
||
two
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Mise en œuvre</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../demarrage/index.html">Démarrage</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../demarrage/installation.html">Installation d’un hyperviseur</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../demarrage/premier-vpc.html">Premier VPC, premier subnet, première VM</a></li>
|
||
</ul>
|
||
</details></li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../deploiement/index.html">Déploiement d’un cluster</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../deploiement/architecture-cluster.html">Architecture du cluster</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../deploiement/image-qcow2.html">Construction de l’image qcow2</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../deploiement/routeurs.html">Routeurs</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../deploiement/premier-hyperviseur.html">Premier hyperviseur</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../deploiement/route-reflector.html">VM route reflector</a></li>
|
||
</ul>
|
||
</details></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Exploitation</span></p>
|
||
<ul class="current nav bd-sidenav">
|
||
<li class="toctree-l1 current active has-children"><a class="reference internal" href="../index.html">Exploitation</a><details open="open"><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul class="current">
|
||
<li class="toctree-l2"><a class="reference internal" href="../configuration.html">Configuration</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../services.html">Services systemd</a></li>
|
||
<li class="toctree-l2 current active has-children"><a class="reference internal" href="index.html">API de l’agent</a><details open="open"><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul class="current">
|
||
<li class="toctree-l3 current active"><a class="current reference internal" href="#">Modèle asynchrone et codes de retour</a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="reference.html">Référence</a></li>
|
||
</ul>
|
||
</details></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../observabilite.html">Observabilité</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../diagnostic.html">Diagnostic</a></li>
|
||
</ul>
|
||
</details></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Développement</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../developpement/index.html">Développement</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../developpement/lab.html">Lab de test multi-nœud</a></li>
|
||
</ul>
|
||
</details></li>
|
||
</ul>
|
||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Interne</span></p>
|
||
<ul class="nav bd-sidenav">
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../concepts/index.html">Concepts</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../concepts/vpc-subnet-vm.html">VPC, subnet et VM</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../concepts/modes-reseau.html">Modes réseau</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../concepts/cycle-de-vie.html">Cycle de vie des ressources</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../concepts/metadata-cloud-init.html">Metadata et cloud-init</a></li>
|
||
</ul>
|
||
</details></li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../architecture/index.html">Architecture</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../architecture/vue-densemble.html">Vue d’ensemble</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../architecture/stockage.html">Schéma des clés</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../architecture/contraintes.html">Invariants et pièges</a></li>
|
||
</ul>
|
||
</details></li>
|
||
<li class="toctree-l1 has-children"><a class="reference internal" href="../../versions/index.html">Versions</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../versions/0.2.0.html">Bael</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../../versions/0.1.0.html">Michael</a></li>
|
||
</ul>
|
||
</details></li>
|
||
</ul>
|
||
|
||
</div>
|
||
</nav></div>
|
||
</div>
|
||
|
||
|
||
<div class="sidebar-primary-items__end sidebar-primary__section">
|
||
<div class="sidebar-primary-item">
|
||
<div id="ethical-ad-placement"
|
||
class="flat"
|
||
data-ea-publisher="readthedocs"
|
||
data-ea-type="readthedocs-sidebar"
|
||
data-ea-manual="true">
|
||
</div></div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
<main id="main-content" class="bd-main" role="main">
|
||
|
||
|
||
|
||
<div class="sbt-scroll-pixel-helper"></div>
|
||
|
||
<div class="bd-content">
|
||
<div class="bd-article-container">
|
||
|
||
<div class="bd-header-article d-print-none">
|
||
<div class="header-article-items header-article__inner">
|
||
|
||
<div class="header-article-items__start">
|
||
|
||
<div class="header-article-item"><button class="sidebar-toggle primary-toggle btn btn-sm" title="Toggle primary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<span class="fa-solid fa-bars"></span>
|
||
</button></div>
|
||
|
||
</div>
|
||
|
||
|
||
<div class="header-article-items__end">
|
||
|
||
<div class="header-article-item">
|
||
|
||
<div class="article-header-buttons">
|
||
|
||
|
||
|
||
<button onclick="toggleFullScreen()"
|
||
class="btn btn-sm btn-fullscreen-button pst-navbar-icon"
|
||
title="Mode plein écran"
|
||
data-bs-placement="bottom" data-bs-toggle="tooltip"
|
||
>
|
||
|
||
|
||
<span class="btn__icon-container">
|
||
<i class="fas fa-expand"></i>
|
||
</span>
|
||
|
||
</button>
|
||
|
||
|
||
|
||
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Thème" data-bs-title="Thème" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Clair"></i>
|
||
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Sombre"></i>
|
||
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="Paramètres système"></i>
|
||
</button>
|
||
|
||
|
||
<button class="btn btn-sm pst-navbar-icon search-button search-button__button pst-js-only" title="Recherche" aria-label="Recherche" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
|
||
</button>
|
||
<button class="sidebar-toggle secondary-toggle btn btn-sm pst-navbar-icon" title="Toggle secondary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
|
||
<span class="fa-solid fa-list"></span>
|
||
</button>
|
||
</div></div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
<div id="jb-print-docs-body" class="onlyprint">
|
||
<h1>Modèle asynchrone et codes de retour</h1>
|
||
<!-- Table of contents -->
|
||
<div id="print-main-content">
|
||
<div id="jb-print-toc">
|
||
|
||
<div>
|
||
<h2> Contenu </h2>
|
||
</div>
|
||
<nav aria-label="Page">
|
||
<ul class="visible nav section-nav flex-column">
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#les-deux-temps-d-une-requete">Les deux temps d’une requête</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#attendre-correctement">Attendre correctement</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#codes-de-retour">Codes de retour</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#idempotence">Idempotence</a></li>
|
||
</ul>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
<div id="searchbox"></div>
|
||
<article class="bd-article">
|
||
|
||
<section id="modele-asynchrone-et-codes-de-retour">
|
||
<h1>Modèle asynchrone et codes de retour<a class="headerlink" href="#modele-asynchrone-et-codes-de-retour" title="Lien vers cette rubrique">#</a></h1>
|
||
<p>Toute création et toute suppression sont <strong>asynchrones</strong>. C’est le point qui surprend le plus
|
||
souvent à l’intégration : un <code class="docutils literal notranslate"><span class="pre">202</span></code> ne dit pas que la ressource existe, il dit que la demande
|
||
a été acceptée et enregistrée.</p>
|
||
<section id="les-deux-temps-d-une-requete">
|
||
<h2>Les deux temps d’une requête<a class="headerlink" href="#les-deux-temps-d-une-requete" title="Lien vers cette rubrique">#</a></h2>
|
||
<pre class="mermaid">
|
||
sequenceDiagram
|
||
participant C as Appelant
|
||
participant A as API
|
||
participant W as Worker
|
||
C->>A: POST /subnets
|
||
A->>A: Prepare — valide, écrit "creating"
|
||
A-->>C: 202 + ressource en creating
|
||
A->>W: Dispatch (file d'attente)
|
||
W->>W: Execute — netns, netif, dhcp
|
||
W->>W: état → running (ou error)
|
||
C->>A: GET /subnets/<name>
|
||
A-->>C: 200 + state
|
||
</pre><p><strong>Prepare</strong> est synchrone, dans le handler HTTP : il valide l’état, écrit l’état initial en base
|
||
et répond. <strong>Execute</strong> est asynchrone : il fait le travail réseau réel, puis positionne l’état
|
||
final.</p>
|
||
<p>Conséquence directe : un échec d”<code class="docutils literal notranslate"><span class="pre">Execute</span></code> ne peut pas être remonté dans la réponse HTTP. Il
|
||
se lit dans l’état de la ressource, qui passe à <code class="docutils literal notranslate"><span class="pre">error</span></code>.</p>
|
||
</section>
|
||
<section id="attendre-correctement">
|
||
<h2>Attendre correctement<a class="headerlink" href="#attendre-correctement" title="Lien vers cette rubrique">#</a></h2>
|
||
<p>Il n’y a pas de webhook ni de long-polling : l’appelant interroge <code class="docutils literal notranslate"><span class="pre">GET</span> <span class="pre">/<type>/<name></span></code> jusqu’à
|
||
un état stable.</p>
|
||
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="k">until</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="s2">"</span><span class="k">$(</span>curl<span class="w"> </span>-sf<span class="w"> </span>http://127.0.0.1:8080/subnets/sn-000001<span class="w"> </span><span class="p">|</span><span class="w"> </span>jq<span class="w"> </span>-r<span class="w"> </span>.state<span class="k">)</span><span class="s2">"</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>running<span class="w"> </span><span class="o">]</span><span class="p">;</span><span class="w"> </span><span class="k">do</span>
|
||
<span class="w"> </span>sleep<span class="w"> </span><span class="m">2</span>
|
||
<span class="k">done</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Trois règles pour un appelant robuste :</p>
|
||
<ul class="simple">
|
||
<li><p><strong>Toujours borner l’attente.</strong> Côté agent, <code class="docutils literal notranslate"><span class="pre">dispatcher.timeout_seconds</span></code> (300 s par défaut)
|
||
borne les opérations qui attendent une transition ; l’appelant doit avoir sa propre borne.</p></li>
|
||
<li><p><strong>Traiter ``error`` comme terminal, pas comme un échec transitoire.</strong> Un <code class="docutils literal notranslate"><span class="pre">Execute</span></code> en échec
|
||
ne se rejoue pas tout seul.</p></li>
|
||
<li><p><strong>Ne pas enchaîner sans vérifier.</strong> Créer un subnet dont le VPC est encore en <code class="docutils literal notranslate"><span class="pre">creating</span></code>
|
||
échoue en 422 ; démarrer une VM sur un subnet en <code class="docutils literal notranslate"><span class="pre">creating</span></code> ou <code class="docutils literal notranslate"><span class="pre">running</span></code> est en revanche
|
||
accepté.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="codes-de-retour">
|
||
<h2>Codes de retour<a class="headerlink" href="#codes-de-retour" title="Lien vers cette rubrique">#</a></h2>
|
||
<div class="pst-scrollable-table-container"><table class="table">
|
||
<colgroup>
|
||
<col style="width: 12.0%" />
|
||
<col style="width: 88.0%" />
|
||
</colgroup>
|
||
<thead>
|
||
<tr class="row-odd"><th class="head"><p>Code</p></th>
|
||
<th class="head"><p>Signification</p></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">202</span></code></p></td>
|
||
<td><p>demande acceptée et enregistrée ; l’état passera à <code class="docutils literal notranslate"><span class="pre">running</span></code> ou <code class="docutils literal notranslate"><span class="pre">error</span></code></p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">200</span></code></p></td>
|
||
<td><p>lecture réussie (<code class="docutils literal notranslate"><span class="pre">GET</span></code>)</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">400</span></code></p></td>
|
||
<td><p>champ obligatoire manquant, corps invalide, <code class="docutils literal notranslate"><span class="pre">iface_type</span></code> inconnu, base64 invalide</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">404</span></code></p></td>
|
||
<td><p>ressource inexistante</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">409</span></code></p></td>
|
||
<td><p>conflit d’existence ou d’état : ressource déjà créée, ou suppression depuis un état qui
|
||
ne l’autorise pas ; pour un VPC, subnets encore présents</p></td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">422</span></code></p></td>
|
||
<td><p>dépendance absente ou pas prête : VPC parent d’un subnet, subnet d’une VM</p></td>
|
||
</tr>
|
||
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">500</span></code></p></td>
|
||
<td><p>erreur interne</p></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<p>Le corps d’erreur est uniforme : <code class="docutils literal notranslate"><span class="pre">{"error":</span> <span class="pre">"…"}</span></code>.</p>
|
||
</section>
|
||
<section id="idempotence">
|
||
<h2>Idempotence<a class="headerlink" href="#idempotence" title="Lien vers cette rubrique">#</a></h2>
|
||
<p>Les créations ne sont <strong>pas</strong> idempotentes : recréer une ressource existante donne 409, pas 202.
|
||
Un appelant qui rejoue une requête après un timeout réseau doit donc traiter 409 comme
|
||
« déjà fait », après avoir vérifié l’état par un <code class="docutils literal notranslate"><span class="pre">GET</span></code>.</p>
|
||
<p>Les suppressions depuis l’état <code class="docutils literal notranslate"><span class="pre">error</span></code> sont acceptées mais <strong>best-effort</strong> : les ressources
|
||
système peuvent n’avoir été créées que partiellement, et il n’y a pas de rollback — voir
|
||
<a class="reference internal" href="../../concepts/cycle-de-vie.html"><span class="doc">Cycle de vie des ressources</span></a>.</p>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</article>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<footer class="prev-next-footer d-print-none">
|
||
|
||
<div class="prev-next-area">
|
||
<a class="left-prev"
|
||
href="index.html"
|
||
title="page précédente">
|
||
<i class="fa-solid fa-angle-left"></i>
|
||
<div class="prev-next-info">
|
||
<p class="prev-next-subtitle">précédent</p>
|
||
<p class="prev-next-title">API de l’agent</p>
|
||
</div>
|
||
</a>
|
||
<a class="right-next"
|
||
href="reference.html"
|
||
title="page suivante">
|
||
<div class="prev-next-info">
|
||
<p class="prev-next-subtitle">suivant</p>
|
||
<p class="prev-next-title">Référence</p>
|
||
</div>
|
||
<i class="fa-solid fa-angle-right"></i>
|
||
</a>
|
||
</div>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
<dialog id="pst-secondary-sidebar-modal"></dialog>
|
||
<div id="pst-secondary-sidebar" class="bd-sidebar-secondary bd-toc"><div class="sidebar-secondary-items sidebar-secondary__inner">
|
||
|
||
|
||
<div class="sidebar-secondary-item"><div
|
||
id="pst-page-navigation-heading-2"
|
||
class="page-toc tocsection onthispage">
|
||
<i class="fa-solid fa-list"></i> Contenu
|
||
</div>
|
||
<nav id="pst-page-toc-nav" class="page-toc" aria-labelledby="pst-page-navigation-heading-2">
|
||
<ul class="visible nav section-nav flex-column">
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#les-deux-temps-d-une-requete">Les deux temps d’une requête</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#attendre-correctement">Attendre correctement</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#codes-de-retour">Codes de retour</a></li>
|
||
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#idempotence">Idempotence</a></li>
|
||
</ul>
|
||
</nav></div>
|
||
|
||
</div></div>
|
||
|
||
|
||
</div>
|
||
<footer class="bd-footer-content">
|
||
|
||
<div class="bd-footer-content__inner container">
|
||
|
||
<div class="footer-item">
|
||
|
||
<p class="component-author">
|
||
Par Nicolas Boufidjeline
|
||
</p>
|
||
|
||
</div>
|
||
|
||
<div class="footer-item">
|
||
|
||
|
||
<p class="copyright">
|
||
|
||
© Copyright 2026, Nicolas Boufidjeline.
|
||
<br/>
|
||
|
||
</p>
|
||
|
||
</div>
|
||
|
||
<div class="footer-item">
|
||
|
||
</div>
|
||
|
||
<div class="footer-item">
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</footer>
|
||
|
||
|
||
</main>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Scripts loaded after <body> so the DOM is not blocked -->
|
||
<script defer src="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf"></script>
|
||
<script defer src="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf"></script>
|
||
|
||
<footer class="bd-footer">
|
||
</footer>
|
||
</body>
|
||
</html> |