Skip to content

Commit

Permalink
Add methodInfoResolver attribute to Coroutinebuilder (#1762)
Browse files Browse the repository at this point in the history
* Add methodInfoResolver attribute to Coroutinebuilder

Work on the [feedback](#1754 (comment)) of PR #1754
  • Loading branch information
wplong11 authored Sep 20, 2022
1 parent db378eb commit 951083f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kotlin/src/main/java/feign/kotlin/CoroutineFeign.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import feign.BaseBuilder;
import feign.Client;
import feign.Experimental;
import feign.MethodInfoResolver;
import feign.Target;
import feign.Target.HardCodedTarget;
import java.lang.reflect.InvocationHandler;
Expand Down Expand Up @@ -116,6 +117,7 @@ public static class CoroutineBuilder<C> extends BaseBuilder<CoroutineBuilder<C>>
private AsyncContextSupplier<C> defaultContextSupplier = () -> null;
private AsyncClient<C> client = new AsyncClient.Default<>(
new Client.Default(null, null), LazyInitializedExecutorService.instance);
private MethodInfoResolver methodInfoResolver = KotlinMethodInfo::createInstance;

@Deprecated
public CoroutineBuilder<C> defaultContextSupplier(Supplier<C> supplier) {
Expand All @@ -133,6 +135,11 @@ public CoroutineBuilder<C> defaultContextSupplier(AsyncContextSupplier<C> suppli
return this;
}

public CoroutineBuilder<C> methodInfoResolver(MethodInfoResolver methodInfoResolver) {
this.methodInfoResolver = methodInfoResolver;
return this;
}

public <T> T target(Class<T> apiType, String url) {
return target(new HardCodedTarget<>(apiType, url));
}
Expand Down Expand Up @@ -167,7 +174,7 @@ public CoroutineFeign<C> build() {
.responseInterceptor(responseInterceptor)
.invocationHandlerFactory(invocationHandlerFactory)
.defaultContextSupplier((AsyncContextSupplier<Object>) defaultContextSupplier)
.methodInfoResolver(KotlinMethodInfo::createInstance)
.methodInfoResolver(methodInfoResolver)
.build();
return new CoroutineFeign<>(asyncFeign);
}
Expand Down

0 comments on commit 951083f

Please sign in to comment.