I created two versions of my service. First one uses Futures, other one uses ZIO as an effect.
I have a simple method which use Future as a result effect:
def get(id: String)(implicit executionContext: ExecutionContext): Future[Data]
I also has some other version which uses ZIO[SomeEnv, SomeError, Data]:
def get(id: String): ZIO[SomeEnv, SomeError, Data]
Now, I need to create some kind of adapter which will return data from one version or another one:
def returnDataFromServiceVersion(version: Int) : ??? = {
if(version == 1) futureService.get(...)
else zioService.get(...)
}
The problem here is with returned type. I do not know how to convert ZIO into future or Future into ZIO to have common return type. I tried use ZIO.fromFuture{...} or toFuture() but it did not help.
My question is - how to create this returnDataFromServiceVersion method to use it with both services? I need to have common return type here.
Or maybe there is another way to solve this problem?