Skip to content

Expose restartTimes to client.#658

Merged
dbaeumer merged 4 commits intomicrosoft:masterfrom
hokein:expose-restart-time
Sep 1, 2020
Merged

Expose restartTimes to client.#658
dbaeumer merged 4 commits intomicrosoft:masterfrom
hokein:expose-restart-time

Conversation

@hokein
Copy link
Contributor

@hokein hokein commented Aug 12, 2020

Implements #418

private readonly restarts: number[];

constructor(private name: string) {
constructor(private name: string, private restartTimes: number) {
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest to name this maxRestartCount. We usually use count instead of times for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

interface ConnectionOptions {
cancellationStrategy: CancellationStrategy
restartTimes: number
maxRestartCount: number
Copy link
Member

Choose a reason for hiding this comment

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

Actually more stuff. Sorry for this. For backwards compatibility this should be in the whole call sequence be optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


public createDefaultErrorHandler(restartTimes: number): ErrorHandler {
return new DefaultErrorHandler(this._name, restartTimes);
public createDefaultErrorHandler(maxRestartCount: number): ErrorHandler {
Copy link
Member

Choose a reason for hiding this comment

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

See above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

public createDefaultErrorHandler(maxRestartCount: number): ErrorHandler {
return new DefaultErrorHandler(this._name, maxRestartCount);
public createDefaultErrorHandler(maxRestartCount?: number): ErrorHandler {
return new DefaultErrorHandler(this._name, maxRestartCount || 5);
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct. It will even default to 5 if maxRestartCount is 0 since || is coercive. Did you mean maxRestartCount ?? 5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Ah, right, ?? is what I meant.

Also added a sanity check for invalid value, It should keep the original behavior now.

- || => ??
- add sanity check for invalid value
- correct the logic
@ghost
Copy link

ghost commented Aug 19, 2020

CLA assistant check
All CLA requirements met.

@dbaeumer dbaeumer merged commit ddf7ee6 into microsoft:master Sep 1, 2020
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