Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

YM YEMEAC

🎯
Focusing
Block or report user

Report or block YEMEAC

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@YEMEAC
YEMEAC / consulAddRemoveService.json
Created Oct 5, 2018
register and delete service in consul with curl
View consulAddRemoveService.json
curl -X PUT \
http://127.0.0.1:8500/v1/catalog/register \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: 9aa3163f-31b9-8c8f-f9cd-6feaca81d4ce' \
-d '{
"Datacenter": "dc1",
"Node": "externalServices",
"Address": "172.30.50.59",
"Service": {
@YEMEAC
YEMEAC / ReactiveIf2.java
Created Oct 2, 2018
Wanted to throw an exception using Reactive Spring only if username a new user wanted to have was being used for someone what was't him
View ReactiveIf2.java
private Mono<UserDto> validateUpdate(Long partyId, UserDto request) {
return partyClient.getIndividual(partyId)
.flatMap(r -> securityClient.getByUserName(request.getUsername()))
.switchIfEmpty(Mono.just(UserModel.builder().withId(partyId).build())) //dummy to have something to compare with and kee the reactive flow "flowing"
.flatMap(r -> {
if (!r.getId().equals(partyId)) {
throw new UserAlreadyExistsException("Username already taken");
}
return Mono.just(request);
}
@YEMEAC
YEMEAC / ReactiveIf.java
Last active Oct 16, 2018
Wanted to throw an exception using Reactive Spring only if a service call had results, also a good trick to add your on function directly in a map
View ReactiveIf.java
private Mono<UserDto> validateUserNameAvailable(UserDto user) {
Mono<Boolean> result = securityClient.getByUserName(user.getUserName()).hasElement();
return result.flatMap(value -> {
if (value) {
throw new UserAlreadyExistsException(
String.format("User {} already exists", user.getUserName()));
}
return Mono.just(user);
});
}
You can’t perform that action at this time.