Skip to content

Modularity#44

Closed
louisdussarps wants to merge 83 commits intomainfrom
modularity
Closed

Modularity#44
louisdussarps wants to merge 83 commits intomainfrom
modularity

Conversation

@louisdussarps
Copy link
Contributor

Change description

First step toward orbits v2

Introduction on a new syntax in the Workflow and of two new classes in the core of orbits

Workflow

Now the body of define has to be written as :
`define(){
await this.do("xyz", new Action(...))

}`

Pro :
Easier to add a step in the middle of a workflow
Easier to read
Easier to do try/catch

Con:
Can be confusing with a classic await --> maybe we should write an eslint rule in order not to mixt the two kind of await

Generator

Generators are introduced to manage locking and avoid conflicting runs.

How does it work ?

When a generator starts, it checks if another generator with the same identity + actionRef exists.
If one exists and hasn’t reached a SUCCESS state, it reuses the existing one instead of launching a new one.

Resource

Resources help solve the "redo workflow" problem by introducing lifecycle methods with versioning and drift detection.

How does it work ?

defineInstall() is run :

  • Called the first time the resource runs, or if the version changes.

defineUpdate() is run :

  • Called on every resource execution

defineUninstall() is run :

  • Called only if the resource is explicitly uninstalled

Additionally:

  • A digest cycle runs to detect and handle resource drift.
  • Enables straightforward implementation of cron-like tasks (e.g. refreshXanoLicense every X hours)

Type of change

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

Related issues

This TR can be looked : https://docs.google.com/document/d/1JuZ0Xz6wDmesNPXtBK-c7gi_dq083TzB1krssMgyN-s/edit?tab=t.0

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

Next steps :

  • Remove the definition of an app
  • Change the executor to be proper
  • Add a default executor via a launch through git

rollBack() {
return Promise.resolve(ActionState.SUCCESS);
clone(){
const clone = new (this.constructor as any)();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the fact that setArgument returns this?
return (new (this.constructor as any)()).setArgument({ ...this.argument });


export enum ResourceState {
/**
* @deprecated use UNKNOWN
Copy link
Contributor

Choose a reason for hiding this comment

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

lets take the opportunity to remove all the deprecated things

return Action._constructFromWorkflow(actionDb);
} else {
return Action._constructFromDb(actionDb);
}
Copy link
Contributor

@tmarcuzz tmarcuzz Apr 16, 2025

Choose a reason for hiding this comment

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

That would be more concise:

return actionDb.definitionFrom?.workflow?._id 
    ? Action._constructFromWorkflow(actionDb)
    : Action._constructFromDb(actionDb);

setResult(result: Object) {
this.dbDoc.result = { ...this.dbDoc.result, ...result };
setResult(...results) {
if(results.length === 1){
Copy link
Contributor

@tmarcuzz tmarcuzz Apr 16, 2025

Choose a reason for hiding this comment

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

more concise alternative

this.dbDoc.result = results.length === 1 ? results[0] : results;

@louisdussarps louisdussarps marked this pull request as ready for review July 8, 2025 12:41
@tmarcuzz tmarcuzz closed this Jul 24, 2025
@tmarcuzz tmarcuzz deleted the modularity branch July 24, 2025 10:05
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.

3 participants