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

Sync/Async producers, retries and batch dispatch #1

Merged
merged 9 commits into from
May 10, 2019

Conversation

ghostec
Copy link
Contributor

@ghostec ghostec commented May 9, 2019

  • use rollup to distribuite lib/es with babel transpillation
  • reorganize project to split producers into 2
  • Async producer with SendEvents (batch) method
  • Async producer Retry logic
  • Report DroppedEvents

@ghostec ghostec force-pushed the feature/async-batches-retries branch 10 times, most recently from d355f2d to 5972ae5 Compare May 10, 2019 12:50
@ghostec ghostec requested a review from cscatolini May 10, 2019 12:59
@ghostec ghostec changed the title [WIP] Sync/Async producers, retries and batch dispatch Sync/Async producers, retries and batch dispatch May 10, 2019
@ghostec ghostec force-pushed the feature/async-batches-retries branch 3 times, most recently from 0c21a3a to c8e53c0 Compare May 10, 2019 14:41
Copy link
Contributor

@cscatolini cscatolini left a comment

Choose a reason for hiding this comment

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

WIP review. I still want to take a look in the tests before we proceed.

src/client.js Outdated
// the proposal was already accepted
// https://github.com/grpc/proposal/blob/master/L5-NODEJS-CLIENT-INTERCEPTORS.md
// but the PR is still ongoing
// https://github.com/grpc/grpc-node/pull/59
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the PR was already merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked this yesterday but I wasn't sold on the idea that we gain a lot by changing how it already is done. What are your points about using an interceptor vs what we have right now?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion actually. Using the interceptor is a bit cleaner but my main issue here is that:

  1. The comment is no longer valid since the PR is merged.
  2. It is in the wrong place. We would use the interceptor in this.grpcClient and not when building the event, right?

If we choose to move on without the interceptor I'd just remove this comment to avoid future confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright! removing the comment

src/config/default.json Show resolved Hide resolved
@@ -34,14 +34,20 @@ const clientRequestsFailureCounter = new client.Counter({
labelNames: ['clientHost', 'route', 'topic', 'reason'],
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need the clientHost as tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the same as go client


class MetricsReporter {
constructor(config) {
this.hostname = os.hostname()
Copy link
Contributor

Choose a reason for hiding this comment

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

We're no longer using hostname tag on our metrics. Remove this, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright! will remove from go client as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Great!

This solves the comment about clientHost as well, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

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

this.logger = logger.child({ address: this.address })
this.metrics = new MetricsReporter(this.config)
this.method = '/eventsgateway.GRPCForwarder/SendEvents'
this.lingerIntervalMs = this.config.producer.lingerIntervalMs === undefined ?
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of these long ternary lines. Maybe have a method like this (with better naming, please)

configure(field, default) {
  const val = this.config.producer[field] 
  this[field] = val === undefined ? default : val 
}

and inside the constructor use it:

this.configure('lingerIntervalMs', 500)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great idea

src/producer/async.js Show resolved Hide resolved
})
}

async gracefulStop () {
Copy link
Contributor

Choose a reason for hiding this comment

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

It bugs me that we have some duplicate code from async producer. Can't we share it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added producer/waitGroup

test/unit/asyncProducer.js Show resolved Hide resolved
@ghostec ghostec force-pushed the feature/async-batches-retries branch from c8e53c0 to d6b99f1 Compare May 10, 2019 15:06
Copy link
Contributor

@cscatolini cscatolini left a comment

Choose a reason for hiding this comment

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

Great work! 👍

@cscatolini cscatolini merged commit b906cea into master May 10, 2019
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.

None yet

3 participants