{"id":24828183,"url":"https://github.com/felixbr/finagle-effect","last_synced_at":"2025-04-12T05:53:01.403Z","repository":{"id":57733193,"uuid":"245702917","full_name":"felixbr/finagle-effect","owner":"felixbr","description":"Wrappers around finagle clients for easy use in cats-effect applications","archived":false,"fork":false,"pushed_at":"2020-04-18T21:21:28.000Z","size":75,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T05:52:55.659Z","etag":null,"topics":["cats-effect","clients","finagle","finagle-http","finagle-thrift","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felixbr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-07T20:45:16.000Z","updated_at":"2024-05-19T12:45:59.000Z","dependencies_parsed_at":"2022-09-26T22:30:41.771Z","dependency_job_id":null,"html_url":"https://github.com/felixbr/finagle-effect","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixbr%2Ffinagle-effect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixbr%2Ffinagle-effect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixbr%2Ffinagle-effect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixbr%2Ffinagle-effect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixbr","download_url":"https://codeload.github.com/felixbr/finagle-effect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525156,"owners_count":21118616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cats-effect","clients","finagle","finagle-http","finagle-thrift","scala"],"created_at":"2025-01-30T22:51:40.423Z","updated_at":"2025-04-12T05:53:01.379Z","avatar_url":"https://github.com/felixbr.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# finagle-effect\n\n![Scala CI](https://github.com/felixbr/finagle-effect/workflows/Scala%20CI/badge.svg)\n\nWrappers around finagle clients (e.g. `finagle-http` and `finagle-thrift`), so they can easily be used \nin applications written in terms of `cats-effect` (e.g. `cats.effect.IO` or `monix.eval.Task`).\n\n## Versions\n\n`finagle-effect` depends on [`catbird`](https://github.com/travisbrown/catbird) which pins the versions of [`finagle`](https://github.com/twitter/finagle) libraries and [`cats-effect`](https://github.com/typelevel/cats-effect).\n\n| finagle-effect | Twitter OSS | cats-effect |\n|----------------|-------------|-------------|\n| 0.3.0          | 20.3.0      | 2.0.0       |\n\n## finagle-http-effect\n\n```sbt\nlibraryDependencies += \"io.github.felixbr\" %% \"finagle-http-effect\" % \u003cversion\u003e\n```\n\n### Usage Example\n\n```scala\nimport cats.effect._\nimport com.twitter.finagle.http.Request\nimport io.chrisdavenport.log4cats.Logger\nimport io.chrisdavenport.log4cats.slf4j.Slf4jLogger\nimport io.github.felixbr.finagle.core.effect.TwitterDurationConversions\nimport io.github.felixbr.finagle.http.effect.client._\n\nimport scala.concurrent.duration._\n\nobject ExampleIOApp extends IOApp with TwitterDurationConversions {\n  implicit def log: Logger[IO] = Slf4jLogger.getLogger[IO]\n\n  override def run(args: List[String]): IO[ExitCode] =\n    FinagleHttpClientBuilder[IO]\n      .withUpdatedConfig(_.withRequestTimeout(5.seconds))\n      .serviceResource(\"google.com:80\")\n      .use { googleClient =\u003e\n        for {\n          _   \u003c- log.info(s\"Sending request\")\n          res \u003c- googleClient(Request())\n          _   \u003c- log.info(s\"Received: ${res.contentString.take(200)}\")\n          _   \u003c- log.info(\"Done\")\n        } yield ExitCode.Success\n      }\n}\n```\n\n## finagle-thrift-effect\n\n```sbt\nlibraryDependencies += \"io.github.felixbr\" %% \"finagle-thrift-effect\" % \u003cversion\u003e\n```\n\n### Usage Example\n\n```scala\nimport cats.effect._\nimport io.chrisdavenport.log4cats.Logger\nimport io.chrisdavenport.log4cats.slf4j.Slf4jLogger\nimport io.github.felixbr.finagle.core.effect.{TwitterDurationConversions, TwitterFutureConversionsTo}\nimport io.github.felixbr.finagle.thrift.effect.client.FinagleThriftClientBuilder\nimport thrift.EchoService\n\nimport scala.concurrent.duration._\n\n/**\n  * `TwitterFutureConversionsTo[IO]` will try to convert `Future[A]` implicitly to `IO[A]` but in some cases the\n  * type-inference isn't good enough, so you manually have to use `futureToF` to wrap calls that return `Future[A]`.\n  *\n  * Alternatively you can also help the type-inference by adding a type-annotation like\n  * `echoService.echo(\"Hi\"): IO[String]`.\n  */\nobject ExampleThriftIOApp extends IOApp with TwitterDurationConversions with TwitterFutureConversionsTo[IO] {\n  implicit def log: Logger[IO] = Slf4jLogger.getLogger[IO]\n\n  override def run(args: List[String]): IO[ExitCode] =\n    demoThriftServerResource.use { port =\u003e // Just so we have a server to call to in this example\n\n      FinagleThriftClientBuilder[IO]\n        .withUpdatedConfig(_.withRequestTimeout(5.seconds))\n        .serviceResource[thrift.EchoService.MethodPerEndpoint](s\"localhost:$port\")\n        .use { echoClient =\u003e\n          for {\n            _   \u003c- log.info(s\"Sending request\")\n            res \u003c- futureToF(echoClient.echo(\"Hi!\")) // Here the type-inference is not clear enough, so you have to use `futureToF` or add `: IO[String]`\n            _   \u003c- log.info(s\"Received: $res\")\n            _   \u003c- log.info(\"Done\")\n          } yield ExitCode.Success\n        }\n    }\n\n  /**\n    * For demonstration purposes\n    */\n  private def demoThriftServerResource: Resource[IO, Int] = {\n    import com.twitter.finagle.Thrift\n    import com.twitter.util.Future\n\n    val port = 12345\n\n    Resource\n      .make {\n        IO {\n          Thrift.server.serveIface(s\":$port\", new EchoService.MethodPerEndpoint {\n            override def echo(input: String): Future[String] = Future.value(input)\n          })\n        }\n      }(server =\u003e server.close()) // Here the type-inference works, so you can call `.close()` as if it returned `IO`\n      .map(_.boundAddress.asInstanceOf[java.net.InetSocketAddress].getPort)\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixbr%2Ffinagle-effect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixbr%2Ffinagle-effect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixbr%2Ffinagle-effect/lists"}