{"id":18003736,"url":"https://github.com/kovstas/fs2-throttler","last_synced_at":"2025-07-25T11:36:53.880Z","repository":{"id":48040594,"uuid":"382916587","full_name":"kovstas/fs2-throttler","owner":"kovstas","description":"Throttling for FS2 based on the Token bucket algorithm.","archived":false,"fork":false,"pushed_at":"2025-03-18T15:22:03.000Z","size":150,"stargazers_count":18,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-21T14:22:41.166Z","etag":null,"topics":["fs2","scala","stream","throttle","throttler","throttling"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kovstas.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-04T17:59:51.000Z","updated_at":"2025-03-18T15:22:09.000Z","dependencies_parsed_at":"2023-02-13T23:00:57.987Z","dependency_job_id":"80ac527f-8465-4db3-bbb6-dccbbf19fd8a","html_url":"https://github.com/kovstas/fs2-throttler","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovstas%2Ffs2-throttler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovstas%2Ffs2-throttler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovstas%2Ffs2-throttler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovstas%2Ffs2-throttler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kovstas","download_url":"https://codeload.github.com/kovstas/fs2-throttler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245626232,"owners_count":20646326,"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":["fs2","scala","stream","throttle","throttler","throttling"],"created_at":"2024-10-30T00:10:49.070Z","updated_at":"2025-03-26T09:32:40.737Z","avatar_url":"https://github.com/kovstas.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"FS2 Throttler\n====\n[![CI Status](https://github.com/kovstas/fs2-throttler/workflows/Build/badge.svg)](https://github.com/kovstas/fs2-throttler/actions)\n[![Maven Central](https://img.shields.io/maven-central/v/dev.kovstas/fs2-throttler_2.13.svg)](http://search.maven.org/#search%7Cga%7C1%7Cfs2-throttler)\n\n![Cats Friendly Badge](https://typelevel.org/cats/img/cats-badge-tiny.png)\n\nThrottling for [FS2](https://fs2.io) based on the [Token bucket](https://en.wikipedia.org/wiki/Token_bucket) algorithm. \n\nThis implementation supports:\n- burst in the processing of elements\n- calculates a cost for every element of the stream\n- two throttle modes (Shaping / Enforcing)\n\n## Install\n\nAdd the following to your `build.sbt` file:\n```scala\nlibraryDependencies += \"dev.kovstas\" %% \"fs2-throttler\" % Version\n```\n\n## Usage\n\nTo use the throttler, import the throttle function and apply it to your stream:\n```scala\nimport cats.effect.IO\nimport fs2.Stream\nimport scala.concurrent.duration._\nimport dev.kovstas.fs2throttler.Throttler._\n\nval stream = Stream(1, 2, 3, 4, 5)\n\nval shapedStream = stream.through(throttle(2, 1.second, Shaping))\nval enforcedStream = stream.through(throttle(2, 1.second, Enforcing))\n\nval costFunction: Int =\u003e Long = i =\u003e i.toLong\nval throttledCostStream = stream.through(throttle(2, 1.second, Shaping, costFunction))\n```\nFor more examples, please refer to the tests.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovstas%2Ffs2-throttler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkovstas%2Ffs2-throttler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovstas%2Ffs2-throttler/lists"}