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

New features and enhancements #92

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

ykhatal
Copy link
Contributor

@ykhatal ykhatal commented Aug 4, 2017

Early opened PR, below you can find a list of what was done or still to be:

  • Implementation of channel pool
  • Implementation of universal message format (UMF)
  • Implementation of a requeue count
  • Add unit tests
  • Add benchmarks

@ykhatal ykhatal self-assigned this Aug 4, 2017
@jkernech jkernech changed the title New features and enehancement New features and enhancements Aug 4, 2017
- implementatio of channel pool
- implementation of universal message format
- Add benchmark
@ykhatal ykhatal force-pushed the feature/enhancements branch from fb05974 to e15f0f5 Compare August 4, 2017 14:34
Copy link
Contributor

@Spring3 Spring3 left a comment

Choose a reason for hiding this comment

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

🍖 🍺 Very awesome! The code has become much more clear now. I left some minor suggestions for you to consider


# To do
TO-DO.md
>>>>>>> New features and enehancement
Copy link
Contributor

Choose a reason for hiding this comment

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

There was an unsuccessful merge

const suite = new Benchmark.Suite;

process.on('unhandledRejection', error => {
// Will print "unhandledRejection err is not dewfined"
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in the last word

timeout: 1000,
// default timeout for RPC calls. If set to '0' there will be none.
rpcTimeout: 15000,
consumerSuffix: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it be taken from LOCAL_QUEUE?

return this.connection.createChannel()
.then((channel) => {
++this.channelCount;
this.pool.push(channel);
Copy link
Contributor

@Spring3 Spring3 Aug 17, 2017

Choose a reason for hiding this comment

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

you can do
this.channelCount = this.pool.push(channel)
Take a look at a return value description

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also check for poolSize and current amount of channel?


getChannel() {
return mutex.synchronize(() => {
if (this.pool.length) return Promise.resolve(this.pool.shift());
Copy link
Contributor

@Spring3 Spring3 Aug 17, 2017

Choose a reason for hiding this comment

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

Out of optimization perspective, can you use pop() instead? The difference is that shift will force the array re-indexing, which is a costly operation if you take into consideration the possible amount of channels and frequency of the function calls, while pop() simply cuts one element from the end.

static serialize(message, enableCompression) {
console.log('message:', message);
return new Promise((resolve, reject) => {
const msg = Buffer.from(JSON.stringify(message), 'utf-8');
Copy link
Contributor

@Spring3 Spring3 Aug 17, 2017

Choose a reason for hiding this comment

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

If you want to use encoding, you need to remove the dash, because utf-8 does not exist, but just for your info, utf8 is a default encoding for buffer, so no need to do it explicitly

Docs

function serializeMsg(msg, options) {
const falsie = [undefined, null];

if (typeof msg === 'string') return Buffer.from(msg, 'utf-8');
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above (about utf8)

msg = JSON.stringify(msg);
options.contentType = 'application/json';

return Buffer.from(msg, 'utf-8');
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above (utf8)

// Par défaut, Object.assign copie également
// les symboles énumérables
Object.getOwnPropertySymbols(source).forEach(sym => {
let descriptor = Object.getOwnPropertyDescriptor(source, sym);
Copy link
Contributor

@Spring3 Spring3 Aug 17, 2017

Choose a reason for hiding this comment

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

It's good, but it's an es8 feature while we use LTS node version, which supports ES6 + some ES7. It runs locally for you without issues because you have a modern version of node, but can you check it with the LTS?

correlationId: options.correlationId,
replyTo: options.replyTo,
// requeue: options.requeue,
// requeueCount: options.requeueCount
Copy link
Contributor

Choose a reason for hiding this comment

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

if not used, then please remove these

@rafaismyname
Copy link

such an awesome pull... why it's not merged yet?
you guys need any help? :)

best

@ykhatal
Copy link
Contributor Author

ykhatal commented Nov 30, 2017

@RafaelAmorim thanks for your message.
We are sorry for the delay, we are currently working on other fronts, so we didn't manage to find the time to work on it.
Below you can find an exhaustive list of what remains:

  • Code documentation
  • Fix PR according to review suggestion
  • Refactor some parts, like extract the serialize, deserialize, and zip functions to MessageFormater class instead of keeping them in the message.
  • Fix tests and add new ones
  • Do another round of stress tests
  • Make sure all features work fine
  • Make sure that there is no breaking changes
  • Wrap up everything and do the release
  • publish to npm

So feel free to fork it and provide some work there, we always appreciate contributions.
Thanks 😉

@ofkindness ofkindness removed their request for review March 22, 2018 15:30
@mrister mrister removed their request for review April 30, 2019 12:31
@jkernech jkernech removed their request for review July 19, 2019 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants