{"id":18350298,"url":"https://github.com/ollls/zio-qh2-examples","last_synced_at":"2025-04-09T23:51:18.218Z","repository":{"id":153204321,"uuid":"590262739","full_name":"ollls/zio-qh2-examples","owner":"ollls","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-06T03:08:07.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T23:51:15.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/ollls.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-18T02:03:35.000Z","updated_at":"2025-04-06T03:08:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b3223dc-1948-4ceb-86b9-0fc4e062847a","html_url":"https://github.com/ollls/zio-qh2-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollls%2Fzio-qh2-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollls%2Fzio-qh2-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollls%2Fzio-qh2-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollls%2Fzio-qh2-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ollls","download_url":"https://codeload.github.com/ollls/zio-qh2-examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131455,"owners_count":21052819,"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":[],"created_at":"2024-11-05T21:26:00.014Z","updated_at":"2025-04-09T23:51:18.211Z","avatar_url":"https://github.com/ollls.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZIO Quartz H2 Examples\n\nThis repository contains example HTTP/2 server implementations using the ZIO Quartz H2 library. Both examples demonstrate how to create a high-performance HTTP/2 server with ZIO.\n\nThis implementation leverages Linux's IO-Uring interface for significantly improved I/O performance by reducing context switches and copy operations. It requires:\n- Linux kernel 5.1 or newer for basic IO-Uring support\n- Linux kernel 5.5+ recommended for better performance features\n\nYou can check your kernel version with `uname -r`.\n\n### 3. Running the Root Project Example\n\nTo run the example in the root project:\n\n```bash\nsbt run\n```\n\nThis runs a minimal HTTP/2 server that demonstrates a simple route function with just a GET / endpoint that returns an empty OK response. It's ideal for understanding the basic structure of a ZIO Quartz H2 server without additional complexity.\n\n## Switching Between NIO and IO-Uring\n\nBy default, the server runs using Java NIO. To enable the high-performance Linux IO-Uring implementation:\n\n1. Open `src/main/scala/Run.scala`\n2. Comment out the NIO line:\n```scala\n// exitCode \u003c- new QuartzH2Server(\"localhost\", 8443, 16000, ctx).startIO(R, filter, sync = false)\n```\n3. Uncomment the IO-Uring line:\n```scala\nexitCode \u003c- new QuartzH2Server(\"localhost\", 8443, 16000, ctx).startIO_linuxOnly(1, R, filter)\n```\n\nNote that IO-Uring is only available on Linux systems with kernel version 5.1 or newer, with 5.5+ recommended for optimal performance.\n\n## Key Concepts\n\n### WebFilter with Either.cond\n\nAll examples demonstrate the use of a powerful WebFilter pattern using Scala's `Either.cond` mechanism:\n\n```scala\nval filter: WebFilter[Any] = (r: Request) =\u003e\n  ZIO.succeed(\n    Either.cond(condition, r, Response.Error(StatusCode.Forbidden))\n  )\n```\n\nThis pattern allows for elegant request filtering where:\n- If the condition evaluates to `true`, the request passes through to your routes (`Right(r)`)  \n- If the condition evaluates to `false`, the request is rejected with the specified error response (`Left(response)`)\n\nThis functional approach enables clean implementation of access control, rate limiting, authentication, or any other request filtering logic.\n\n## SSL Configuration\n\nAll examples use SSL and require a keystore file named `keystore.jks` with password \"password\" in the appropriate directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Follls%2Fzio-qh2-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Follls%2Fzio-qh2-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Follls%2Fzio-qh2-examples/lists"}