Sample workflow management - #65
Conversation
| } | ||
|
|
||
| async main(){ | ||
| console.log(`url ${JSON.stringify(API_ADDRESS)} is buyStock`); |
There was a problem hiding this comment.
utiliser internalLog
| body: JSON.stringify({ stock_price: this.argument.price }) | ||
| }; | ||
| const response = await fetch(API_ADDRESS + 'buyStock', requestOptions); | ||
| this.result.stockData = await response.json(); |
There was a problem hiding this comment.
utiliser setResult plutôt
There was a problem hiding this comment.
ok je l'avais laissé comme cela car la dernière fois tu m'as dit de laisser.
There was a problem hiding this comment.
oui, pas crucial sur ce point
| const workflow = new TradingWorkflow(); | ||
| await workflow.save(); | ||
| await Action.trackActionAsPromise(workflow); | ||
| console.log(await workflow.getLogs()); |
There was a problem hiding this comment.
getLogs() non fonctionnel
There was a problem hiding this comment.
c'était repris sur la demo cdk8s
There was a problem hiding this comment.
hmm, sûr ? je le vois ni sur cdk8s ni sur cdk
|
|
||
| async define(){ | ||
| const resultCheckStockPrice = await this.do("check-stock-price", new CheckStockPriceAction()); | ||
| const stockPrice: StockPriceResultObj = resultCheckStockPrice.stockPrice as StockPriceResultObj; |
There was a problem hiding this comment.
typage a priori superflu
| const buyOrSellRecommendation : string = resultGenerateBuySellRecommendationAction.buyOrSellRecommendation | ||
| console.log(`Got recommendation based on price: ${buyOrSellRecommendation}`) | ||
|
|
||
| let result: StockTransaction = { |
There was a problem hiding this comment.
j'aurais plutôt mis les return à l'intérieur du if, qu'un result isolé comme ça
There was a problem hiding this comment.
dans tous les cas let result:.. suffit, pas besoin d'initialiser la valeur
There was a problem hiding this comment.
yep, j'aime généralement cette forme de code cela permet de pouvoir modifier result comme on le veut et éviter des erreurs.
There was a problem hiding this comment.
Dans ce cas
let result : StockTransaction suffit, pas besoin de l'affection non ?
| import { JSONObject } from "../../../../../packages/services/src/utils"; | ||
|
|
||
|
|
||
| export class BuyStockAction extends Action { |
There was a problem hiding this comment.
ça serait bien d'avoir une version qui utilise l'api asyncrhone des lambdas pour toutes ces actions. ça permettrait d'illustrer le watcher()
There was a problem hiding this comment.
Je veux bien plus d'information sur ce point
There was a problem hiding this comment.
quoi comme informations ? 🤔
There was a problem hiding this comment.
faudrait se baser sur cloudwatch pour récupérer le résultat de la fonction en fonction d'un requestId
| @@ -0,0 +1 @@ | |||
| API_ADDRESS=https://f4h881vcjl.execute-api.eu-west-3.amazonaws.com/prod/ No newline at end of file | |||
There was a problem hiding this comment.
ce fichier est aussi dans les .gitignore
| "dependencies": { | ||
| "@orbi-ts/core": "latest", | ||
| "@orbi-ts/fuel": "latest", | ||
| "dotenv": "^17.0.1", |
There was a problem hiding this comment.
on a vraiment besoin de dotenv dans les dépendances ?
louisdussarps
left a comment
There was a problem hiding this comment.
quelques petites remarques ; il manque plus grand chose
|
|
||
| ## Use Case | ||
|
|
||
| In this blog post, we revisit the example of orchestrating a banking transaction. This canonical example was provided by [AWS Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html) and [Temporal](https://temporal.io/blog/temporal-replaces-state-machines-for-distributed-applications). Readers can refer to these articles to compare the syntax and ease of implementation offered by each tool. |
There was a problem hiding this comment.
pas le bon lien pour AWS ?
| price:stockPrice.stock_price | ||
| })); | ||
|
|
||
| const buyOrSellRecommendation : string = resultGenerateBuySellRecommendationAction.buyOrSellRecommendation |
There was a problem hiding this comment.
pas besoin du string ici ?
| - **Atomic actions**: Each business step is an independent and testable action | ||
| - **Conditional branching**: The workflow flow can diverge based on data (buy or sell). It does not differ from standard TypeScript code. | ||
| - **Extensibility**: We can easily add steps, compensation logic, monitoring | ||
| - **Resilience**: Recovery after crash, state management, built-in observability |
There was a problem hiding this comment.
il manque un verbe ici en comparaison des autres tirets
| - Takes a **typed input** (price) | ||
| - Calls a remote API in an encapsulated manner | ||
| - **Returns a state - ActionState.SUCCESS**, ready to be recorded and resumed | ||
| - Handles **errors by default via a state - ActionState.ERROR** |
There was a problem hiding this comment.
il faudrait surtout expliquer/trouver le moyen d'introduire le ActionState.IN_PROGRESS non ? Sinon on voit pas pourquoi le state de l'action serait pas le state de la promise qui constitue le main()
There was a problem hiding this comment.
Proposition :
- Alternative : return ActionState.IN_PROGRESS, avoid waiting for the API response delegating to the watcher the responsibility of determining the final state of the action.
| For your critical processes — e-commerce, finance, logistics, etc. — **adopting such an approach will significantly reduce your bug rate and inconsistencies**. | ||
|
|
||
| --- | ||
|
|
There was a problem hiding this comment.
ça serait bien de rediriger quelque part, soit à la fin, soit dès le début, vers le sample, pour qu'on puisse voir le code source directement dans github et pourquoi pas le tester
| @@ -0,0 +1,3 @@ | |||
| export const API_ADDRESS = process.env['API_ADDRESS']; | |||
|
|
|||
| console.log(API_ADDRESS) | |||
There was a problem hiding this comment.
enlever le console.log ?
| ActionRuntime.activeRuntime.waitForBootstrap.then(async ()=>{ | ||
| const workflow = new TradingWorkflow(); | ||
| await workflow.save(); | ||
| await Action.trackActionAsPromise(workflow); |
There was a problem hiding this comment.
tu veux pas afficher le résultat à la fin ? Sinon le await ne sert pas à grand chose
There was a problem hiding this comment.
d'ailleurs trackActionAsPromise retourne le résultat
Change description
Type of change
Related issues
Checklists
Development
Security
Code review