Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iamd3vil/rifle
Elixir HTTP Client Library. Wrapper over Gun (https://github.com/ninenines/gun) with connection pooling
https://github.com/iamd3vil/rifle
elixir gun http http-client http2
Last synced: 9 days ago
JSON representation
Elixir HTTP Client Library. Wrapper over Gun (https://github.com/ninenines/gun) with connection pooling
- Host: GitHub
- URL: https://github.com/iamd3vil/rifle
- Owner: iamd3vil
- License: mit
- Created: 2018-06-29T16:19:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-30T10:43:38.000Z (over 6 years ago)
- Last Synced: 2024-09-25T23:20:51.438Z (about 1 month ago)
- Topics: elixir, gun, http, http-client, http2
- Language: Elixir
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rifle
Rifle is a wrapper over [Gun](https://github.com/ninenines/gun). Rifle also provides pooling for Gun and reuses connections. Currently *WIP*
## Installation
`Rifle` is available as a Hex package. You need to add `gun`, before adding `rifle` to your `deps()` in `mix.exs`.
```elixir
defp deps do
[
{:gun, "== 1.0.0-pre.5"},
{:rifle, "~> 0.1"}
]
end
```## Usage
In `Rifle`, you need to define a service(a domain and port to connect to). Then Rifle spawns a pool of Gun connections and spreads the requests on the pool of connections. Requests can be made on a service or pool.
To create a pool, you can add this line to your supervisor.
`{Rifle, %{name: :httpbin, domain: "httpbin.org", port: 443, pool_size: 10}}`
#### Options can contain:
- `name` - This needs to be the name of the pool or service. Needs to be unique.
- `domain` - Domain of the service
- `port` - Port it needs to connect to. If `443` is provided, it will automatically use TLS.
- `pool_size` - Number of `Gun` connections to create.Adding this line will create supervisor with pool of connections.
#### For making requests:
`Rifle.get/4`, `Rifle.post/5`, `Rifle.delete/5`, `Rifle.put/5`, `Rifle.head/5`, `Rifle.options/5` or `requests/6` can be used to place requests.
## TODO
- [x] HTTP 1.1 & HTTP 2 support
- [ ] Websockets support
- [ ] Better Documentation