Skip to content

linux-china/spring-cloud-function-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published