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

bulkhead #7

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

JohnDoePlusPlus
Copy link

No description provided.

JohnDoePlusPlus and others added 3 commits November 22, 2019 17:42
update options
update unit tests
Copy link
Member

@dimadeveatii dimadeveatii left a comment

Choose a reason for hiding this comment

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

A nice implementation. A few more checks are needed to ensure queue won't get blocked. Please review also the filename/directory name conventions. I think it should all be camelCase.

private readonly limit: number = Infinity,
) { }

public store(data: ExecutionMetaData<T>): this {
Copy link
Member

Choose a reason for hiding this comment

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

Please use standard queue method names, like push and pop instead of store and next

@@ -0,0 +1,14 @@
import { Factory } from '../../interfaces/factory';
Copy link
Member

Choose a reason for hiding this comment

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

Chances are low we will ever have another execution queue implementation than the current one. Therefore the factory here seems like an added complexity. I'd suggest rather to delete this file, and implement a static method static create<T>(limit: number): ExecutionQueue<T> directly in the ExecutionQueue class.

@@ -0,0 +1,57 @@
import { ExecutionQueue } from '../ExecutionQueue/ExecutionQueue';
Copy link
Member

Choose a reason for hiding this comment

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

Bulkhead/Bulkhead.ts doesn't sound nice. Maybe just bulkhead/index.ts ?

@@ -0,0 +1,18 @@
import { Factory } from '../../interfaces/factory';
Copy link
Member

Choose a reason for hiding this comment

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

Same as for queue implementation, this factory is not of much use taking into account there won't be another bulkhead implementations. Now it looks like an added complexity. I'd suggest that we implement a static create method directly in the bulkhead class.


const result = method(...args);

const afterExecution = async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if async is needed here.

private async execute(method: (...args: any[]) => Promise<T>, args: any[]) {
this.inExecution += 1;

const result = method(...args);
Copy link
Member

Choose a reason for hiding this comment

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

The provided method might throw an error, thus breaking our queue execution.

this.callNext();
};

result.then(afterExecution, afterExecution);
Copy link
Member

Choose a reason for hiding this comment

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

What if the method never resolves? It will stay forever in the queue and potentially might block the queue. I think we might need an additional option to setup a timeout for the execution. Could we use the @timeout from current library? Either as a decorator, or directly as a method.

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