9.4 Calling Functions with FunctionClient

Micronaut provides support for invoking functions (either locally or deployed to a cloud provider) directly within the application context. To use the features described in this section, you will need to have the function-client dependency on your classpath.

  1. implementation("io.micronaut:micronaut-function-client")
  1. <dependency>
  2. <groupId>io.micronaut</groupId>
  3. <artifactId>micronaut-function-client</artifactId>
  4. </dependency>
Using the CLI

If you are creating your project using the Micronaut CLI’s create-function command, the function-client dependency is included by default.

The developer’s primary use of this feature will be in defining interfaces that are annotated with FunctionClient. When this annotation is applied, methods on the interface will become invokers of respective methods on the remote (or local) function associated with the interface.

In addition, the function-client works together with Micronaut’s Service Discovery functionality, identifying any functions that are registered with the current service discovery provider and making them available to the client application.