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

Adds a predicate to DataLoaderRegistry and a per dataloader map of pedicates is also possible #133

Merged
merged 8 commits into from
Oct 8, 2023

Conversation

bbakerman
Copy link
Member

@bbakerman bbakerman commented Sep 29, 2023

This adds a map of per dataloader predicates to ScheduledDataLoaderRegistry so people can have more fine grain control on when a dataloader is dispatched.

if its not used then it goes back to the default behavior of one predicate for the ScheduledDataLoaderRegistry

@@ -15,7 +15,7 @@
public @interface GuardedBy {

/**
* The lock that should be held.
* @return The lock that should be held.
Copy link
Member Author

Choose a reason for hiding this comment

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

stopped a javadoc warning

Copy link

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

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

Looks good to me. Some minor comments below.

Builder combinedBuilder = ScheduledDataLoaderRegistry.newScheduledRegistry()
.dispatchPredicate(this.dispatchPredicate);
combinedBuilder.registerAll(this);
combinedBuilder.registerAll(registry);

Choose a reason for hiding this comment

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

Maybe worth checking here, or inside registerAll if the other registry is also a ScheduledDataLoaderRegistry and if so picking up its dispatchPredicates too.

Copy link
Member Author

Choose a reason for hiding this comment

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

checked - it does

*/
public DispatchPredicate getDispatchPredicate() {
return dispatchPredicate;
}
Copy link

Choose a reason for hiding this comment

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

Now that a DispatchPredicate can be registered per DataLoader, this should ideally be called defaultDispatchPredicate. However, I understand that would involve renaming, and/or a deprecation and a property with the new name. In the very least, the Javadoc should be updated to indicate that it applies by default, if there isn't already a registration for that DataLoader.

Also, really minor but the field and getter for dispatchPredicate could be ordered after the map of predicates, like it is in the builder to reflect it comes after the other registrations.

Copy link
Member Author

Choose a reason for hiding this comment

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

done. I didnt deprecate but I did redocument

@bbakerman bbakerman added this to the 3.2.1 milestone Oct 8, 2023
@bbakerman bbakerman merged commit 442edf4 into master Oct 8, 2023
1 check passed
@dondonz dondonz deleted the predicate_per_registry_per_dataloader branch October 17, 2023 05:21
github-merge-queue bot pushed a commit to camunda/camunda that referenced this pull request Apr 24, 2024
…ain) (#17708)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[com.graphql-java:java-dataloader](https://togithub.com/graphql-java/java-dataloader)
| `3.2.0` -> `3.3.0` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/com.graphql-java:java-dataloader/3.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.graphql-java:java-dataloader/3.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.graphql-java:java-dataloader/3.2.0/3.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.graphql-java:java-dataloader/3.2.0/3.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>graphql-java/java-dataloader
(com.graphql-java:java-dataloader)</summary>

###
[`v3.3.0`](https://togithub.com/graphql-java/java-dataloader/releases/tag/v3.3.0):
3.3.0

[Compare
Source](https://togithub.com/graphql-java/java-dataloader/compare/v3.2.2...v3.3.0)

#### What's Changed

- Pre-size resulting lists by [@&#8203;dfa1](https://togithub.com/dfa1)
in
[graphql-java/java-dataloader#142
- Minor javadoc fixes by [@&#8203;dfa1](https://togithub.com/dfa1) in
[graphql-java/java-dataloader#141
- Shuts down executor if its was auto added by our code by
[@&#8203;bbakerman](https://togithub.com/bbakerman) in
[graphql-java/java-dataloader#144
- If there is a specific predicate for a dataloader - its is the final
say on whether to dispatch by
[@&#8203;bbakerman](https://togithub.com/bbakerman) in
[graphql-java/java-dataloader#145

**Full Changelog**:
graphql-java/java-dataloader@v3.2.2...v3.3.0

###
[`v3.2.2`](https://togithub.com/graphql-java/java-dataloader/releases/tag/v3.2.2):
3.2.2

[Compare
Source](https://togithub.com/graphql-java/java-dataloader/compare/v3.2.1...v3.2.2)

#### What's Changed

A series of small fixes to make the code more efficient

- Lazily initialize Executor in ScheduledDataLoaderRegistry builder by
[@&#8203;kilink](https://togithub.com/kilink) in
[graphql-java/java-dataloader#135
- Avoid allocations in DataLoaderHelper.dispatch when there's no work by
[@&#8203;kilink](https://togithub.com/kilink) in
[graphql-java/java-dataloader#136

#### New Contributors

- [@&#8203;kilink](https://togithub.com/kilink) made their first
contribution in
[graphql-java/java-dataloader#135

**Full Changelog**:
graphql-java/java-dataloader@v3.2.1...v3.2.2

###
[`v3.2.1`](https://togithub.com/graphql-java/java-dataloader/releases/tag/v3.2.1):
3.2.1

[Compare
Source](https://togithub.com/graphql-java/java-dataloader/compare/v3.2.0...v3.2.1)

### New ticker mode

There is a new mode in `ScheduledDataLoaderRegistry` called ticker mode
that will continue to tick away and allow for chained data loader calls.
See the readme for more details.

```java
  ScheduledDataLoaderRegistry registry = ScheduledDataLoaderRegistry.newScheduledRegistry()
        .register("a", dataLoaderA)
        .register("b", dataLoaderB)
        .scheduledExecutorService(executorService)
        .schedule(Duration.ofMillis(10))
        .tickerMode(true) // ticker mode is on
        .build();

  CompletableFuture<Object> chainedCalls = dataLoaderA.load("user1")
        .thenCompose(userAsKey -> dataLoaderB.load(userAsKey));
```

### Predicates per dataloader in ScheduledDataLoaderRegistry

`ScheduledDataLoaderRegistry` now has the capability to have a predicate
per data loader specified as well as an overall one. This allows you to
have fine control on when dataloaders get dispatched.

#### What's Changed

- Try.getThrowable - fixed incorrect exception message by
[@&#8203;rstata](https://togithub.com/rstata) in
[graphql-java/java-dataloader#122
- Prepend 0.0.0 to build version by
[@&#8203;dondonz](https://togithub.com/dondonz) in
[graphql-java/java-dataloader#126
- Batch scheduler function support by
[@&#8203;bbakerman](https://togithub.com/bbakerman) in
[graphql-java/java-dataloader#128
- Adds a predicate to DataLoaderRegistry and a per dataloader map of
pedicates is also possible by
[@&#8203;bbakerman](https://togithub.com/bbakerman) in
[graphql-java/java-dataloader#133
- Ticker mode on ScheduledDataLoaderRegistry by
[@&#8203;bbakerman](https://togithub.com/bbakerman) in
[graphql-java/java-dataloader#131

#### New Contributors

- [@&#8203;rstata](https://togithub.com/rstata) made their first
contribution in
[graphql-java/java-dataloader#122
- [@&#8203;dondonz](https://togithub.com/dondonz) made their first
contribution in
[graphql-java/java-dataloader#126

**Full Changelog**:
graphql-java/java-dataloader@v3.2.0...v3.2.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 10pm every weekday,before 6am
every weekday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/camunda/zeebe).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMTMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWVyZ2UiXX0=-->
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

2 participants