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:

cd clients/elixir
mix deps.get

2. Configuration

Set environment variables consumed by tests/examples:

3. Client Startup

Add the dependency to your application in mix.exs or load the provided library. Example usage inside an iex session:

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:

Priorities must be "critical" or "normal" when sending jobs.

5. Testing

The project includes integration tests:

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.