Dariusz Kuc
07/06/2020, 5:53 PMfun <T : AbstractStub<*>> getClient(stubFactory: (Channel) -> T): T {
val client = stubFactory.invoke(configuredChannel)
return if (deadlineMs != null) {
// returns AbstractStub<S>
client.withDeadlineAfter(deadlineMs, TimeUnit.MILLISECONDS) as T
} else {
client
}
}
was playing around with inlining the T
but cannot get it to work
---
doing the chaining call from from the caller works as expected
val client: HelloGrpc.HelloBlockingStub = getClient { HelloGrpc.newBlockingStub(it) }.withDeadlineAfter(1000, TimeUnit.MILLISECONDS)
Joe
07/06/2020, 5:59 PMfun <T : AbstractStub<T>> getClient(stubFactory: () -> T): T {
? That should make it an AbstractStub<T>
instead of an AbstractStub<S>
Dariusz Kuc
07/06/2020, 6:01 PMDariusz Kuc
07/06/2020, 6:02 PMDariusz Kuc
07/06/2020, 6:02 PMasad.awadia
07/06/2020, 6:06 PMDariusz Kuc
07/06/2020, 6:43 PMDariusz Kuc
07/06/2020, 6:45 PMDariusz Kuc
07/06/2020, 6:45 PMDariusz Kuc
07/06/2020, 6:45 PM