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

[Event Hubs] Define classes and interfaces for EPH as per API design #4416

Merged
merged 5 commits into from
Jul 26, 2019

Conversation

ShivangiReja
Copy link
Member

As per feedback, we decided that EPH and Event Hubs client will ship in the same client library while the EPH plugins will each ship in their own separate client libraries.

This PR creates new classes and interfaces for Event processor host as per Proposed API design for EPH

@ShivangiReja ShivangiReja self-assigned this Jul 25, 2019
@ShivangiReja ShivangiReja requested a review from chradek July 25, 2019 00:17
Copy link
Contributor

@chradek chradek left a comment

Choose a reason for hiding this comment

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

Some minor comments but otherwise overall it looks good! Also good job remembering the copyright comments (I always forget those...)

private _partitionContext: PartitionContext; // for internal use by createCheckpoint
private _partitionManager: PartitionManager; // for internal use by createCheckpoint

get partitionContext(): PartitionContext {
Copy link
Contributor

Choose a reason for hiding this comment

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

partitionContext and partitionManager shouldn't be public for now. Customers will have access to both outside of CheckpointManager, and we want to the public API as simple as possible to start with.

Copy link
Member Author

@ShivangiReja ShivangiReja Jul 25, 2019

Choose a reason for hiding this comment

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

I added these public getters for now because build was failing with this error: _partitionContext' is declared but its value is never read.

I'll remove these getters later after the actual methods implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha. You could also just comment them out until we need them too :-)

* The PartitionProcessorFactory is called by EPH whenever a new partition is about to be processed.
*/
export interface PartitionProcessorFactory {
createPartitionProcessor(
Copy link
Contributor

Choose a reason for hiding this comment

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

For JavaScript, it's more idiomatic to provide a function as the factory than a class/object that has a factory method on it.

If you remove the function name createPartitionProcessor but leave the rest of the signature, then PartitionProcessorFactory will just describe a function instead.

So this should work:

const partitionProcessorFactory: PartitionProcessorFactory = (
  context: PartitionContext,
  checkpointManager: CheckpointManager
) => {
  return new PartitionProcessor();
};

This was discussed in the API proposal but we had the existing example to make it easier for our C# friends to read :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice!!

export interface PartitionProcessorFactory {
createPartitionProcessor(
context: PartitionContext,
checkpointManger: CheckpointManager
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: checkpointManger should be checkpointManager

@ShivangiReja ShivangiReja marked this pull request as ready for review July 25, 2019 18:36
@ShivangiReja ShivangiReja requested a review from ramya-rao-a July 25, 2019 20:33
* PartitionContext is passed into an EventProrcessor's initialization handler and contains information
* about the partition, the EventProcessor will be processing events from.
*/
export class PartitionContext {
Copy link
Contributor

Choose a reason for hiding this comment

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

@chradek Do we need this to be a class?
Or are we making it a class to ensure that the properties are readonly?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be safe to make this an interface now. If we want to ensure the properties are readonly at runtime we can either freeze the object that implements the interface Object.freeze or create the object using Object.defineProperties


public async createCheckpoint(offset: string, sequenceNumber: number): Promise<void>;

public async createCheckpoint(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be updateCheckpoint after the latest round of updates

@ShivangiReja ShivangiReja merged commit 18de29b into Azure:master Jul 26, 2019
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.

3 participants