Skip to content

Commit

Permalink
Merge pull request #117 from statisticsnorway/add-virtual-threads
Browse files Browse the repository at this point in the history
Use virtual threads for all endpoints
  • Loading branch information
mallport authored Sep 25, 2024
2 parents 559924d + ee99825 commit 6ed069d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface CloudIdentityClient {
* @return a {@link Publisher} of {@link LookupResponse}
*/
@Get( "/groups:lookup?groupKey.id={groupKeyId}")
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
Publisher<LookupResponse> lookup(String groupKeyId);

/**
Expand All @@ -31,6 +31,6 @@ public interface CloudIdentityClient {
* @return a {@link Publisher} of {@link MembershipResponse}
*/
@Get( "/groups/{groupId}/memberships?pageToken={pageToken}")
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
Publisher<MembershipResponse> listMembers(String groupId, @Nullable String pageToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public HttpResponse<Flowable<byte[]>> pseudonymizeField(
@Produces(MediaType.APPLICATION_JSON)
@Secured({PseudoServiceRole.ADMIN})
@Post(value = "/depseudonymize/field", consumes = MediaType.APPLICATION_JSON)
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
public HttpResponse<Flowable<byte[]>> depseudonymizeField(
@Schema(implementation = DepseudoFieldRequest.class) String request
) {
Expand Down Expand Up @@ -132,7 +132,7 @@ public HttpResponse<Flowable<byte[]>> depseudonymizeField(
@Produces(MediaType.APPLICATION_JSON)
@Secured({PseudoServiceRole.ADMIN})
@Post(value = "/repseudonymize/field", consumes = MediaType.APPLICATION_JSON)
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
public HttpResponse<Flowable<byte[]>> repseudonymizeField(
@Schema(implementation = RepseudoFieldRequest.class) String request
) {
Expand Down Expand Up @@ -178,7 +178,7 @@ Pseudo rules will most times refer to crypto keys. You can provide your own keys
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(value = MediaType.APPLICATION_JSON)
@SingleResult
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
public HttpResponse<Flowable<byte[]>> pseudonymizeFile(
@Schema(implementation = PseudoRequest.class) String request, StreamingFileUpload data
) {
Expand Down Expand Up @@ -229,7 +229,7 @@ Pseudo rules will most times refer to crypto keys. You can provide your own keys
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Secured({PseudoServiceRole.ADMIN})
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
public HttpResponse<Flowable<byte[]>> depseudonymizeFile(
@Schema(implementation = PseudoRequest.class) String request, StreamingFileUpload data, Principal principal
) {
Expand Down Expand Up @@ -281,7 +281,7 @@ Pseudo rules will most times refer to crypto keys. You can provide your own keys
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Secured({PseudoServiceRole.ADMIN})
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
public HttpResponse<Flowable<byte[]>> repseudonymizeFile(
@Schema(implementation = RepseudoRequest.class) String request, StreamingFileUpload data, Principal principal) {
log.info(Strings.padEnd(String.format("*** Repseudonymize file: %s", data.getFilename()), 80, '*'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class LocalSidServiceController {
private final SidService sidService;

@Secured({PseudoServiceRole.ADMIN})
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
@Post("/sid/map")
public Publisher<SidInfo> lookup(@Body SidRequest sidRequest) {
if (sidRequest.fnr() != null) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/no/ssb/dlp/pseudo/service/sid/SidClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
public interface SidClient {

@Post("/sid/map")
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
Publisher<SidInfo> lookup(@Body SidRequest sidRequest);

@Post("/sid/map/batch")
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
Publisher<MultiSidResponse> lookup(@Body MultiSidRequest multiSidRequest);

@Get("/sid/snapshots")
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
Publisher<SnapshotInfo> snapshots();

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ public class SidLookupController {
@Operation(summary = "Look up missing FNRs", description = "Look FNRs that are not in the SID catalog")
@Parameter(name = "snapshot", in = ParameterIn.QUERY, description = "Snapshot date of the SID catalog version")
@Produces(MediaType.APPLICATION_JSON)
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
@Secured({PseudoServiceRole.USER, PseudoServiceRole.ADMIN})
@Post("/lookup/batch")
public Publisher<MultiSidLookupResponse> lookupMissing(@QueryValue Optional<String> snapshot, @Body MultiSidRequest req) {
return sidService.lookupMissing(req.fnrList(), snapshot);
}

@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
@Post("/map/batch")
public Publisher<Map<String, SidInfo>> lookupFnrs(@QueryValue Optional<String> snapshot, @Body MultiSidRequest req) {
return CollectionUtils.isNotEmpty(req.fnrList())
? sidService.lookupFnr(req.fnrList(), snapshot)
: sidService.lookupSnr(req.snrList(), snapshot);
}

@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
@Get("/fnr/{fnr}")
public Publisher<SidInfo> lookupFnr(@PathVariable String fnr, @QueryValue Optional<String> snapshot) {
return sidService.lookupFnr(fnr, snapshot);
}

@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
@Get("/snr/{snr}")
public Publisher<SidInfo> lookupSnr(@PathVariable String snr, @QueryValue Optional<String> snapshot) {
return sidService.lookupSnr(snr, snapshot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public HttpResponse<SidCacheInfo> getCacheInfo() {
}

@Secured({PseudoServiceRole.ADMIN})
@ExecuteOn(TaskExecutors.IO)
@ExecuteOn(TaskExecutors.BLOCKING)
@Post("/reload")
public HttpResponse<String> reloadSidCache() {
sidCacheLoader.loadSidData(null);
Expand Down

0 comments on commit 6ed069d

Please sign in to comment.