Skip to content

Commit f866efc

Browse files
authored
docs: DR for prioritized transfer services (#4869)
1 parent bfe92d5 commit f866efc

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Prioritized transfer services
2+
3+
## Decision
4+
5+
We will add a priority to `TransferServices` within the `TransferServiceRegistry`. `TransferServices` can then either
6+
be registered with a specific priority or, when registered without specifying one, be assigned the default priority.
7+
When a `TransferService` is selected, it will be chosen by priority.
8+
9+
## Rationale
10+
11+
For a given transfer, there may be multiple `TransferServices` which can handle the transfer and, for a given use case,
12+
a specific `TransferService` may be preferred over others. Right now, there is no way to ensure that a specific
13+
`TransferService` is chosen. Instead, the first applicable one is selected. By assigning a priority to the
14+
`TransferServices`, it can be ensured that more specialized services are chosen over less specialized ones, if both are
15+
applicable.
16+
17+
## Approach
18+
19+
The implementation will be similar to the registration and selection of `DataFlowControllers` in the
20+
`DataFlowManagerImpl`, as these are also based on a prioritization.
21+
22+
### Registration
23+
24+
A new method will be added to the `TransferServiceRegistry` for registering a `TransferService` with a priority:
25+
26+
```java
27+
void registerTransferService(int priority, TransferService transferService);
28+
```
29+
30+
The existing method for registering a `TransferService` without assigning a priority will default to using priority 0.
31+
This also ensures that existing registrations continue working in the same way.
32+
33+
Within the `TransferServiceRegistryImpl`, a record will be created which links a `TransferService` to its priority.
34+
Internally, the `TransferServiceRegistryImpl` will then work with this new record.
35+
36+
```java
37+
record PrioritizedTransferService(int priority, TransferService service) { }
38+
```
39+
40+
### Selection
41+
42+
At the moment, a `TransferServiceSelectionStrategy` is used to select a `TransferService`. This will be deprecated
43+
in favor of the prioritization. Selection will then be handled by filtering for all applicable services and choosing
44+
the one with the highest priority:
45+
46+
```java
47+
@Override
48+
@Nullable
49+
public TransferService resolveTransferService(DataFlowStartMessage request) {
50+
return transferServices.stream()
51+
.filter(pts -> pts.service.canHandle(request))
52+
.sorted(Comparator.comparingInt(pts -> -pts.priority))
53+
.map(PrioritizedTransferService::service)
54+
.findFirst().orElse(null);
55+
}
56+
```
57+
58+
As by our deprecation policy the `TransferServiceSelectionStrategy` needs to remain functional until removed, both
59+
solutions will be applied in parallel until its removal. Therefore, the `TransferServiceSelectionStrategy` will
60+
for now be applied as a fallback in case no `TransferService` with a priority greater than 0 is present.

docs/developer/decision-records/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@
7676
- [2025-02-06 HashiCorp Vault Authentication Refactor](./2025-02-06-hashicorp-vault-authentication-refactor)
7777
- [2025-02-07 Deprecation of HTTP Proxy in the Data Plane](./2025-02-07-http-proxy-data-plane-deprecation)
7878
- [2025-02-27 Move provisioning phase in the Data Plane](./2025-02-27-move-provisioning-phase-data-plane)
79+
- [2025-03-14 Prioritized Transfer Services](./2025-03-14-prioritized-transfer-services)

0 commit comments

Comments
 (0)