Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aop): add @Commit and @Rollback, @Before/AfterTransaction decorators #30

Closed
biud436 opened this issue Sep 20, 2023 · 1 comment · Fixed by #31
Closed

feat(aop): add @Commit and @Rollback, @Before/AfterTransaction decorators #30

biud436 opened this issue Sep 20, 2023 · 1 comment · Fixed by #31
Assignees

Comments

@biud436
Copy link
Owner

biud436 commented Sep 20, 2023

We must be added new decorators called Rollback, Comit, Before/AfterTransaction in the TransactionalZone.

State

  • virtual transaction id

Rollback

In the rollback decorator, we have to pass error object that includes the method name to parameter.

Commit

in case of commit decorator, it has to pass a virtual transaction id to parameters.

Before/After Transaction

We need to pass a virtual transaction id. in the state called BeforeTransaction, the virtual transactiom id will be created.

Virtual Transaction ID

as you know that the HTTP Server is stateless. so to use the virtual transaction id for dividing a transaction, it will have to save transaction state to Store (like session store)

the Store is basically a Hash structure that needs an unique key. the unique key is the same as a fingerprint of user. generally, in case of session, the server can create the session key when it has completed a login process, and save it to cookie storage. However, in case of transaction, it can't implement it.

When enumerating methods of target class, we need to save some method to hash store.

/**
 * @type ITransactionStore
 */
export type ITransactionStore = {
    /**
     * 트랜잭션을 시작하기 전에 실행되는 메소드입니다.
     */
    [BEFORE_TRANSACTION_TOKEN]?: object;

    /**
     * 트랜잭션을 시작한 후에 실행되는 메소드입니다.
     */
    [AFTER_TRANSACTION_TOKEN]?: object;

    /**
     * 트랜잭션이 커밋된 후 실행되는 메소드입니다.
     */
    [TRANSACTION_COMMIT_TOKEN]?: object;

    /**
     * 트랜잭션이 롤백된 후 실행되는 메소드입니다.
     */
    [TRANSACTION_ROLLBACK_TOKEN]?: object;
};

and when performing the transaction, it can be executed by finding a stored method.

@biud436 biud436 changed the title feat: added @Commit and @Rollback, @AfterTransaction decorators feat(aop): added @Commit and @Rollback, @AfterTransaction decorators Sep 20, 2023
@biud436 biud436 changed the title feat(aop): added @Commit and @Rollback, @AfterTransaction decorators feat(aop): added @Commit and @Rollback, @Before/AfterTransaction decorators Sep 20, 2023
@biud436 biud436 changed the title feat(aop): added @Commit and @Rollback, @Before/AfterTransaction decorators feat(aop): add @Commit and @Rollback, @Before/AfterTransaction decorators Sep 21, 2023
@biud436 biud436 self-assigned this Sep 21, 2023
biud436 added a commit that referenced this issue Sep 21, 2023
@biud436
Copy link
Owner Author

biud436 commented Sep 21, 2023

image

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 a pull request may close this issue.

1 participant