Annotation Interface GrpcClient


An annotation for fields of type Channel or subclasses of AbstractStub/gRPC client services. Also works for annotated methods that only take a single parameter of these types. Annotated fields/methods will be automatically populated/invoked by Spring.

Note: Fields/Set-Methods that are annotated with this annotation should NOT be annotated with Autowired or Inject (conflict).

Note: If you annotate an AbstractStub with this annotation the bean processing will also apply the StubTransformers in the application context. These can be used, for example, to configure CallOptions such as CallCredentials. Please note that these transformations aren't applied if you inject a Channel only.

Note: These annotation allows the specification of custom interceptors. These will be appended to the global interceptors and applied using ClientInterceptors.interceptForward(Channel, ClientInterceptor...).

Note: The constructor and bean factory injection is experimental.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the grpc client.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    A list of ClientInterceptor beans that should be used with this client in addition to the globally defined ones.
    A list of ClientInterceptor classes that should be used with this client in addition to the globally defined ones.
    boolean
    Whether the custom interceptors should be mixed with the global interceptors and sorted afterwards.
  • Element Details

    • value

      String value
      The name of the grpc client. This name will be used to get the config options for this client.

      Example: @GrpcClient("myClient") <-> grpc.client.myClient.address=static://localhost:9090

      Note: This value might also be used to check the common / alternative names in server certificate, you can overwrite this value with the security.authorityOverride property.

      Returns:
      The name of the grpc client.
    • interceptors

      Class<? extends ClientInterceptor>[] interceptors
      A list of ClientInterceptor classes that should be used with this client in addition to the globally defined ones. If a bean of the given type exists, it will be used; otherwise a new instance of that class will be created via no-args constructor.

      Note: Please read the javadocs regarding the ordering of interceptors.

      Returns:
      A list of ClientInterceptor classes that should be used.
      Default:
      {}
    • interceptorNames

      String[] interceptorNames
      A list of ClientInterceptor beans that should be used with this client in addition to the globally defined ones.

      Note: Please read the javadocs regarding the ordering of interceptors.

      Returns:
      A list of ClientInterceptor beans that should be used.
      Default:
      {}
    • sortInterceptors

      boolean sortInterceptors
      Whether the custom interceptors should be mixed with the global interceptors and sorted afterwards. Use this option if you want to add a custom interceptor between global interceptors.
      Returns:
      True, if the custom interceptors should be merged with the global ones and sorted afterwards. False otherwise.
      Default:
      false