grpc-ecosystem / grpc-spring

Spring Boot starter module for gRPC framework.
https://grpc-ecosystem.github.io/grpc-spring/
Apache License 2.0
3.46k stars 812 forks source link

Allow creation of meta annotation with @GrpcClient #991

Closed 313hemant313 closed 9 months ago

313hemant313 commented 9 months ago

As of now it is not possible to create a meta annotation with @GrpcClient("client-key").

@GrpcClient("client-key-profile-1") SameTypeStub stub

@GrpcClient("cient-key-profile-1") SameTypeStub stub

we have a requirement where based on some logic we can switch between stub of same type but with different profile (different address)

So was thinking for creating a meta annotation so that we can keep a annotation like

@CustomGrpcClient("client-key-profile-1", "PROFILE-1") @CustomGrpcClient("client-key-profile-1", "PROFILE-2")

ST-DDT commented 9 months ago

Do you have an example for this in spring boot?

313hemant313 commented 9 months ago

Sample meta annotation example:

@Target(ElementType.TYPE)
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface QueryRequest {
}
@Target(ElementType.ANNOTATION_TYPE)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@QueryRequest
@interface NextQueryRequest

 @Target(ElementType.ANNOTATION_TYPE)
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface QueryRequest {
}
@Target(ElementType.ANNOTATION_TYPE)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@QueryRequest
@interface NextQueryRequest

@GrpcClient annotation is does not have Target as ElementType.ANNOTATION_TYPE

@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface GrpcClient

Ref: https://stackoverflow.com/questions/63426869/unable-to-create-meta-annotation-for-requestbody-in-springboot

ST-DDT commented 9 months ago

If that is all that is needed, I would say: Contributions welcome.