pyyus 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyyus-0.4.1/.github/workflows/cli-publish.yml +23 -0
- pyyus-0.4.1/.gitignore +50 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203/API /345/217/202/350/200/203.md" +530 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203/Python API /345/242/236/345/274/272.md" +1114 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//345/272/224/347/224/250/346/211/247/350/241/214 API/App /347/261/273.md" +385 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//345/272/224/347/224/250/346/211/247/350/241/214 API/Session /347/261/273.md" +1003 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//345/272/224/347/224/250/346/211/247/350/241/214 API//345/272/224/347/224/250/346/211/247/350/241/214 API.md" +502 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//345/272/224/347/224/250/346/211/247/350/241/214 API//351/253/230/351/230/266/345/207/275/346/225/260.md" +618 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//346/265/201/345/274/217 I_O API.md" +378 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//347/273/223/346/236/234/347/261/273/345/236/213 API.md" +561 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//351/205/215/347/275/256/347/256/241/347/220/206 API/AppConfig /345/272/224/347/224/250/351/205/215/347/275/256/347/261/273.md" +457 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//351/205/215/347/275/256/347/256/241/347/220/206 API/RuntimeConfig /350/277/220/350/241/214/346/227/266/351/205/215/347/275/256/347/261/273.md" +1578 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//351/205/215/347/275/256/347/256/241/347/220/206 API/WasmConfig /351/205/215/347/275/256/347/261/273.md" +479 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203//351/205/215/347/275/256/347/256/241/347/220/206 API//351/205/215/347/275/256/347/256/241/347/220/206 API.md" +1789 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/Developer Guide.md +591 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/Examples Tutorials.md +398 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/Testing Infrastructure.md +1457 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content/_internal Api Enhancement.md +605 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227/Python /345/272/224/347/224/250/346/212/200/350/203/275.md" +446 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227/SQLx /344/270/216 WASM /351/233/206/346/210/220.md" +336 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227/WASIP2 API /346/212/200/350/203/275.md" +380 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227/WASIP2 /345/272/224/347/224/250/346/212/200/350/203/275.md" +381 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227.md +1276 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227//346/212/200/350/203/275/346/224/257/346/214/201/347/263/273/347/273/237/Package /345/272/224/347/224/250/346/212/200/350/203/275.md" +650 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227//346/212/200/350/203/275/346/224/257/346/214/201/347/263/273/347/273/237//346/212/200/350/203/275/346/224/257/346/214/201/347/263/273/347/273/237.md +1574 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227//346/217/220/347/244/272/345/267/245/347/250/213/346/214/207/345/215/227.md +726 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227//346/217/220/347/244/272/346/250/241/346/235/277.md +486 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/274/200/345/217/221/350/200/205/346/214/207/345/215/227//346/236/204/345/273/272/350/204/232/346/234/254/346/233/264/346/226/260.md +430 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//345/277/253/351/200/237/345/274/200/345/247/213.md +309 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/240/270/345/277/203/346/246/202/345/277/265/PyO3 /347/273/221/345/256/232/346/234/272/345/210/266.md" +389 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/240/270/345/277/203/346/246/202/345/277/265/WASI /347/263/273/347/273/237/346/216/245/345/217/243.md" +394 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/240/270/345/277/203/346/246/202/345/277/265/WebAssembly /345/237/272/347/241/200.md" +502 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/240/270/345/277/203/346/246/202/345/277/265//345/272/224/347/224/250/346/211/247/350/241/214/346/265/201/347/250/213.md +434 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/240/270/345/277/203/346/246/202/345/277/265//345/274/202/346/255/245/344/272/213/344/273/266/351/251/261/345/212/250/346/236/266/346/236/204.md +445 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/240/270/345/277/203/346/246/202/345/277/265//346/225/260/346/215/256/347/261/273/345/236/213/344/270/216/345/272/217/345/210/227/345/214/226.md +413 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/240/270/345/277/203/346/246/202/345/277/265//346/240/270/345/277/203/346/246/202/345/277/265.md +513 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/265/201/345/274/217/345/244/204/347/220/206/347/263/273/347/273/237//344/272/213/344/273/266/351/251/261/345/212/250/347/263/273/347/273/237.md +473 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/265/201/345/274/217/345/244/204/347/220/206/347/263/273/347/273/237//345/210/206/351/241/265/350/257/273/345/206/231/347/263/273/347/273/237.md +430 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/265/201/345/274/217/345/244/204/347/220/206/347/263/273/347/273/237//345/217/214/345/220/221/346/265/201/346/236/266/346/236/204.md +383 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/265/201/345/274/217/345/244/204/347/220/206/347/263/273/347/273/237//345/220/210/345/271/266/346/265/201/347/263/273/347/273/237.md +616 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/265/201/345/274/217/345/244/204/347/220/206/347/263/273/347/273/237//346/200/247/350/203/275/344/274/230/345/214/226/344/270/216/345/206/205/345/255/230/347/256/241/347/220/206.md +529 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//346/265/201/345/274/217/345/244/204/347/220/206/347/263/273/347/273/237//346/265/201/345/274/217/345/244/204/347/220/206/347/263/273/347/273/237.md +594 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213/Blob /345/255/230/345/202/250/347/244/272/344/276/213/345/272/224/347/224/250.md" +1674 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213/HelloP2 /345/272/224/347/224/250/347/250/213/345/272/217/347/244/272/344/276/213.md" +654 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213/Person-Notes /345/272/224/347/224/250/347/250/213/345/272/217/347/244/272/344/276/213.md" +491 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213//345/237/272/347/241/200/347/244/272/344/276/213.md +375 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213//346/234/200/344/275/263/345/256/236/350/267/265.md +314 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213.md +987 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/244/272/344/276/213/344/270/216/346/225/231/347/250/213//351/253/230/347/272/247/347/244/272/344/276/213.md +357 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237/HTTP /347/273/204/344/273/266.md" +446 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237/PyYus /344/274/232/350/257/235/347/256/241/347/220/206/344/272/214/350/277/233/345/210/266.md" +577 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237/Redis /347/273/204/344/273/266.md" +378 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//344/272/213/344/273/266/347/273/204/344/273/266.md +453 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//345/255/230/345/202/250/347/273/204/344/273/266/Blob /345/255/230/345/202/250/350/203/275/345/212/233.md" +559 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//345/255/230/345/202/250/347/273/204/344/273/266//345/255/230/345/202/250/347/273/204/344/273/266.md +502 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//345/272/224/347/224/250/350/260/203/347/224/250/347/273/204/344/273/266.md +355 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//346/220/234/347/264/242/347/273/204/344/273/266.md +293 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//346/225/260/346/215/256/345/272/223/347/273/204/344/273/266.md +339 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//347/273/204/344/273/266/347/263/273/347/273/237.md +625 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//347/273/204/344/273/266/347/263/273/347/273/237//350/277/233/347/250/213/347/273/204/344/273/266.md +393 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204/WASI 1.0 /346/224/257/346/214/201/WASI 1.0 /346/224/257/346/214/201.md" +498 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204/WASI 1.0 /346/224/257/346/214/201/WASI P1 /346/224/257/346/214/201.md" +381 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204/WASI 2.0 /346/224/257/346/214/201.md" +761 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//345/206/205/345/255/230/347/256/241/347/220/206.md +430 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//344/272/213/344/273/266/347/273/204/344/273/266.md +473 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//345/255/230/345/202/250/347/273/204/344/273/266.md +372 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//345/267/245/345/205/267/347/273/204/344/273/266.md +365 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//345/272/224/347/224/250/347/273/204/344/273/266.md +437 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//346/225/260/346/215/256/345/272/223/347/273/204/344/273/266.md +321 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//346/240/270/345/277/203/347/273/204/344/273/266.md +290 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//347/273/204/344/273/266/347/263/273/347/273/237.md +370 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//347/275/221/347/273/234/347/273/204/344/273/266.md +372 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/273/204/344/273/266/347/263/273/347/273/237//350/277/233/347/250/213/347/273/204/344/273/266.md +378 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//347/274/223/345/255/230/346/234/272/345/210/266.md +475 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204//350/277/220/350/241/214/346/227/266/346/236/266/346/236/204.md +619 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264/CLI/345/217/221/345/270/203/345/267/245/344/275/234/346/265/201/347/250/213.md +250 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//344/270/200/351/224/256/345/256/211/350/243/205/347/263/273/347/273/237.md +531 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//345/217/221/345/270/203/350/207/252/345/212/250/345/214/226.md +267 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//345/244/207/344/273/275/344/270/216/346/201/242/345/244/215.md +439 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//345/256/211/345/205/250/345/212/240/345/233/272.md +374 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//345/256/271/345/231/250/345/214/226/351/203/250/347/275/262.md +290 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//346/200/247/350/203/275/350/260/203/344/274/230.md +438 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//347/233/221/346/216/247/344/270/216/345/221/212/350/255/246.md +358 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264//351/203/250/347/275/262/344/270/216/350/277/220/347/273/264.md +403 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/205/215/347/275/256/347/256/241/347/220/206//345/205/250/345/261/200/351/205/215/347/275/256/346/226/207/344/273/266/347/244/272/344/276/213.md +382 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/205/215/347/275/256/347/256/241/347/220/206//345/212/250/346/200/201/351/205/215/347/275/256.md +413 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/205/215/347/275/256/347/256/241/347/220/206//345/272/224/347/224/250/351/205/215/347/275/256.md +540 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/205/215/347/275/256/347/256/241/347/220/206//346/227/247/351/205/215/347/275/256/345/212/240/350/275/275/346/234/272/345/210/266.md +412 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/205/215/347/275/256/347/256/241/347/220/206//346/237/245/350/257/242/351/205/215/347/275/256.md +540 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/205/215/347/275/256/347/256/241/347/220/206//350/277/220/350/241/214/346/227/266/351/205/215/347/275/256.md +526 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/205/215/347/275/256/347/256/241/347/220/206//351/205/215/347/275/256/347/256/241/347/220/206.md +566 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/224/231/350/257/257/345/244/204/347/220/206/344/270/216/350/260/203/350/257/225//346/227/245/345/277/227/347/263/273/347/273/237.md +395 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/224/231/350/257/257/345/244/204/347/220/206/344/270/216/350/260/203/350/257/225//350/260/203/350/257/225/345/267/245/345/205/267/PyYus CLI /345/242/236/345/274/272/345/212/237/350/203/275.md" +1312 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/224/231/350/257/257/345/244/204/347/220/206/344/270/216/350/260/203/350/257/225//350/260/203/350/257/225/345/267/245/345/205/267//350/260/203/350/257/225/345/267/245/345/205/267.md +577 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/224/231/350/257/257/345/244/204/347/220/206/344/270/216/350/260/203/350/257/225//351/224/231/350/257/257/345/244/204/347/220/206/344/270/216/350/260/203/350/257/225.md +393 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/224/231/350/257/257/345/244/204/347/220/206/344/270/216/350/260/203/350/257/225//351/224/231/350/257/257/347/261/273/345/236/213/344/275/223/347/263/273.md +371 -0
- pyyus-0.4.1/.qoder/repowiki/zh/content//351/241/271/347/233/256/346/246/202/350/277/260.md +394 -0
- pyyus-0.4.1/.qoder/repowiki/zh/meta/repowiki-metadata.json +1 -0
- pyyus-0.4.1/.qoder/settings.local.json +23 -0
- pyyus-0.4.1/Cargo.lock +5838 -0
- pyyus-0.4.1/Cargo.toml +105 -0
- pyyus-0.4.1/PKG-INFO +446 -0
- pyyus-0.4.1/README.md +427 -0
- pyyus-0.4.1/agents.md +8 -0
- pyyus-0.4.1/crates/config/Cargo.toml +21 -0
- pyyus-0.4.1/crates/config/src/config.rs +479 -0
- pyyus-0.4.1/crates/config/src/lib.rs +46 -0
- pyyus-0.4.1/crates/runtime/Cargo.toml +132 -0
- pyyus-0.4.1/crates/runtime/build.rs +8 -0
- pyyus-0.4.1/crates/runtime/src/bin/pyyus.rs +309 -0
- pyyus-0.4.1/crates/runtime/src/bin/pyyus_session.rs +1227 -0
- pyyus-0.4.1/crates/runtime/src/bin/pyyus_tools.rs +998 -0
- pyyus-0.4.1/crates/runtime/src/components/appcall.rs +217 -0
- pyyus-0.4.1/crates/runtime/src/components/base.rs +38 -0
- pyyus-0.4.1/crates/runtime/src/components/blobdo.rs +1837 -0
- pyyus-0.4.1/crates/runtime/src/components/eventdo.rs +76 -0
- pyyus-0.4.1/crates/runtime/src/components/httpdo.rs +1065 -0
- pyyus-0.4.1/crates/runtime/src/components/mod.rs +42 -0
- pyyus-0.4.1/crates/runtime/src/components/processdo.rs +681 -0
- pyyus-0.4.1/crates/runtime/src/components/redisdo.rs +391 -0
- pyyus-0.4.1/crates/runtime/src/components/sqlxdo.rs +454 -0
- pyyus-0.4.1/crates/runtime/src/components/zipdo.rs +231 -0
- pyyus-0.4.1/crates/runtime/src/config/app.rs +427 -0
- pyyus-0.4.1/crates/runtime/src/config/entry.rs +215 -0
- pyyus-0.4.1/crates/runtime/src/config/mod.rs +16 -0
- pyyus-0.4.1/crates/runtime/src/config/runtime.rs +1066 -0
- pyyus-0.4.1/crates/runtime/src/config/skill.rs +159 -0
- pyyus-0.4.1/crates/runtime/src/config/wasm.rs +272 -0
- pyyus-0.4.1/crates/runtime/src/lib.rs +9 -0
- pyyus-0.4.1/crates/runtime/src/pipe/event.rs +689 -0
- pyyus-0.4.1/crates/runtime/src/pipe/header.rs +142 -0
- pyyus-0.4.1/crates/runtime/src/pipe/mod.rs +5 -0
- pyyus-0.4.1/crates/runtime/src/pipe/stdio.rs +167 -0
- pyyus-0.4.1/crates/runtime/src/prelude.rs +5 -0
- pyyus-0.4.1/crates/runtime/src/query/base.rs +354 -0
- pyyus-0.4.1/crates/runtime/src/query/input.rs +31 -0
- pyyus-0.4.1/crates/runtime/src/query/mod.rs +7 -0
- pyyus-0.4.1/crates/runtime/src/query/output.rs +280 -0
- pyyus-0.4.1/crates/runtime/src/session/app_finder.rs +94 -0
- pyyus-0.4.1/crates/runtime/src/session/cache.rs +707 -0
- pyyus-0.4.1/crates/runtime/src/session/mod.rs +6 -0
- pyyus-0.4.1/crates/runtime/src/stream/event_stream.rs +434 -0
- pyyus-0.4.1/crates/runtime/src/stream/function_executor/block_once.rs +53 -0
- pyyus-0.4.1/crates/runtime/src/stream/function_executor/call_once.rs +41 -0
- pyyus-0.4.1/crates/runtime/src/stream/function_executor/loop_caller.rs +60 -0
- pyyus-0.4.1/crates/runtime/src/stream/function_executor/mod.rs +279 -0
- pyyus-0.4.1/crates/runtime/src/stream/function_executor/piped_reader.rs +185 -0
- pyyus-0.4.1/crates/runtime/src/stream/mod.rs +28 -0
- pyyus-0.4.1/crates/runtime/src/stream/prelude.rs +14 -0
- pyyus-0.4.1/crates/runtime/src/stream/unified_stream.rs +233 -0
- pyyus-0.4.1/crates/runtime/src/wasi_runtime/engine.rs +140 -0
- pyyus-0.4.1/crates/runtime/src/wasi_runtime/mod.rs +38 -0
- pyyus-0.4.1/crates/runtime/src/wasi_runtime/p1.rs +465 -0
- pyyus-0.4.1/crates/runtime/src/wasi_runtime/p2.rs +1266 -0
- pyyus-0.4.1/crates/runtime/src/wasi_runtime/prelude.rs +9 -0
- pyyus-0.4.1/crates/runtime/src/wasi_runtime/utils.rs +123 -0
- pyyus-0.4.1/crates/utils/Cargo.toml +22 -0
- pyyus-0.4.1/crates/utils/src/lib.rs +4 -0
- pyyus-0.4.1/crates/utils/src/loginit.rs +174 -0
- pyyus-0.4.1/crates/utils/src/token.rs +9 -0
- pyyus-0.4.1/demo.py +178 -0
- pyyus-0.4.1/docs/cli/pyyus-session.md +142 -0
- pyyus-0.4.1/docs/cli/pyyus-tools.md +184 -0
- pyyus-0.4.1/docs/cli/pyyus.md +73 -0
- pyyus-0.4.1/docs/lock-report.md +402 -0
- pyyus-0.4.1/docs/paged-reader.md +45 -0
- pyyus-0.4.1/docs/prompt/base-hello.md +4 -0
- pyyus-0.4.1/docs/prompt/blob-storage-prompt.md +24 -0
- pyyus-0.4.1/docs/prompt/cli-prompt.md +23 -0
- pyyus-0.4.1/docs/prompt/cli-publish.md +5 -0
- pyyus-0.4.1/docs/prompt/context-structed.md +139 -0
- pyyus-0.4.1/docs/prompt/genapp-prompt.md +12 -0
- pyyus-0.4.1/docs/prompt/new-slqx-port.md +19 -0
- pyyus-0.4.1/docs/prompt/notes-app-prompt.md +38 -0
- pyyus-0.4.1/docs/prompt/package-app.md +47 -0
- pyyus-0.4.1/docs/prompt/pyyus-session.md +27 -0
- pyyus-0.4.1/docs/prompt/repeat-app.md +5 -0
- pyyus-0.4.1/docs/prompt/skill-entry.md +35 -0
- pyyus-0.4.1/docs/prompt/stream-prompt.md +79 -0
- pyyus-0.4.1/docs/prompt/top-prompt.md +59 -0
- pyyus-0.4.1/docs/prompt/top-tool-skill.md +25 -0
- pyyus-0.4.1/docs/prompt/utils-tools.md +53 -0
- pyyus-0.4.1/docs/pypackage/api-reference.md +712 -0
- pyyus-0.4.1/docs/pypackage/install.md +121 -0
- pyyus-0.4.1/docs/pypackage/quickstart.md +394 -0
- pyyus-0.4.1/docs/threads-report.md +649 -0
- pyyus-0.4.1/docs/wiki/sqlxdo2-implementation-plan.md +348 -0
- pyyus-0.4.1/docs/wiki/wasm-sql-deep-dive.md +940 -0
- pyyus-0.4.1/docs//345/205/250/345/261/200/351/205/215/347/275/256/346/226/207/344/273/266/347/244/272/344/276/213.md +23 -0
- pyyus-0.4.1/docs//345/217/214/345/220/221/346/265/201.md +22 -0
- pyyus-0.4.1/docs//346/240/207/345/207/206/346/265/201.md +15 -0
- pyyus-0.4.1/prompt.md +53 -0
- pyyus-0.4.1/pyproject.toml +42 -0
- pyyus-0.4.1/python/pyyus/__init__.py +106 -0
- pyyus-0.4.1/python/pyyus/_internal.pyi +869 -0
- pyyus-0.4.1/python/pyyus/api.py +355 -0
- pyyus-0.4.1/python/pyyus/py.typed +0 -0
- pyyus-0.4.1/run.sh +206 -0
- pyyus-0.4.1/skills/package-app/SKILL.md +296 -0
- pyyus-0.4.1/skills/package-app/references/entry-config.md +126 -0
- pyyus-0.4.1/skills/python-app/SKILL.md +208 -0
- pyyus-0.4.1/skills/python-app/references/cli-invocation.md +62 -0
- pyyus-0.4.1/skills/python-app/references/command-config.md +61 -0
- pyyus-0.4.1/skills/python-app/references/python-invocation.md +349 -0
- pyyus-0.4.1/skills/top-pyyus/SKILL.md +180 -0
- pyyus-0.4.1/skills/top-pyyus/references/config-reference.md +292 -0
- pyyus-0.4.1/skills/top-pyyus/references/pyyus-package.md +361 -0
- pyyus-0.4.1/skills/top-pyyus/references/yus-cli.md +71 -0
- pyyus-0.4.1/skills/top-pyyus/references/yus-session-cli.md +141 -0
- pyyus-0.4.1/skills/top-pyyus/references/yus-tools-cli.md +182 -0
- pyyus-0.4.1/skills/wasip1-app/SKILL.md +175 -0
- pyyus-0.4.1/skills/wasip1-app/references/cli-invocation.md +62 -0
- pyyus-0.4.1/skills/wasip1-app/references/python-invocation.md +349 -0
- pyyus-0.4.1/skills/wasip2-api/SKILL.md +330 -0
- pyyus-0.4.1/skills/wasip2-api/references/appcall.md +139 -0
- pyyus-0.4.1/skills/wasip2-api/references/appfile.md +43 -0
- pyyus-0.4.1/skills/wasip2-api/references/base.md +58 -0
- pyyus-0.4.1/skills/wasip2-api/references/blob.md +94 -0
- pyyus-0.4.1/skills/wasip2-api/references/cli-invocation.md +138 -0
- pyyus-0.4.1/skills/wasip2-api/references/components.md +251 -0
- pyyus-0.4.1/skills/wasip2-api/references/event.md +56 -0
- pyyus-0.4.1/skills/wasip2-api/references/http.md +158 -0
- pyyus-0.4.1/skills/wasip2-api/references/process.md +142 -0
- pyyus-0.4.1/skills/wasip2-api/references/python-invocation.md +349 -0
- pyyus-0.4.1/skills/wasip2-api/references/redis.md +121 -0
- pyyus-0.4.1/skills/wasip2-api/references/sqlx.md +87 -0
- pyyus-0.4.1/skills/wasip2-app/SKILL.md +211 -0
- pyyus-0.4.1/skills/wasip2-app/references/appcall.md +139 -0
- pyyus-0.4.1/skills/wasip2-app/references/appfile.md +43 -0
- pyyus-0.4.1/skills/wasip2-app/references/base.md +58 -0
- pyyus-0.4.1/skills/wasip2-app/references/blob.md +94 -0
- pyyus-0.4.1/skills/wasip2-app/references/cli-invocation.md +62 -0
- pyyus-0.4.1/skills/wasip2-app/references/event.md +56 -0
- pyyus-0.4.1/skills/wasip2-app/references/http.md +158 -0
- pyyus-0.4.1/skills/wasip2-app/references/process.md +142 -0
- pyyus-0.4.1/skills/wasip2-app/references/python-invocation.md +349 -0
- pyyus-0.4.1/skills/wasip2-app/references/redis.md +121 -0
- pyyus-0.4.1/skills/wasip2-app/references/sqlx.md +87 -0
- pyyus-0.4.1/src/config.rs +444 -0
- pyyus-0.4.1/src/error.rs +68 -0
- pyyus-0.4.1/src/io.rs +2132 -0
- pyyus-0.4.1/src/lib.rs +80 -0
- pyyus-0.4.1/src/runtime.rs +1710 -0
- pyyus-0.4.1/src/types.rs +1091 -0
- pyyus-0.4.1/tests/conftest.py +35 -0
- pyyus-0.4.1/tests/test_api.py +248 -0
- pyyus-0.4.1/tests/test_app.py +434 -0
- pyyus-0.4.1/tests/test_combined_streams.py +348 -0
- pyyus-0.4.1/tests/test_lines_readers.py +560 -0
- pyyus-0.4.1/tests/test_session.py +298 -0
- pyyus-0.4.1/tests/test_skill.py +231 -0
- pyyus-0.4.1/tests/test_types.py +407 -0
- pyyus-0.4.1/tests/test_wasm.rs +165 -0
- pyyus-0.4.1/tools/cli-publish.sh +119 -0
- pyyus-0.4.1/tools/oneclick-install.sh +219 -0
- pyyus-0.4.1/uv.lock +959 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: CLI Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-22.04
|
|
14
|
+
name: Build on ubuntu
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Build & Publish
|
|
20
|
+
env:
|
|
21
|
+
WEB_DAV_URL: ${{ secrets.WEB_DAV_URL }}
|
|
22
|
+
WEB_DAV_AUTH: ${{ secrets.WEB_DAV_AUTH }}
|
|
23
|
+
run: bash tools/cli-publish.sh
|
pyyus-0.4.1/.gitignore
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/target
|
|
2
|
+
# /.qoder
|
|
3
|
+
/.qoder/skills
|
|
4
|
+
/.openclaude
|
|
5
|
+
/.opencode
|
|
6
|
+
/arms_cache
|
|
7
|
+
**/target/
|
|
8
|
+
**/*.rs.bk
|
|
9
|
+
Cargo.lock
|
|
10
|
+
__pycache__/
|
|
11
|
+
*.py[cod]
|
|
12
|
+
*$py.class
|
|
13
|
+
*.so
|
|
14
|
+
*.zip
|
|
15
|
+
.Python
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
downloads/
|
|
20
|
+
eggs/
|
|
21
|
+
.eggs/
|
|
22
|
+
lib/
|
|
23
|
+
lib64/
|
|
24
|
+
parts/
|
|
25
|
+
sdist/
|
|
26
|
+
var/
|
|
27
|
+
wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
.pytest_cache/
|
|
32
|
+
.mypy_cache/
|
|
33
|
+
.dmypy.json
|
|
34
|
+
dmypy.json
|
|
35
|
+
*.prof
|
|
36
|
+
.python-version
|
|
37
|
+
.venv/
|
|
38
|
+
venv/
|
|
39
|
+
python/pyyus/libpyyus.dylib.dSYM
|
|
40
|
+
ENV/
|
|
41
|
+
env/
|
|
42
|
+
.idea/
|
|
43
|
+
.vscode/
|
|
44
|
+
*.swp
|
|
45
|
+
*.swo
|
|
46
|
+
*.wasm
|
|
47
|
+
*~
|
|
48
|
+
.DS_Store
|
|
49
|
+
Thumbs.db
|
|
50
|
+
MANIFEST
|
pyyus-0.4.1/.qoder/repowiki/zh/content/API /345/217/202/350/200/203/API /345/217/202/350/200/203.md"
ADDED
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
# API 参考
|
|
2
|
+
|
|
3
|
+
<cite>
|
|
4
|
+
**本文引用的文件**
|
|
5
|
+
- [src/lib.rs](file://src/lib.rs)
|
|
6
|
+
- [python/pyyus/__init__.py](file://python/pyyus/__init__.py)
|
|
7
|
+
- [src/config.rs](file://src/config.rs)
|
|
8
|
+
- [src/runtime.rs](file://src/runtime.rs)
|
|
9
|
+
- [src/io.rs](file://src/io.rs)
|
|
10
|
+
- [src/types.rs](file://src/types.rs)
|
|
11
|
+
- [src/error.rs](file://src/error.rs)
|
|
12
|
+
- [crates/config/src/lib.rs](file://crates/config/src/lib.rs)
|
|
13
|
+
- [crates/config/src/config.rs](file://crates/config/src/config.rs)
|
|
14
|
+
- [crates/runtime/src/lib.rs](file://crates/runtime/src/lib.rs)
|
|
15
|
+
- [crates/runtime/src/prelude.rs](file://crates/runtime/src/prelude.rs)
|
|
16
|
+
- [crates/runtime/src/stream/mod.rs](file://crates/runtime/src/stream/mod.rs)
|
|
17
|
+
- [crates/runtime/src/pipe/mod.rs](file://crates/runtime/src/pipe/mod.rs)
|
|
18
|
+
- [python/pyyus/api.py](file://python/pyyus/api.py)
|
|
19
|
+
- [tests/test_highlevel.py](file://tests/test_highlevel.py)
|
|
20
|
+
- [tests/test_session.py](file://tests/test_session.py)
|
|
21
|
+
- [Cargo.toml](file://Cargo.toml)
|
|
22
|
+
</cite>
|
|
23
|
+
|
|
24
|
+
## 目录
|
|
25
|
+
1. [简介](#简介)
|
|
26
|
+
2. [项目结构](#项目结构)
|
|
27
|
+
3. [核心组件](#核心组件)
|
|
28
|
+
4. [架构总览](#架构总览)
|
|
29
|
+
5. [详细组件分析](#详细组件分析)
|
|
30
|
+
6. [依赖分析](#依赖分析)
|
|
31
|
+
7. [性能考虑](#性能考虑)
|
|
32
|
+
8. [故障排查指南](#故障排查指南)
|
|
33
|
+
9. [结论](#结论)
|
|
34
|
+
10. [附录](#附录)
|
|
35
|
+
|
|
36
|
+
## 简介
|
|
37
|
+
本参考文档面向 Python 开发者与系统集成工程师,系统化梳理 Pyyus2 的 Python 绑定 API,覆盖以下核心能力:
|
|
38
|
+
- 初始化与配置:init、AppConfig、RuntimeConfig、WasmConfig
|
|
39
|
+
- 配置构建器模式:AppConfig::build、RuntimeConfig::snap、RuntimeConfigSnap::app、RuntimeConfigSnap::session
|
|
40
|
+
- 应用执行:App.run、App.run_stream、App.run_async、App.run_stream_async
|
|
41
|
+
- 流式 I/O:PagedReader、PagedWriter、pipe
|
|
42
|
+
- 会话式调用:Session(状态保持的 P2 函数调用)
|
|
43
|
+
- 结果模型:RunResult、FunctionResult、ResultTypes、WasmActionType
|
|
44
|
+
- 高级工具:run_wasm、run_wasm_stream
|
|
45
|
+
- 运行时缓存:clear_runtime_cache、runtime_cache_size、precompile_wasm
|
|
46
|
+
- 错误模型:统一的 PyyusError 映射到 Python 异常
|
|
47
|
+
|
|
48
|
+
本文件提供方法签名、参数说明、返回值类型、使用示例、最佳实践与常见问题处理,并解释 API 之间的关系与调用顺序。
|
|
49
|
+
|
|
50
|
+
## 项目结构
|
|
51
|
+
- Python 包导出层位于 python/pyyus/__init__.py,提供 run_wasm、run_wasm_stream 等高层封装。
|
|
52
|
+
- Rust 绑定层位于 src/,通过 pyo3 暴露类与函数;核心逻辑委托至 crates/runtime 与 crates/config。
|
|
53
|
+
- crates/runtime 提供 WASM 运行时、流式事件、会话管理等能力。
|
|
54
|
+
- crates/config 提供包级配置初始化与默认路径解析。
|
|
55
|
+
|
|
56
|
+
```mermaid
|
|
57
|
+
graph TB
|
|
58
|
+
subgraph "Python 层"
|
|
59
|
+
PYAPI["python/pyyus/__init__.py<br/>run_wasm / run_wasm_stream"]
|
|
60
|
+
APIPY["python/pyyus/api.py<br/>高级API封装"]
|
|
61
|
+
end
|
|
62
|
+
subgraph "Rust 绑定层"
|
|
63
|
+
LIBRS["src/lib.rs<br/>模块导出"]
|
|
64
|
+
CONFIGRS["src/config.rs<br/>配置类与构建器"]
|
|
65
|
+
RUNTIMERS["src/runtime.rs<br/>App/Session/StreamingResult"]
|
|
66
|
+
IORS["src/io.rs<br/>PagedReader/PagedWriter/pipe"]
|
|
67
|
+
TYPESRS["src/types.rs<br/>RunResult/FunctionResult/ResultTypes/WasmActionType"]
|
|
68
|
+
ERRORSRS["src/error.rs<br/>PyyusError"]
|
|
69
|
+
end
|
|
70
|
+
subgraph "Rust 运行时库"
|
|
71
|
+
RTLIB["crates/runtime/src/lib.rs"]
|
|
72
|
+
RTPRELUDE["crates/runtime/src/prelude.rs"]
|
|
73
|
+
RTSTREAM["crates/runtime/src/stream/mod.rs"]
|
|
74
|
+
RTPipe["crates/runtime/src/pipe/mod.rs"]
|
|
75
|
+
end
|
|
76
|
+
subgraph "Rust 配置库"
|
|
77
|
+
CFG_LIB["crates/config/src/lib.rs"]
|
|
78
|
+
CFG_RS["crates/config/src/config.rs"]
|
|
79
|
+
end
|
|
80
|
+
PYAPI --> LIBRS
|
|
81
|
+
LIBRS --> CONFIGRS
|
|
82
|
+
LIBRS --> RUNTIMERS
|
|
83
|
+
LIBRS --> IORS
|
|
84
|
+
LIBRS --> TYPESRS
|
|
85
|
+
LIBRS --> ERRORSRS
|
|
86
|
+
RUNTIMERS --> RTLIB
|
|
87
|
+
RTLIB --> RTPRELUDE
|
|
88
|
+
RTPRELUDE --> RTSTREAM
|
|
89
|
+
RTPRELUDE --> RTPipe
|
|
90
|
+
CONFIGRS --> CFG_LIB
|
|
91
|
+
CFG_LIB --> CFG_RS
|
|
92
|
+
APIPY --> CONFIGRS
|
|
93
|
+
APIPY --> RUNTIMERS
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**图表来源**
|
|
97
|
+
- [src/lib.rs:1-61](file://src/lib.rs#L1-L61)
|
|
98
|
+
- [python/pyyus/__init__.py:1-128](file://python/pyyus/__init__.py#L1-L128)
|
|
99
|
+
- [python/pyyus/api.py:1-749](file://python/pyyus/api.py#L1-L749)
|
|
100
|
+
- [crates/runtime/src/lib.rs:1-24](file://crates/runtime/src/lib.rs#L1-L24)
|
|
101
|
+
- [crates/runtime/src/prelude.rs:1-5](file://crates/runtime/src/prelude.rs#L1-L5)
|
|
102
|
+
- [crates/runtime/src/stream/mod.rs:1-10](file://crates/runtime/src/stream/mod.rs#L1-L10)
|
|
103
|
+
- [crates/runtime/src/pipe/mod.rs:1-83](file://crates/runtime/src/pipe/mod.rs#L1-L83)
|
|
104
|
+
- [crates/config/src/lib.rs:1-21](file://crates/config/src/lib.rs#L1-L21)
|
|
105
|
+
- [crates/config/src/config.rs:1-419](file://crates/config/src/config.rs#L1-L419)
|
|
106
|
+
|
|
107
|
+
**章节来源**
|
|
108
|
+
- [src/lib.rs:1-61](file://src/lib.rs#L1-L61)
|
|
109
|
+
- [python/pyyus/__init__.py:1-128](file://python/pyyus/__init__.py#L1-L128)
|
|
110
|
+
- [crates/runtime/src/lib.rs:1-24](file://crates/runtime/src/lib.rs#L1-L24)
|
|
111
|
+
- [crates/config/src/lib.rs:1-21](file://crates/config/src/lib.rs#L1-L21)
|
|
112
|
+
|
|
113
|
+
## 核心组件
|
|
114
|
+
- 初始化与配置
|
|
115
|
+
- init(workdir: Optional[str], log_level: Optional[str]) -> None
|
|
116
|
+
- AppConfig(path: str) / from_toml(path: str) / from_zip(path: str) -> AppConfig
|
|
117
|
+
- RuntimeConfig(path: str) / from_toml(path: str) / from_zip(path: str) / from_app_config(AppConfig) -> RuntimeConfig
|
|
118
|
+
- WasmConfig(path: str, name: Optional[str] = None) -> WasmConfig
|
|
119
|
+
- 配置构建器模式
|
|
120
|
+
- AppConfig::build(rename: Optional[str] = None) -> RuntimeConfig
|
|
121
|
+
- RuntimeConfig::snap(action: str = "*", args: Optional[List] = None, kwargs: Optional[Dict] = None) -> RuntimeConfigSnap
|
|
122
|
+
- RuntimeConfigSnap::app() -> App
|
|
123
|
+
- RuntimeConfigSnap::session(ttl: int = 900, index: Optional[str] = None, force: bool = False) -> Session
|
|
124
|
+
- 应用执行
|
|
125
|
+
- App(RuntimeConfig) -> App
|
|
126
|
+
- App.run(action: str = "*", args: List[str] = [], stdin: Optional[bytes] = None) -> RunResult
|
|
127
|
+
- App.run_stream(action: str = "*", args: List[str] = [], stdin: Optional[bytes] = None, max_chars: int = 4096, max_lines: int = 50) -> StreamingResult
|
|
128
|
+
- App.run_async(...) -> Awaitable[RunResult]
|
|
129
|
+
- App.run_stream_async(...) -> Awaitable[StreamingResult]
|
|
130
|
+
- 流式 I/O
|
|
131
|
+
- PagedWriter -> write(data: bytes), close()
|
|
132
|
+
- PagedReader -> read_all(), read_all_text(), read_page() -> Optional[str], goto_page(n), content_length, chars, lines, is_closed
|
|
133
|
+
- pipe(max_chars: int = 4096, max_lines: int = 50) -> (PagedWriter, PagedReader)
|
|
134
|
+
- 会话式调用
|
|
135
|
+
- Session(RuntimeConfig) -> Session
|
|
136
|
+
- Session.call(func_name: str, params: Optional[str] = None, data: Optional[bytes] = None) -> FunctionResult
|
|
137
|
+
- Session.call_async(...)
|
|
138
|
+
- Session.close(), session_id, is_active
|
|
139
|
+
- 结果模型
|
|
140
|
+
- RunResult(success: bool, exit_code: Optional[int], error_message: Optional[str], stdout: Optional[bytes], stderr: Optional[bytes])
|
|
141
|
+
- FunctionResult(success: bool, data: Optional[ResultTypes], error: Optional[str])
|
|
142
|
+
- ResultTypes(string_val: Optional[str], bytes_val: Optional[bytes], json_val: Optional[json])
|
|
143
|
+
- WasmActionType 枚举(bin/lib/stream/stream_ext/sse/sse_ext/upstream)
|
|
144
|
+
- 高级工具
|
|
145
|
+
- run_wasm(wasm_path, action="*", args=None, stdin=None, workdir=None, log_level=None) -> RunResult
|
|
146
|
+
- run_wasm_stream(wasm_path, action="*", args=None, stdin=None, max_chars=4096, max_lines=50, workdir=None, log_level=None) -> StreamingResult
|
|
147
|
+
- 运行时缓存
|
|
148
|
+
- precompile_wasm(path: str) -> bytes
|
|
149
|
+
- clear_runtime_cache() -> None
|
|
150
|
+
- runtime_cache_size() -> int
|
|
151
|
+
|
|
152
|
+
**章节来源**
|
|
153
|
+
- [src/config.rs:1-257](file://src/config.rs#L1-L257)
|
|
154
|
+
- [src/runtime.rs:1-600](file://src/runtime.rs#L1-L600)
|
|
155
|
+
- [src/io.rs:1-252](file://src/io.rs#L1-L252)
|
|
156
|
+
- [src/types.rs:1-827](file://src/types.rs#L1-L827)
|
|
157
|
+
- [python/pyyus/__init__.py:52-128](file://python/pyyus/__init__.py#L52-L128)
|
|
158
|
+
- [python/pyyus/api.py:514-749](file://python/pyyus/api.py#L514-L749)
|
|
159
|
+
|
|
160
|
+
## 架构总览
|
|
161
|
+
下图展示 Python 高层 API 与底层 Rust 实现的交互关系,以及 App.run_stream 的异步流式输出路径。
|
|
162
|
+
|
|
163
|
+
```mermaid
|
|
164
|
+
sequenceDiagram
|
|
165
|
+
participant Py as "Python 调用方"
|
|
166
|
+
participant API as "run_wasm/run_wasm_stream"
|
|
167
|
+
participant Bind as "Rust 绑定层"
|
|
168
|
+
participant App as "App"
|
|
169
|
+
participant RT as "Tokio 运行时"
|
|
170
|
+
participant Stream as "AppStreamAll/事件流"
|
|
171
|
+
participant Reader as "PagedReader"
|
|
172
|
+
participant Writer as "PagedWriter"
|
|
173
|
+
Py->>API : 调用 run_wasm / run_wasm_stream
|
|
174
|
+
API->>Bind : init(workdir, log_level)
|
|
175
|
+
API->>Bind : 构造 RuntimeConfig / App
|
|
176
|
+
API->>App : 调用 run / run_stream
|
|
177
|
+
App->>RT : block_on(run_app_* 或 spawn(run_app_streaming))
|
|
178
|
+
RT->>Stream : new_bytes_stdin(config, stdin)
|
|
179
|
+
alt 同步模式
|
|
180
|
+
Stream-->>App : 收集 stdout/stderr
|
|
181
|
+
App-->>API : 返回 RunResult
|
|
182
|
+
else 流式模式
|
|
183
|
+
App->>Writer : 写入 stdout/stderr 分页缓冲
|
|
184
|
+
Py->>Reader : read_page()/read_all()
|
|
185
|
+
Reader-->>Py : 返回页面文本
|
|
186
|
+
App-->>API : 返回 StreamingResult可等待最终 RunResult
|
|
187
|
+
end
|
|
188
|
+
API-->>Py : 返回结果
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**图表来源**
|
|
192
|
+
- [python/pyyus/__init__.py:52-128](file://python/pyyus/__init__.py#L52-L128)
|
|
193
|
+
- [python/pyyus/api.py:514-749](file://python/pyyus/api.py#L514-L749)
|
|
194
|
+
- [src/runtime.rs:357-408](file://src/runtime.rs#L357-L408)
|
|
195
|
+
- [src/runtime.rs:410-476](file://src/runtime.rs#L410-L476)
|
|
196
|
+
- [src/io.rs:69-242](file://src/io.rs#L69-L242)
|
|
197
|
+
|
|
198
|
+
## 详细组件分析
|
|
199
|
+
|
|
200
|
+
### 初始化与配置 API
|
|
201
|
+
- init(workdir: Optional[str], log_level: Optional[str]) -> None
|
|
202
|
+
- 作用:初始化日志级别与包级配置(工作目录、应用目录、存储目录等)。
|
|
203
|
+
- 注意:首次使用需先调用 init。
|
|
204
|
+
- AppConfig
|
|
205
|
+
- 构造:from_wasm_path(path: str) 或 from_toml(path: str) 或 from_zip(path: str)
|
|
206
|
+
- 方法:add_env(key: str, value: str), add_mount(host_dir: str, guest_dir: str)
|
|
207
|
+
- 属性:domain() -> str
|
|
208
|
+
- **新增**:build(rename: Optional[str] = None) -> RuntimeConfig
|
|
209
|
+
- 作用:将 AppConfig 转换为 RuntimeConfig,支持重命名应用域
|
|
210
|
+
- 参数:rename - 可选的新应用域名
|
|
211
|
+
- RuntimeConfig
|
|
212
|
+
- 构造:from_wasm_path(path: str) 或 from_toml(path: str) 或 from_zip(path: str) 或 from_app_config(AppConfig)
|
|
213
|
+
- 方法:add_env(key: str, value: str), set_host_workdir(path: str)
|
|
214
|
+
- 属性:domain() -> str
|
|
215
|
+
- **新增**:snap(action: str = "*", args: Optional[List] = None, kwargs: Optional[Dict] = None) -> RuntimeConfigSnap
|
|
216
|
+
- 作用:创建特定动作、参数组合的配置快照
|
|
217
|
+
- 参数:action - 动作名称,默认"*";args - 位置参数列表;kwargs - 关键字参数字典
|
|
218
|
+
- WasmConfig
|
|
219
|
+
- 构造:new(path: str, name: Optional[str] = None)
|
|
220
|
+
- 属性:name() -> str, path() -> str
|
|
221
|
+
|
|
222
|
+
最佳实践
|
|
223
|
+
- 在脚本开头调用 init,确保日志与工作目录已就绪。
|
|
224
|
+
- 使用 from_toml/from_zip 管理复杂应用配置;仅单文件场景可用 from_wasm_path。
|
|
225
|
+
- 通过 add_env/add_mount 注入环境变量与挂载点,避免硬编码路径。
|
|
226
|
+
- **新增**:使用 AppConfig::build 和 RuntimeConfig::snap 实现配置构建器模式,提高代码可读性和类型安全性。
|
|
227
|
+
|
|
228
|
+
**章节来源**
|
|
229
|
+
- [src/config.rs:14-257](file://src/config.rs#L14-L257)
|
|
230
|
+
- [crates/config/src/config.rs:82-214](file://crates/config/src/config.rs#L82-L214)
|
|
231
|
+
- [crates/config/src/config.rs:310-410](file://crates/config/src/config.rs#L310-L410)
|
|
232
|
+
|
|
233
|
+
### 配置构建器模式 API
|
|
234
|
+
- AppConfig::build(rename: Optional[str] = None) -> RuntimeConfig
|
|
235
|
+
- 作用:将 AppConfig 转换为 RuntimeConfig,支持重命名应用域
|
|
236
|
+
- 参数:rename - 可选的新应用域名,用于覆盖原始配置中的域名
|
|
237
|
+
- 返回:新的 RuntimeConfig 实例
|
|
238
|
+
- RuntimeConfig::snap(action: str = "*", args: Optional[List] = None, kwargs: Optional[Dict] = None) -> RuntimeConfigSnap
|
|
239
|
+
- 作用:创建特定动作、参数组合的配置快照
|
|
240
|
+
- 参数:action - 动作名称,默认"*";args - 位置参数列表;kwargs - 关键字参数字典
|
|
241
|
+
- 返回:RuntimeConfigSnap 实例,可用于创建 App 或 Session
|
|
242
|
+
- RuntimeConfigSnap::app() -> App
|
|
243
|
+
- 作用:从配置快照创建 App 实例
|
|
244
|
+
- 返回:App 实例,直接用于执行 WASM 应用
|
|
245
|
+
- RuntimeConfigSnap::session(ttl: int = 900, index: Optional[str] = None, force: bool = False) -> Session
|
|
246
|
+
- 作用:从配置快照创建 Session 实例
|
|
247
|
+
- 参数:ttl - 会话生存时间(秒),0 表示永久;index - 会话索引;force - 是否强制覆盖现有会话
|
|
248
|
+
- 返回:Session 实例,用于状态保持的函数调用
|
|
249
|
+
|
|
250
|
+
使用示例
|
|
251
|
+
```python
|
|
252
|
+
# 使用构建器模式创建配置
|
|
253
|
+
app_cfg = pyyus.AppConfig.from_toml("config.toml").build("my-app")
|
|
254
|
+
runtime_cfg = pyyus.RuntimeConfig.from_toml("runtime.toml")
|
|
255
|
+
snap = runtime_cfg.snap("process", ["arg1"], {"key": "value"})
|
|
256
|
+
|
|
257
|
+
# 从快照创建 App 和 Session
|
|
258
|
+
app = snap.app()
|
|
259
|
+
session = snap.session(ttl=1800, index="worker-1")
|
|
260
|
+
|
|
261
|
+
# 直接使用快照执行
|
|
262
|
+
result = app.run()
|
|
263
|
+
session_result = session.call("process", ["arg1"], {"key": "value"})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**章节来源**
|
|
267
|
+
- [src/config.rs:107-256](file://src/config.rs#L107-L256)
|
|
268
|
+
|
|
269
|
+
### 应用执行 API(App)
|
|
270
|
+
- App(RuntimeConfig)
|
|
271
|
+
- 作用:承载 WASM 应用的生命周期与执行。
|
|
272
|
+
- App.run(action: str = "*", args: List[str] = [], stdin: Optional[bytes] = None) -> RunResult
|
|
273
|
+
- 作用:同步执行 WASM 应用,返回 RunResult(包含 stdout/stderr/退出码/错误信息)。
|
|
274
|
+
- App.run_stream(..., max_chars: int = 4096, max_lines: int = 50) -> StreamingResult
|
|
275
|
+
- 作用:启动异步流式执行,返回 StreamingResult,内部维护 stdout/stderr 的 PagedReader。
|
|
276
|
+
- App.run_async(...) -> Awaitable[RunResult]
|
|
277
|
+
- 作用:返回协程对象,可在事件循环中 await。
|
|
278
|
+
- App.run_stream_async(...) -> Awaitable[StreamingResult]
|
|
279
|
+
- 作用:返回协程对象,可在事件循环中 await。
|
|
280
|
+
|
|
281
|
+
调用顺序与注意事项
|
|
282
|
+
- 先 init,再构造 RuntimeConfig/AppConfig,再实例化 App。
|
|
283
|
+
- run_stream 会立即返回 StreamingResult,随后可通过 PagedReader 逐步读取输出。
|
|
284
|
+
- 若需等待最终结果,可使用 StreamingResult.wait/wait_async 或读取其 result 字段。
|
|
285
|
+
|
|
286
|
+
**章节来源**
|
|
287
|
+
- [src/runtime.rs:18-121](file://src/runtime.rs#L18-L121)
|
|
288
|
+
- [src/runtime.rs:357-408](file://src/runtime.rs#L357-L408)
|
|
289
|
+
- [src/runtime.rs:410-476](file://src/runtime.rs#L410-L476)
|
|
290
|
+
|
|
291
|
+
### 流式 I/O API(PagedReader/PagedWriter/pipe)
|
|
292
|
+
- PagedWriter
|
|
293
|
+
- new() -> (PagedWriter, UnboundedReceiver<Vec<u8>>)
|
|
294
|
+
- 方法:write(data: bytes), close()
|
|
295
|
+
- 用途:将 WASM 输出写入内部缓冲并通过通道发送给 PagedReader。
|
|
296
|
+
- PagedReader
|
|
297
|
+
- new(data: bytes, max_chars: int = 4096, max_lines: int = 50)
|
|
298
|
+
- 方法:read_all() -> bytes, read_all_text() -> str, read_page() -> Optional[str], goto_page(n) -> Optional[str]
|
|
299
|
+
- 属性:content_length, chars, lines, is_closed
|
|
300
|
+
- 用途:按页读取输出,支持字符数与行数限制。
|
|
301
|
+
- pipe(max_chars: int = 4096, max_lines: int = 50) -> (PagedWriter, PagedReader)
|
|
302
|
+
- 用途:便捷创建一对 writer-reader。
|
|
303
|
+
|
|
304
|
+
分页策略
|
|
305
|
+
- 优先按字符数(max_chars)截断;当超过行数上限(max_lines)时停止。
|
|
306
|
+
- 末尾换行保留,避免截断中间字符。
|
|
307
|
+
|
|
308
|
+
**章节来源**
|
|
309
|
+
- [src/io.rs:6-252](file://src/io.rs#L6-L252)
|
|
310
|
+
|
|
311
|
+
### 会话式调用 API(Session)
|
|
312
|
+
- Session(RuntimeConfig)
|
|
313
|
+
- 作用:建立长连接式的 WASM P2 会话,复用运行时状态。
|
|
314
|
+
- Session.call(func_name: str, params: Optional[str] = None, data: Optional[bytes] = None) -> FunctionResult
|
|
315
|
+
- 作用:同步调用 WASM 函数,返回 FunctionResult(包含成功标志、数据或错误)。
|
|
316
|
+
- Session.call_async(...)
|
|
317
|
+
- 作用:返回协程对象,可在事件循环中 await。
|
|
318
|
+
- Session.close() -> None
|
|
319
|
+
- 作用:关闭会话并释放资源。
|
|
320
|
+
- 属性:session_id -> str, is_active -> bool
|
|
321
|
+
- 上下文管理:with 语句自动关闭。
|
|
322
|
+
|
|
323
|
+
最佳实践
|
|
324
|
+
- 多次调用同一 Session 可减少启动成本。
|
|
325
|
+
- 使用 params 传递查询参数,data 传递二进制输入。
|
|
326
|
+
- 会话关闭后不可再次调用。
|
|
327
|
+
|
|
328
|
+
**章节来源**
|
|
329
|
+
- [src/runtime.rs:194-600](file://src/runtime.rs#L194-L600)
|
|
330
|
+
|
|
331
|
+
### 结果模型 API
|
|
332
|
+
- RunResult
|
|
333
|
+
- 字段:success, exit_code, error_message, stdout, stderr
|
|
334
|
+
- 方法:to_dict() -> Dict
|
|
335
|
+
- 行为:__bool__ 返回 success
|
|
336
|
+
- FunctionResult
|
|
337
|
+
- 字段:success, data: Optional[ResultTypes], error: Optional[str]
|
|
338
|
+
- 方法:to_json() -> Optional[str]
|
|
339
|
+
- ResultTypes
|
|
340
|
+
- 字段:string_val, bytes_val, json_val
|
|
341
|
+
- 方法:try_to_string/bytes/json -> Result
|
|
342
|
+
- WasmActionType
|
|
343
|
+
- 枚举:Bin, Lib, Stream, StreamExt, Sse, SseExt, UpStream
|
|
344
|
+
- 方法:is_binary(), need_pipe(), has_ext_data()
|
|
345
|
+
|
|
346
|
+
使用建议
|
|
347
|
+
- 优先使用 ResultTypes 的 try_to_* 方法进行类型安全转换。
|
|
348
|
+
- FunctionResult.data 为空时,检查 error 字段获取错误信息。
|
|
349
|
+
|
|
350
|
+
**章节来源**
|
|
351
|
+
- [src/types.rs:7-827](file://src/types.rs#L7-L827)
|
|
352
|
+
|
|
353
|
+
### 高级工具 API
|
|
354
|
+
- run_wasm(wasm_path: str, action: str = "*", args: Optional[List[str]] = None, stdin: Optional[bytes] = None, workdir: Optional[str] = None, log_level: Optional[str] = None) -> RunResult
|
|
355
|
+
- 作用:一次性运行 WASM 并返回完整结果。
|
|
356
|
+
- run_wasm_stream(wasm_path: str, action: str = "*", args: Optional[List[str]] = None, stdin: Optional[bytes] = None, max_chars: int = 4096, max_lines: int = 50, workdir: Optional[str] = None, log_level: Optional[str] = None) -> StreamingResult
|
|
357
|
+
- 作用:流式读取输出,适合长输出或实时日志。
|
|
358
|
+
|
|
359
|
+
使用示例(路径)
|
|
360
|
+
- run_wasm 示例:[python/pyyus/__init__.py:52-128](file://python/pyyus/__init__.py#L52-L128)
|
|
361
|
+
- run_wasm_stream 示例:[python/pyyus/api.py:514-749](file://python/pyyus/api.py#L514-L749)
|
|
362
|
+
|
|
363
|
+
**章节来源**
|
|
364
|
+
- [python/pyyus/__init__.py:52-128](file://python/pyyus/__init__.py#L52-L128)
|
|
365
|
+
- [python/pyyus/api.py:514-749](file://python/pyyus/api.py#L514-L749)
|
|
366
|
+
|
|
367
|
+
### 运行时缓存与预编译
|
|
368
|
+
- precompile_wasm(path: str) -> bytes
|
|
369
|
+
- 作用:对 WASM 文件进行预编译,返回字节码以便加速后续启动。
|
|
370
|
+
- clear_runtime_cache() -> None
|
|
371
|
+
- 作用:清空运行时配置缓存。
|
|
372
|
+
- runtime_cache_size() -> int
|
|
373
|
+
- 作用:返回当前缓存条目数量。
|
|
374
|
+
|
|
375
|
+
最佳实践
|
|
376
|
+
- 在部署阶段对常用 WASM 文件调用 precompile_wasm,保存产物并在运行时加载。
|
|
377
|
+
- 定期调用 clear_runtime_cache 释放内存占用。
|
|
378
|
+
|
|
379
|
+
**章节来源**
|
|
380
|
+
- [src/runtime.rs:327-353](file://src/runtime.rs#L327-L353)
|
|
381
|
+
|
|
382
|
+
## 依赖分析
|
|
383
|
+
- Python 层依赖
|
|
384
|
+
- pyo3(0.28,启用 abi3-py39 与 tokio 运行时)
|
|
385
|
+
- tokio(full 特性)、tokio-stream、tokio-util、futures、bytes
|
|
386
|
+
- reqwest(带 rustls-native-roots、blocking、stream)
|
|
387
|
+
- serde/serde_json、anyhow、log/env_logger、clap、cfg-if、parking_lot、thiserror
|
|
388
|
+
- Rust 工作区
|
|
389
|
+
- yus-config、yus-runtime、yus-utils 作为成员 crate
|
|
390
|
+
- 通过 features 控制组件开关(如 components、com-http/com-redis/com-pg/com-blob)
|
|
391
|
+
|
|
392
|
+
```mermaid
|
|
393
|
+
graph TB
|
|
394
|
+
PY["pyproject.toml / Cargo.toml 依赖声明"]
|
|
395
|
+
PYO3["pyo3 0.28"]
|
|
396
|
+
TOKIO["tokio / tokio-stream / tokio-util / futures / bytes"]
|
|
397
|
+
REQ["reqwest"]
|
|
398
|
+
SERDE["serde / serde_json"]
|
|
399
|
+
ANY["anyhow / log / env_logger / clap / cfg-if / parking_lot / thiserror"]
|
|
400
|
+
PY --> PYO3
|
|
401
|
+
PY --> TOKIO
|
|
402
|
+
PY --> REQ
|
|
403
|
+
PY --> SERDE
|
|
404
|
+
PY --> ANY
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**图表来源**
|
|
408
|
+
- [Cargo.toml:63-85](file://Cargo.toml#L63-L85)
|
|
409
|
+
- [Cargo.toml:31-55](file://Cargo.toml#L31-L55)
|
|
410
|
+
|
|
411
|
+
**章节来源**
|
|
412
|
+
- [Cargo.toml:1-106](file://Cargo.toml#L1-L106)
|
|
413
|
+
|
|
414
|
+
## 性能考虑
|
|
415
|
+
- 预编译:对热点 WASM 文件调用 precompile_wasm,显著降低启动延迟。
|
|
416
|
+
- 流式 I/O:run_stream 配合 PagedReader 分页读取,避免一次性加载大输出导致内存峰值。
|
|
417
|
+
- 会话复用:Session 复用运行时状态,减少重复初始化成本。
|
|
418
|
+
- 缓存管理:定期清理 runtime_cache,避免长期运行内存膨胀。
|
|
419
|
+
- 日志级别:合理设置 log_level,生产环境建议 info 或更高。
|
|
420
|
+
- **新增**:配置构建器模式减少了重复配置创建的成本,提高了代码执行效率。
|
|
421
|
+
|
|
422
|
+
## 故障排查指南
|
|
423
|
+
常见错误与处理
|
|
424
|
+
- 未初始化:调用 Pyyus API 前必须先 init。若出现"未初始化"错误,请先调用 init。
|
|
425
|
+
- 配置错误:from_toml/from_zip 失败多因路径不存在或格式不正确。检查路径与 TOML/ZIP 格式。
|
|
426
|
+
- 运行时错误:App.run/run_stream 抛出 RuntimeError,查看 RunResult.error_message 或 FunctionResult.error 获取详细信息。
|
|
427
|
+
- 流关闭:PagedReader 在通道断开后标记为 closed,继续读取将返回 None。请在 is_closed 为真时停止读取。
|
|
428
|
+
- 参数类型:ResultTypes 的 try_to_* 转换失败通常表示数据类型与期望不符,检查上游输出类型。
|
|
429
|
+
- **新增**:配置构建器模式错误:确保在调用 build() 之前正确设置 AppConfig,在调用 snap() 之前正确设置 RuntimeConfig。
|
|
430
|
+
|
|
431
|
+
异常映射
|
|
432
|
+
- PyyusError -> PyErr:根据错误类型映射为 PyIOError、PyRuntimeError、PyValueError、PyTypeError、PyEOFError 等。
|
|
433
|
+
|
|
434
|
+
**章节来源**
|
|
435
|
+
- [src/error.rs:4-69](file://src/error.rs#L4-L69)
|
|
436
|
+
- [src/io.rs:180-214](file://src/io.rs#L180-L214)
|
|
437
|
+
|
|
438
|
+
## 结论
|
|
439
|
+
Pyyus2 提供了从 Python 侧直接运行与流式消费 WASM 应用的能力,配合会话式调用与预编译优化,适用于高并发与低延迟场景。新增的配置构建器模式进一步提升了 API 的易用性和类型安全性。建议在生产环境中结合预编译、缓存清理与合理的日志级别,获得稳定且高性能的运行体验。
|
|
440
|
+
|
|
441
|
+
## 附录
|
|
442
|
+
|
|
443
|
+
### API 关系与调用顺序图
|
|
444
|
+
```mermaid
|
|
445
|
+
flowchart TD
|
|
446
|
+
Start(["开始"]) --> Init["调用 init(workdir, log_level)"]
|
|
447
|
+
Init --> Cfg["构建 RuntimeConfig/AppConfig/WasmConfig"]
|
|
448
|
+
Cfg --> Builder{"使用构建器模式?"}
|
|
449
|
+
Builder --> |是| Build["AppConfig.build() / RuntimeConfig.snap()"]
|
|
450
|
+
Builder --> |否| AppNew["实例化 App / Session"]
|
|
451
|
+
Build --> Snap["RuntimeConfigSnap"]
|
|
452
|
+
Snap --> AppNew["App/RuntimeConfigSnap.app()"]
|
|
453
|
+
AppNew --> Mode{"选择模式"}
|
|
454
|
+
Mode --> |同步| Run["App.run(...) -> RunResult"]
|
|
455
|
+
Mode --> |流式| RunStream["App.run_stream(...) -> StreamingResult"]
|
|
456
|
+
Mode --> |会话| SessionCall["Session.call(...) -> FunctionResult"]
|
|
457
|
+
RunStream --> Read["PagedReader.read_page()/read_all()"]
|
|
458
|
+
SessionCall --> End(["结束"])
|
|
459
|
+
Run --> End
|
|
460
|
+
Read --> End
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
**图表来源**
|
|
464
|
+
- [python/pyyus/__init__.py:52-128](file://python/pyyus/__init__.py#L52-L128)
|
|
465
|
+
- [python/pyyus/api.py:514-749](file://python/pyyus/api.py#L514-L749)
|
|
466
|
+
- [src/config.rs:107-256](file://src/config.rs#L107-L256)
|
|
467
|
+
- [src/runtime.rs:18-121](file://src/runtime.rs#L18-L121)
|
|
468
|
+
- [src/io.rs:69-242](file://src/io.rs#L69-L242)
|
|
469
|
+
|
|
470
|
+
### 数据模型类图
|
|
471
|
+
```mermaid
|
|
472
|
+
classDiagram
|
|
473
|
+
class RunResult {
|
|
474
|
+
+bool success
|
|
475
|
+
+int exit_code
|
|
476
|
+
+string error_message
|
|
477
|
+
+bytes stdout
|
|
478
|
+
+bytes stderr
|
|
479
|
+
+to_dict() Dict
|
|
480
|
+
}
|
|
481
|
+
class FunctionResult {
|
|
482
|
+
+bool success
|
|
483
|
+
+ResultTypes data
|
|
484
|
+
+string error
|
|
485
|
+
+to_json() string
|
|
486
|
+
}
|
|
487
|
+
class ResultTypes {
|
|
488
|
+
+string string_val
|
|
489
|
+
+bytes bytes_val
|
|
490
|
+
+json json_val
|
|
491
|
+
+try_to_string() Result<string>
|
|
492
|
+
+try_to_bytes() Result<bytes>
|
|
493
|
+
+try_to_json() Result<json>
|
|
494
|
+
}
|
|
495
|
+
class WasmActionType {
|
|
496
|
+
+Bin
|
|
497
|
+
+Lib
|
|
498
|
+
+Stream
|
|
499
|
+
+StreamExt
|
|
500
|
+
+Sse
|
|
501
|
+
+SseExt
|
|
502
|
+
+UpStream
|
|
503
|
+
+is_binary() bool
|
|
504
|
+
+need_pipe() bool
|
|
505
|
+
+has_ext_data() bool
|
|
506
|
+
}
|
|
507
|
+
FunctionResult --> ResultTypes : "包含"
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**图表来源**
|
|
511
|
+
- [src/types.rs:7-827](file://src/types.rs#L7-L827)
|
|
512
|
+
|
|
513
|
+
### 配置构建器模式使用示例
|
|
514
|
+
```python
|
|
515
|
+
# 方式1:传统方式
|
|
516
|
+
app_cfg = pyyus.AppConfig.from_toml("config.toml")
|
|
517
|
+
runtime_cfg = app_cfg.build("renamed-app")
|
|
518
|
+
snap = runtime_cfg.snap("process", ["arg1"], {"key": "value"})
|
|
519
|
+
app = snap.app()
|
|
520
|
+
|
|
521
|
+
# 方式2:链式构建器
|
|
522
|
+
app_cfg = pyyus.AppConfig.from_toml("config.toml").build("renamed-app")
|
|
523
|
+
snap = app_cfg.snap("process", ["arg1"], {"key": "value"})
|
|
524
|
+
session = snap.session(ttl=1800, index="worker-1")
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
**章节来源**
|
|
528
|
+
- [src/config.rs:107-256](file://src/config.rs#L107-L256)
|
|
529
|
+
- [tests/test_highlevel.py:151-179](file://tests/test_highlevel.py#L151-L179)
|
|
530
|
+
- [tests/test_session.py:45-108](file://tests/test_session.py#L45-L108)
|