# Elixir Client Guide
The Elixir SDK lives in `clients/elixir`. This document describes how to connect it to a running Shirly deployment (`scheduler-api` and `scheduler-worker`) as described in `../binaries_setup.md`.
## 1. Dependencies
Ensure Erlang/OTP, Elixir, and `mix` are installed. Then:
```bash
cd clients/elixir
mix deps.get
```
## 2. Configuration
Set environment variables consumed by tests/examples:
- `SHIRLY_API_URL` (default `http://localhost:8080/api/v1`)
- `SHIRLY_API_KEY` (optional bearer token)
## 3. Client Startup
Add the dependency to your application in `mix.exs` or load the provided library. Example usage inside an iex session:
```elixir
Mix.install([
{:shirly_client, path: "./clients/elixir"}
])
alias ShirlyClient
alias ShirlyClient.Models.SubmitJobRequest
{:ok, client} =
ShirlyClient.new(
base_url: System.get_env("SHIRLY_API_URL", "http://localhost:8080/api/v1"),
api_key: System.get_env("SHIRLY_API_KEY")
)
request =
SubmitJobRequest.new(%{
priority: "critical", # optional; defaults to "normal"
payload: %{"kind" => "email", "to" => "ops@example.com"},
max_retries: 3
})
{:ok, job} = ShirlyClient.submit_job(client, request)
IO.inspect(job.job_id, label: "Job ID")
{:ok, status} = ShirlyClient.get_job_status(client, job.job_id)
IO.inspect(status.state, label: "Job State")
```
## 4. Advanced APIs
The client module mirrors Shirly’s REST surface:
- `submit_job_batch/2`
- `create_scheduled_job/2`, `delete_scheduled_job/2`
- `create_workflow/2`, `list_workflows/1`
- `list_dlq/2`, `replay_dlq/2`
- `list_workers/1`, `pause_queue/2`, `resume_queue/2`
Priorities must be `"critical"` or `"normal"` when sending jobs.
## 5. Testing
The project includes integration tests:
```bash
mix test
```
Set `SHIRLY_API_URL` and other variables to target staging or production when packaging the SDK.
Use this guide to document or publish the Elixir client for downstream users.