{"id":15056365,"url":"https://github.com/esl/opuntia","last_synced_at":"2025-04-10T04:07:39.773Z","repository":{"id":215081755,"uuid":"738054469","full_name":"esl/opuntia","owner":"esl","description":"Opuntia is a basic set of tools for traffic shaping for erlang and elixir. Because if you touch it too fast, it stings you.","archived":false,"fork":false,"pushed_at":"2024-03-08T12:19:25.000Z","size":48,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-10T04:07:32.026Z","etag":null,"topics":["elixir","erlang","shaper","traffic-shaping"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/opuntia/readme.html","language":"Erlang","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/esl.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":"2024-01-02T10:02:57.000Z","updated_at":"2024-12-31T23:23:57.000Z","dependencies_parsed_at":"2024-01-02T12:25:30.024Z","dependency_job_id":"7b6c71e9-7177-4c27-98ef-58b7d467dd06","html_url":"https://github.com/esl/opuntia","commit_stats":null,"previous_names":["esl/opuntia"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esl%2Fopuntia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esl%2Fopuntia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esl%2Fopuntia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esl%2Fopuntia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esl","download_url":"https://codeload.github.com/esl/opuntia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154986,"owners_count":21056543,"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":["elixir","erlang","shaper","traffic-shaping"],"created_at":"2024-09-24T21:50:08.015Z","updated_at":"2025-04-10T04:07:39.753Z","avatar_url":"https://github.com/esl.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `opuntia`\n\n[![Actions Status](https://github.com/esl/opuntia/actions/workflows/ci.yml/badge.svg)](https://github.com/esl/opuntia/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/esl/opuntia/branch/main/graph/badge.svg)](https://codecov.io/gh/esl/opuntia)\n[![Hex](http://img.shields.io/hexpm/v/opuntia.svg)](https://hex.pm/packages/opuntia)\n\n`opuntia` is a basic set of tools for traffic shaping for erlang and elixir\n\nIt implements the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket).\n\nThere are two ways to use it, checking availability a priori or accepting a penalisation.\n\nAfter creating a bucket\n```erl\nBucket = opuntia:new(#{bucket_size =\u003e 10, rate =\u003e 1, time_unit =\u003e millisecond, start_full =\u003e true}),\n```\nyou can either consume all tokens queued and see the suggested delay, considering that this might\nallow you to consume at once much more than the bucket size:\n```erl\n{NewShaper, Delay} = opuntia:update(Shaper, 50),\ntimer:sleep(Delay), %% Will suggest to sleep 40ms\n```\nor you can first how many tokens are available for you to consume before doing so:\n```erl\nAllowed = opuntia:peek(Shaper),\nconsume_tokens(Allowed),\n{NewShaper, 0} = opuntia:update(Shaper), %% Will suggest no delay if you were diligent and consume less that adviced\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesl%2Fopuntia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesl%2Fopuntia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesl%2Fopuntia/lists"}