Skip to content

Sample workflow management - #65

Closed
louisdussarps wants to merge 9 commits into
mainfrom
sample-workflow-management
Closed

Sample workflow management#65
louisdussarps wants to merge 9 commits into
mainfrom
sample-workflow-management

Conversation

@louisdussarps

Copy link
Copy Markdown
Contributor

Change description

Description here

Type of change

  • Bug fix (fixes an issue)
  • New feature (adds functionality)

Related issues

Checklists

Development

  • Lint rules pass locally
  • Application changes have been tested thoroughly
  • Automated tests covering modified code pass

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

Code review

  • Pull request has a descriptive title and context useful to a reviewer. Screenshots or screencasts are attached as necessary
  • reviewers assigned

Comment thread samples/orchestrate-lambda/Readme.md
Comment thread samples/orchestrate-lambda/Readme.md
}

async main(){
console.log(`url ${JSON.stringify(API_ADDRESS)} is buyStock`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utiliser internalLog

body: JSON.stringify({ stock_price: this.argument.price })
};
const response = await fetch(API_ADDRESS + 'buyStock', requestOptions);
this.result.stockData = await response.json();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utiliser setResult plutôt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok je l'avais laissé comme cela car la dernière fois tu m'as dit de laisser.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui, pas crucial sur ce point

const workflow = new TradingWorkflow();
await workflow.save();
await Action.trackActionAsPromise(workflow);
console.log(await workflow.getLogs());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLogs() non fonctionnel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'était repris sur la demo cdk8s

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typage a priori superflu

const buyOrSellRecommendation : string = resultGenerateBuySellRecommendationAction.buyOrSellRecommendation
console.log(`Got recommendation based on price: ${buyOrSellRecommendation}`)

let result: StockTransaction = {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'aurais plutôt mis les return à l'intérieur du if, qu'un result isolé comme ça

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dans tous les cas let result:.. suffit, pas besoin d'initialiser la valeur

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, j'aime généralement cette forme de code cela permet de pouvoir modifier result comme on le veut et éviter des erreurs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça serait bien d'avoir une version qui utilise l'api asyncrhone des lambdas pour toutes ces actions. ça permettrait d'illustrer le watcher()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je veux bien plus d'information sur ce point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quoi comme informations ? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faudrait se baser sur cloudwatch pour récupérer le résultat de la fonction en fonction d'un requestId

Comment thread samples/orchestrate-lambda/.env Outdated
@@ -0,0 +1 @@
API_ADDRESS=https://f4h881vcjl.execute-api.eu-west-3.amazonaws.com/prod/ No newline at end of file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ce fichier est aussi dans les .gitignore

Comment thread samples/orchestrate-lambda/package.json Outdated
"dependencies": {
"@orbi-ts/core": "latest",
"@orbi-ts/fuel": "latest",
"dotenv": "^17.0.1",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a vraiment besoin de dotenv dans les dépendances ?

@louisdussarps louisdussarps left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas le bon lien pour AWS ?

price:stockPrice.stock_price
}));

const buyOrSellRecommendation : string = resultGenerateBuySellRecommendationAction.buyOrSellRecommendation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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**

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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**.

---

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ç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

Comment thread samples/orchestrate-lambda/src/const.ts Outdated
@@ -0,0 +1,3 @@
export const API_ADDRESS = process.env['API_ADDRESS'];

console.log(API_ADDRESS)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enlever le console.log ?

ActionRuntime.activeRuntime.waitForBootstrap.then(async ()=>{
const workflow = new TradingWorkflow();
await workflow.save();
await Action.trackActionAsPromise(workflow);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu veux pas afficher le résultat à la fin ? Sinon le await ne sert pas à grand chose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'ailleurs trackActionAsPromise retourne le résultat

@ldechamps ldechamps closed this Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants