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

Refactor origin inventory builder #78

Merged

Conversation

mikkokar
Copy link
Contributor

Simplify builder class for the OriginsInventory.

public Builder connectionFactory(Connection.Factory connectionFactory) {
this.connectionFactory = connectionFactory;
public Builder originHealthMonitor(OriginHealthStatusMonitor originHealthMonitor) {
this.originHealthMonitor = originHealthMonitor;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check this for null here, to avoid throwing an exception in the build method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

OriginsInventory originsInventory = new OriginsInventory(eventBus, backendService.id(), originHealthStatusMonitor, hostConnectionPoolFactory, metricsRegistry);
originsInventory.setOrigins(backendService.origins());
OriginsInventory originsInventory = new OriginsInventory(eventBus, appId, originHealthMonitor, connectionPoolFactory, metricsRegistry);
originsInventory.setOrigins(initialOrigins);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the setOrigins(Set<Origin>) method can be private, and setOrigins(Origin...) can be package-private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Kyle. The setOrigins(Set<Origin>) is nowadays public. This is because the inventory by design will manage the state for the origins, and the setOrigins provides a way to push more origins into the inventory.

return new StatsReportingConnectionPool(
new SimpleConnectionPool(
origin,
defaultSettableConnectionPoolSettings(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename defaultSettableConnectionPoolSettings since "settable" is no longer in the class name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Will do.

@@ -124,6 +155,39 @@ public void onChange(Registry.Changes<BackendService> changes) {
.close());
}

private OriginHealthCheckFunction originHealthCheckFunction(
Copy link
Contributor

Choose a reason for hiding this comment

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

This method can be static.

.build();
return new ProxyToBackend(clientFactory.createClient(backendService, inventory));
}

private ConnectionPoolFactory connectionPoolFactory(
Copy link
Contributor

Choose a reason for hiding this comment

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

This method can be static.

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 method is just a wrapper around new keyword. I will remove it.

@mikkokar mikkokar force-pushed the refactor-origin-inventory-builder branch from 5a02b80 to 4718907 Compare January 26, 2018 13:05
@mikkokar mikkokar merged commit 1201350 into ExpediaGroup:master Jan 26, 2018
@mikkokar mikkokar deleted the refactor-origin-inventory-builder branch June 27, 2018 07:42
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.

2 participants