Skip to content

Latest commit

 

History

History
58 lines (45 loc) · 1.89 KB

README.md

File metadata and controls

58 lines (45 loc) · 1.89 KB

Spring Cloud Function with RSocket

Expose cloud function with REST API & RSocket with R2DBC as backend.

Function signatures

  • RPC: Function<String, Mono>, Function<Mono, Mono>

public Function<String, String> uppercase() {
   return value -> value.toUpperCase();
}

public Function<Flux<String>, Flux<String>> reactiveUpperCase() {
	return flux -> flux.map(val -> val.toUpperCase());
}
  • request/stream: Function<String, Flux>
  • fire_and_forget/metadataPush: Function<String, Void>
public Consumer<Person> log() {
    return person -> {
        System.out.println("Received: " + person);
    };
}
	
public Function<Flux<?>, Mono<Void>> log() {
	return flux -> flux.map(..).filter(..).then();
}
  • channel: Function<Flux>, Flux

Demo function

@Controller
public class Greeter implements Function<String, Mono<String>> {

    @Override
    @MessageMapping("greeter")
    public Mono<String> apply(String name) {
        return Mono.just("Hello " + name);
    }
}

References