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

Inject execution interceptors using multibinder #24404

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

kokosing
Copy link
Member

@kokosing kokosing commented Dec 7, 2024

Inject execution interceptors using multibinder

The GlueMetastoreModule is not truly following the inversion of control
paradigm. Many things are created directly in the methods without using
injection. Using set multibinder for execution interceptors allows to
independently define execution interceptors and use Guice injection.

Co-authored-by: Grzegorz Kokosiński [email protected]

@cla-bot cla-bot bot added the cla-signed label Dec 7, 2024
@github-actions github-actions bot added the hive Hive connector label Dec 7, 2024
@kokosing kokosing force-pushed the origin/master/003_cleanup branch 2 times, most recently from 2ee69e5 to 52c5923 Compare December 8, 2024 21:14
The GlueMetastoreModule is not truly following the inversion of control
paradigm. Many things are created directly in the methods without using
injection. Using set multibinder for execution interceptors allows to
independently define execution interceptors and use Guice injection.

Co-authored-by: Grzegorz Kokosiński <[email protected]>
@kokosing kokosing force-pushed the origin/master/003_cleanup branch from 52c5923 to ab4fe20 Compare December 10, 2024 12:51
@kokosing kokosing requested a review from losipiuk December 11, 2024 09:38
.setRecordIndividualHttpError(true)
.build().newExecutionInterceptor())
.addExecutionInterceptor(new GlueHiveExecutionInterceptor(config.isSkipArchive()))
.executionInterceptors(ImmutableList.copyOf(executionInterceptors))
Copy link
Member

Choose a reason for hiding this comment

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

You are loosing ordering here. Does it matter?

Copy link
Member Author

Choose a reason for hiding this comment

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

The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

So far order is maintained. If we keep adding new elements following the method above is safe. If we add an element in different module, then it could be added in random place (before or after this module).

I have checked the existing interceptors and they are independent from each other, and I believe it is important thing for them. If order would matter then I guess it would have to work as a stack because you have methods there like beforeX and afterX.

Copy link
Member Author

Choose a reason for hiding this comment

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

So I believe order does not matter here.

@kokosing kokosing merged commit 9662e43 into trinodb:master Dec 11, 2024
57 checks passed
@kokosing kokosing deleted the origin/master/003_cleanup branch December 11, 2024 10:41
@github-actions github-actions bot added this to the 468 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed hive Hive connector
Development

Successfully merging this pull request may close these issues.

3 participants