{"id":18116574,"url":"https://github.com/kflorence/port-manager","last_synced_at":"2026-04-28T11:05:05.684Z","repository":{"id":47143694,"uuid":"380581816","full_name":"kflorence/port-manager","owner":"kflorence","description":"Thread-safe port manager for Java/Scala.","archived":false,"fork":false,"pushed_at":"2021-09-11T23:54:25.000Z","size":30,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T10:20:43.469Z","etag":null,"topics":["java","port","scala","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kflorence.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-26T19:29:10.000Z","updated_at":"2021-09-11T23:52:11.000Z","dependencies_parsed_at":"2022-09-02T03:31:21.531Z","dependency_job_id":null,"html_url":"https://github.com/kflorence/port-manager","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kflorence/port-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kflorence%2Fport-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kflorence%2Fport-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kflorence%2Fport-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kflorence%2Fport-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kflorence","download_url":"https://codeload.github.com/kflorence/port-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kflorence%2Fport-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32377599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T09:24:15.638Z","status":"ssl_error","status_checked_at":"2026-04-28T09:24:15.071Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["java","port","scala","testing-tools"],"created_at":"2024-11-01T04:12:09.608Z","updated_at":"2026-04-28T11:05:05.662Z","avatar_url":"https://github.com/kflorence.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Port Manager\n![Release](https://github.com/kflorence/port-manager/actions/workflows/release.yaml/badge.svg)\n![Maven Central](https://img.shields.io/maven-central/v/com.kflorence/port-manager-scaladsl_2.13)\n\nThread-safe management of ports within a port bounds. The primary use-case is the reservation of static ports during integration testing. It allows the ports used by applications to be known and prevents ports from colliding across test suites.\n\n## Usage\nInclude the library as a dependency of your project (the `Test` scope is optional).\n\n```sbt\nval version = \"0.1.0\"\n\n// For Java\nval portManagerJavadsl = \"com.kflorence\" %% \"port-manager-javadsl\" % version % Test\nlibraryDependencies ++= Seq(portManagerJavadsl)\n\n// For Scala\nval portManagerScaladsl = \"com.kflorence\" %% \"port-manager-scaladsl\" % version % Test\nlibraryDependencies ++= Seq(portManagerScaladsl)\n```\n\nYou will then want to create a `PortManager` instance that is responsible for a range of ports. Generally, you can just use `StaticPortManager.Ephemeral`, which will manage the [IANA suggested ephemeral ports](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml) in the range of `49152` to `65535`. Any time your tests need a port, you can simply invoke `StaticPortManager.Ephemeral.claim()`, which will claim and return the next available port. If there are no ports left to claim, an exception will be thrown. If for some reason you need to unclaim a port, you can invoke `StaticPortManager.Ephemeral.unclaim(port)` where `port` is the port you wish to unclaim.\n\nYou can also create your own `StaticPortManager` for a specific set of ports:\n```scala\n// Using specific ports\nval portManagerSet = StaticPortManager(Set(49152, 49153, 49154, 49155))\n\n// Using a range of ports\nval portManagerRange = StaticPortManager(49155 to 50000)\n```\n\nNote that each port manager is only aware of the ports it manages. So if you use multiple, care should be taken to ensure the ports do not overlap.\n\nFor more use cases, see the [StaticPortManagerTests](./scaladsl/src/test/scala/com/kflorence/portManager/scaladsl/StaticPortManagerTests.scala).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkflorence%2Fport-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkflorence%2Fport-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkflorence%2Fport-manager/lists"}