@@ -4,6 +4,7 @@ import cats.effect.IO
44import fs2 .Stream
55import test .TestServer
66import test .TestClient
7+ import test .WeatherService
78import weaver ._
89import smithy4s .kinds .FunctorAlgebra
910import cats .syntax .all ._
@@ -13,6 +14,8 @@ import jsonrpclib.fs2._
1314import test .GreetOutput
1415import io .circe .Encoder
1516import test .GreetInput
17+ import test .GetWeatherOutput
18+ import test .GetWeatherInput
1619import test .NotWelcomeError
1720import io .circe .Decoder
1821import smithy4s .Service
@@ -178,4 +181,36 @@ object TestServerSpec extends SimpleIOSuite {
178181 }
179182 }
180183 }
184+
185+ testRes(" accessing endpoints from multiple servers" ) {
186+ class WeatherServiceImpl () extends WeatherService [IO ] {
187+ override def getWeather (city : String ): IO [GetWeatherOutput ] = IO (GetWeatherOutput (" sunny" ))
188+ }
189+
190+ for {
191+ clientSideChannel <- setupAux(
192+ None ,
193+ channel => {
194+ val testClient = ClientStub (TestClient , channel)
195+ Seq (AlgebraWrapper (new ServerImpl (testClient)), AlgebraWrapper (new WeatherServiceImpl ()))
196+ },
197+ _ => Seq .empty
198+ )
199+ greetResult <- {
200+ implicit val inputEncoder : Encoder [GreetInput ] = CirceJsonCodec .fromSchema
201+ implicit val outputDecoder : Decoder [GreetOutput ] = CirceJsonCodec .fromSchema
202+ val remoteFunction = clientSideChannel.simpleStub[GreetInput , GreetOutput ](" greet" )
203+ remoteFunction(GreetInput (" Bob" )).toStream
204+ }
205+ getWeatherResult <- {
206+ implicit val inputEncoder : Encoder [GetWeatherInput ] = CirceJsonCodec .fromSchema
207+ implicit val outputDecoder : Decoder [GetWeatherOutput ] = CirceJsonCodec .fromSchema
208+ val remoteFunction = clientSideChannel.simpleStub[GetWeatherInput , GetWeatherOutput ](" getWeather" )
209+ remoteFunction(GetWeatherInput (" Warsaw" )).toStream
210+ }
211+ } yield {
212+ expect.same(greetResult.message, " Hello Bob" ) &&
213+ expect.same(getWeatherResult.weather, " sunny" )
214+ }
215+ }
181216}
0 commit comments