Skip to content

Commit

Permalink
redis first impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitolo-Andrea committed Jan 20, 2025
1 parent a99932b commit 862400c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ public Mono<ResponseEntity<CitizenConsentDTO>> deleteCitizenConsent(String fisca
@Override
public Mono<ResponseEntity<String>> bloomFilterSearch(String fiscalCode) {
return bloomFilterService.mightContain(fiscalCode)
.map(response -> response
? ResponseEntity.ok("OK")
: ResponseEntity.status(HttpStatus.ACCEPTED).body("NO CHANNELS ENABLED")
);
.map(result -> ResponseEntity.ok().body(result));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

public interface BloomFilterService {

Mono<Boolean> mightContain(String hashedFiscalCode);
Mono<String> mightContain(String hashedFiscalCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,24 @@ private RBloomFilterReactive<String> initializeBloomFilter(RedissonReactiveClien
}

public void add(String value) {
bloomFilter.add(value);
bloomFilter.add(value).doOnSuccess(result -> {
if(result)
log.info("[BLOOM-FILTER-SERVICE] Fiscal Code added to bloom filter");
else
log.info("[BLOOM-FILTER-SERVICE] Fiscal Code not added to bloom filter");
})
.subscribe();
}

public Mono<Boolean> mightContain(String value) {
return bloomFilter.contains(value);
public Mono<String> mightContain(String value) {
return bloomFilter.contains(value).map(result -> {
if (Boolean.TRUE.equals(result)) {
log.info("[BLOOM-FILTER-SERVICE] Fiscal Code found");
return "OK";
} else {
log.info("[BLOOM-FILTER-SERVICE] Fiscal Code not found");
return "NO CHANNELS ENABLED";
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public Mono<CitizenConsentDTO> createCitizenConsent(String fiscalCode, String tp
return citizenRepository
.save(citizenConsentToSave)
.map(mapperToDTO::map)
.doOnSuccess(citizenConsentSaved -> bloomFilterService.add(fiscalCode));
.doOnSuccess(citizenConsentSaved -> bloomFilterService.add(fiscalCode)
);
}))
)
.doOnSuccess(savedConsent ->
Expand Down

0 comments on commit 862400c

Please sign in to comment.