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

resolves #72 introduce a recovery queue #74

Merged
merged 11 commits into from
Jul 21, 2022

Conversation

ggrossetie
Copy link
Contributor

Introduce a recovery queue in order to store data when the connection is lost and send them when the connection is established again.

New options:

  • recovery: Enable recovering data when reconnecting after the connection was dropped. Default: false.
  • recoveryQueueSizeCalculation: Function used to calculate the size of stored elements. Default: element => element.data.length + element.encoding.length.
  • recoveryQueueMaxSize: Positive integer to track the sizes of items added to the cache, and automatically evict items in order to stay below this size. Default: Infinity

This feature is disabled by default.
Should we emit a warning if the user enables this feature without a max size?

Since I've updated the Readme.md in #71, I will add documentation for them once #71 is merged.

Resolves #72

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

This also needs some docs

lib/Queue.js Show resolved Hide resolved
lib/TcpConnection.js Show resolved Hide resolved
test/recovery.js Outdated Show resolved Hide resolved
@ggrossetie
Copy link
Contributor Author

This also needs some docs

Yes.
To avoid conflicts, I'm waiting on #71 to be merged before adding documentation.

@ggrossetie
Copy link
Contributor Author

Documentation added.

I think we need to decide if we want to emit a warning or emit an event when an error occurred while writing data to the TCP socket. There are two cases where we write data to the TCP socket:

  • nominal case
  • recovery case when we try to dequeue items from the recovery queue

@ggrossetie ggrossetie requested a review from mcollina July 18, 2022 13:05
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit a89fd71 into pinojs:master Jul 21, 2022
@mcollina
Copy link
Member

Thanks!

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.

[Feature idea] Introduce a FIFO queue with a max size to store data when the TCP socket write is unsuccessful
2 participants