-
-
Notifications
You must be signed in to change notification settings - Fork 760
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aligned DataLoader options behavior. (#8044)
- Loading branch information
1 parent
8006931
commit 95b6ca7
Showing
11 changed files
with
149 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace GreenDonut; | ||
|
||
/// <summary> | ||
/// This class represents a branched <see cref="IDataLoader{TKey, TValue}"/>. | ||
/// </summary> | ||
/// <typeparam name="TKey"> | ||
/// The type of the key. | ||
/// </typeparam> | ||
/// <typeparam name="TValue"> | ||
/// The type of the value. | ||
/// </typeparam> | ||
public class BranchedDataLoader<TKey, TValue> | ||
: DataLoaderBase<TKey, TValue> | ||
where TKey : notnull | ||
{ | ||
private readonly DataLoaderBase<TKey, TValue> _root; | ||
|
||
public BranchedDataLoader( | ||
DataLoaderBase<TKey, TValue> root, | ||
string key) | ||
: base(root.BatchScheduler, root.Options) | ||
{ | ||
_root = root; | ||
CacheKeyType = $"{root.CacheKeyType}:{key}"; | ||
ContextData = root.ContextData; | ||
} | ||
|
||
public IDataLoader<TKey, TValue> Root => _root; | ||
|
||
protected internal override string CacheKeyType { get; } | ||
|
||
protected sealed override bool AllowCachePropagation => false; | ||
|
||
protected override bool AllowBranching => true; | ||
|
||
protected internal override ValueTask FetchAsync( | ||
IReadOnlyList<TKey> keys, | ||
Memory<Result<TValue?>> results, | ||
DataLoaderFetchContext<TValue> context, | ||
CancellationToken cancellationToken) | ||
=> _root.FetchAsync(keys, results, context, cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters