### Connect to Beanstalkd Server with ElixirTalk Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Demonstrates how to establish a connection to a beanstalkd server using ElixirTalk. It shows the basic connection call with host and port, and mentions default values and the optional timeout parameter for the initial connection. ```elixir iex(1)> {:ok, pid} = ElixirTalk.connect('10.1.1.5', 14711) # Or with defaults: iex(1)> {:ok, pid} = ElixirTalk.connect() # With timeout: iex(1)> {:ok, pid} = ElixirTalk.connect('127.0.0.1', 11300, 5000) ``` -------------------------------- ### Tube Management Source: https://context7.com/jsvisa/elixir_talk/llms.txt Organizes jobs into named tubes (queues) with separate watching and using contexts. ```APIDOC ## Tube Management ### Description Organize jobs into named tubes (queues) with separate watching and using contexts. ### Method `ElixirTalk.use/2`, `ElixirTalk.watch/2`, `ElixirTalk.list_tubes/1`, `ElixirTalk.list_tube_used/1`, `ElixirTalk.list_tubes_watched/1`, `ElixirTalk.ignore/2` ### Endpoint N/A (Client-side operations) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pid** (pid) - Required - The process identifier of the connected beanstalkd client. - **tube_name** (binary) - Required (for `use`, `watch`, `ignore`) - The name of the tube. ### Request Example ```elixir {:ok, pid} = ElixirTalk.connect() # Use a tube for putting jobs (producer) {:using, "emails"} = ElixirTalk.use(pid, "emails") {:inserted, id} = ElixirTalk.put(pid, "send@example.com") # Watch tubes for reserving jobs (consumer) {:watching, 2} = ElixirTalk.watch(pid, "emails") {:watching, 3} = ElixirTalk.watch(pid, "notifications") # List all tubes in the system ["default", "emails", "notifications"] = ElixirTalk.list_tubes(pid) # Check currently used tube {:using, "emails"} = ElixirTalk.list_tube_used(pid) # Check watched tubes ["default", "emails", "notifications"] = ElixirTalk.list_tubes_watched(pid) # Stop watching a tube {:watching, 2} = ElixirTalk.ignore(pid, "default") # Cannot ignore last watched tube :not_ignored = ElixirTalk.ignore(pid, "notifications") ``` ### Response #### Success Response - `{:using, tube_name}` - Indicates the currently active tube for operations. - `{:watching, count}` - Indicates the number of tubes being watched. - `[tube_names]` (list) - A list of tube names. - `:not_ignored` - If the last watched tube cannot be ignored. #### Response Example ```elixir {:using, "emails"} ``` ``` -------------------------------- ### Tube Management with ElixirTalk Source: https://context7.com/jsvisa/elixir_talk/llms.txt Organizes jobs into named tubes (queues). Allows switching the current tube for producers and configuring which tubes consumers watch. Provides functions to list all tubes, the current tube, and watched tubes, as well as to ignore specific tubes. ```elixir perkembangan {:ok, pid} = ElixirTalk.connect() # Use a tube for putting jobs (producer) {:using, "emails"} = ElixirTalk.use(pid, "emails") {:inserted, id} = ElixirTalk.put(pid, "send@example.com") # Watch tubes for reserving jobs (consumer) {:watching, 2} = ElixirTalk.watch(pid, "emails") {:watching, 3} = ElixirTalk.watch(pid, "notifications") # List all tubes in the system ["default", "emails", "notifications"] = ElixirTalk.list_tubes(pid) # Check currently used tube {:using, "emails"} = ElixirTalk.list_tube_used(pid) # Check watched tubes ["default", "emails", "notifications"] = ElixirTalk.list_tubes_watched(pid) # Stop watching a tube {:watching, 2} = ElixirTalk.ignore(pid, "default") # Cannot ignore last watched tube :not_ignored = ElixirTalk.ignore(pid, "notifications") ``` -------------------------------- ### Tube Management with ElixirTalk Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Covers the management of 'tubes' (queues) within beanstalkd using ElixirTalk. This includes listing all available tubes, identifying the currently used tube, switching to a different tube, and observing how tubes are created and vanish automatically. ```elixir iex(6)> ElixirTalk.list_tubes(pid) ["default"] iex(7)> ElixirTalk.list_tube_used(pid) {:using, "default"} iex(8)> ElixirTalk.use(pid, "notDefault") {:using, "notDefault"} iex(11)> ElixirTalk.use(pid, "default") {:using, "default"} ``` -------------------------------- ### Put Job into Queue Source: https://context7.com/jsvisa/elixir_talk/llms.txt Inserts a new job into the current tube with optional priority, delay, and time-to-run parameters. ```APIDOC ## Put Job into Queue ### Description Insert a new job into the current tube with optional priority, delay, and time-to-run parameters. ### Method `ElixirTalk.put/3`, `ElixirTalk.put/4` ### Endpoint N/A (Client-side operation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pid** (pid) - Required - The process identifier of the connected beanstalkd client. - **data** (binary) - Required - The job data to be enqueued. - **options** (list of tuples, optional) - Options for the job insertion: - `pri` (integer): Priority level (0 is most urgent). - `delay` (integer): Delay in seconds before the job becomes ready. - `ttr` (integer): Time-to-run in seconds (worker timeout). ### Request Example ```elixir {:ok, pid} = ElixirTalk.connect() # Basic job insertion {:inserted, job_id} = ElixirTalk.put(pid, "hello world") # Job with priority (0 = most urgent, 4294967295 = least urgent) {:inserted, job_id} = ElixirTalk.put(pid, "urgent task", pri: 0) # Job with delay (wait 5 seconds before becoming ready) {:inserted, job_id} = ElixirTalk.put(pid, "delayed task", delay: 5) # Job with all options (priority, delay, time-to-run) {:inserted, job_id} = ElixirTalk.put(pid, "complex job", [ pri: 100, delay: 10, ttr: 120 ]) ``` ### Response #### Success Response - `{:inserted, job_id}` (tuple) - Indicates successful insertion, returning the new job ID. #### Error Response - `:job_too_big` - The job data exceeds the maximum allowed size. - `:draining` - The server is not accepting new jobs. - `{:error, reason}` - A general connection or protocol error. #### Response Example ```elixir {:inserted, 1} ``` ``` -------------------------------- ### Basic Job Operations with ElixirTalk Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Illustrates the fundamental operations for managing jobs in beanstalkd using ElixirTalk. This includes putting a new job, reserving an existing job, and deleting a finished job. It also highlights the importance of deleting jobs to prevent re-queuing. ```elixir iex(2)> ElixirTalk.put(pid, "hello world") {:inserted, 1} iex(3)> ElixirTalk.reserve(pid) {:reserved, 1, "hello world"} iex(4)> ElixirTalk.delete(pid, 1) :deleted ``` -------------------------------- ### Add ElixirTalk to Mix Dependencies Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md This code snippet shows how to add the ElixirTalk library to your project's dependencies in the `mix.exs` file. After adding this, you should run `$ mix deps.get` to fetch the dependency. ```elixir def deps do [{:elixir_talk, "~> 1.1"}] end ``` -------------------------------- ### Manage ElixirTalk Connections Source: https://context7.com/jsvisa/elixir_talk/llms.txt Handles connection lifecycle management to the job queue server. Includes connecting, performing operations, and gracefully closing connections using `quit`. Supports automatic reconnection with backoff policies. ```elixir {:ok, pid} = ElixirTalk.connect() # Perform operations ElixirTalk.put(pid, "task") {:reserved, id, data} = ElixirTalk.reserve(pid) ElixirTalk.delete(pid, id) # Close connection gracefully :ok = ElixirTalk.quit(pid) # Connection automatically reconnects on failure if reconnect: true {:ok, pid} = ElixirTalk.connect([ host: '10.1.1.5', port: 11300, reconnect: true # Auto-reconnect with 1 second backoff ]) ``` -------------------------------- ### Reserve and Process Jobs Source: https://context7.com/jsvisa/elixir_talk/llms.txt Retrieves jobs from watched tubes for processing. Supports blocking and timeout-based reservation. ```APIDOC ## Reserve and Process Jobs ### Description Retrieve jobs from watched tubes for processing. Supports blocking and timeout-based reservation. ### Method `ElixirTalk.reserve/2`, `ElixirTalk.reserve/3` ### Endpoint N/A (Client-side operation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pid** (pid) - Required - The process identifier of the connected beanstalkd client. - **timeout** (integer) - Optional - The maximum time in seconds to wait for a job. `0` for non-blocking, `:infinity` or omitted for blocking indefinitely. ### Request Example ```elixir {:ok, pid} = ElixirTalk.connect() # Reserve with infinite wait (blocks until job available) {:reserved, job_id, job_data} = ElixirTalk.reserve(pid) # Reserve with timeout (in seconds) case ElixirTalk.reserve(pid, 5) do {:reserved, job_id, job_data} -> IO.puts("Processing job #{job_id}: #{job_data}") ElixirTalk.delete(pid, job_id) :timed_out -> IO.puts("No jobs available within 5 seconds") :deadline_soon -> IO.puts("Job about to expire, extend with touch/1") end # Non-blocking reserve (timeout = 0) case ElixirTalk.reserve(pid, 0) do {:reserved, id, data} -> handle_job(id, data) :timed_out -> :no_jobs_available end ``` ### Response #### Success Response - `{:reserved, job_id, job_data}` - Indicates a job was reserved, returning its ID and data. #### Error Response - `:timed_out` - No job was available within the specified timeout. - `:deadline_soon` - The job is about to expire. #### Response Example ```elixir {:reserved, 1, "job data payload"} ``` ``` -------------------------------- ### Connect to Beanstalkd Server with ElixirTalk Source: https://context7.com/jsvisa/elixir_talk/llms.txt Establishes a TCP connection to a beanstalkd server. Supports default and custom host/port configurations, timeouts, and automatic reconnection. Returns {:ok, pid} on success or {:error, reason} on failure. ```elixir perkembangan ElixirTalk.connect() # Connect to custom server with timeout {:ok, pid} = ElixirTalk.connect('10.1.1.5', 14711, :infinity) # Connect with keyword options for advanced configuration {:ok, pid} = ElixirTalk.connect([ host: '10.1.1.5', port: 14711, recv_timeout: 5_000, connect_timeout: 5_000, reconnect: true ]) ``` -------------------------------- ### Gather ElixirTalk Statistics Source: https://context7.com/jsvisa/elixir_talk/llms.txt Provides functions to retrieve statistics at server, tube, and job levels. These metrics are essential for monitoring queue health, performance, and debugging. Statistics for non-existent resources return :not_found. ```elixir {:ok, pid} = ElixirTalk.connect() {:inserted, job_id} = ElixirTalk.put(pid, "job data") # Server-wide statistics stats = ElixirTalk.stats(pid) IO.inspect(stats) # Tube statistics tube_stats = ElixirTalk.stats_tube(pid, "default") IO.inspect(tube_stats) # Job statistics (only while job exists) job_stats = ElixirTalk.stats_job(pid, job_id) IO.inspect(job_stats) # Non-existent resources return :not_found :not_found = ElixirTalk.stats_tube(pid, "nonexistent") :not_found = ElixirTalk.stats_job(pid, 99999) ``` -------------------------------- ### Insert Job into Queue with ElixirTalk Source: https://context7.com/jsvisa/elixir_talk/llms.txt Inserts a new job into the current tube with optional priority, delay, and time-to-run parameters. Handles potential errors like job size limits or server draining. Returns {:inserted, job_id} on success or an error tuple. ```elixir perkembangan {:ok, pid} = ElixirTalk.connect() # Basic job insertion {:inserted, job_id} = ElixirTalk.put(pid, "hello world") # Job with priority (0 = most urgent) {:inserted, job_id} = ElixirTalk.put(pid, "urgent task", pri: 0) # Job with delay (wait 5 seconds before becoming ready) {:inserted, job_id} = ElixirTalk.put(pid, "delayed task", delay: 5) # Job with all options (priority, delay, time-to-run) {:inserted, job_id} = ElixirTalk.put(pid, "complex job", [ pri: 100, delay: 10, ttr: 120 ]) # Handle errors case ElixirTalk.put(pid, large_data) do {:inserted, id} -> IO.puts("Job #{id} created") :job_too_big -> IO.puts("Job exceeds max size (65535 bytes)") :draining -> IO.puts("Server not accepting new jobs") {:error, reason} -> IO.puts("Connection error: #{reason}") end ``` -------------------------------- ### Connect to Beanstalkd Server Source: https://context7.com/jsvisa/elixir_talk/llms.txt Establishes a TCP connection to a beanstalkd server. Supports custom host, port, and timeout configurations with automatic reconnection on failure. ```APIDOC ## Connect to Beanstalkd Server ### Description Establish a TCP connection to a beanstalkd server. Supports custom host, port, and timeout configurations with automatic reconnection on failure. ### Method `ElixirTalk.connect/0`, `ElixirTalk.connect/3`, `ElixirTalk.connect/1` ### Endpoint N/A (Client-side connection) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```elixir # Connect to default server (127.0.0.1:11300) {:ok, pid} = ElixirTalk.connect() # Connect to custom server with timeout {:ok, pid} = ElixirTalk.connect('10.1.1.5', 14711, :infinity) # Connect with keyword options for advanced configuration {:ok, pid} = ElixirTalk.connect([ host: '10.1.1.5', port: 14711, recv_timeout: 5_000, connect_timeout: 5_000, reconnect: true ]) ``` ### Response #### Success Response (200) `{:ok, pid}` - A process identifier for the connected client. #### Error Response `{:error, reason}` - An error tuple indicating connection failure. #### Response Example ```elixir {:ok, #PID<0.123.0>} ``` ``` -------------------------------- ### Watching and Ignoring Tubes with ElixirTalk Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Explains how to manage which tubes a client monitors for incoming jobs using ElixirTalk. This involves watching additional tubes and ignoring existing ones. It clarifies that watching and using tubes are orthogonal operations. ```elixir iex(12)> ElixirTalk.list_tubes_watched(pid) ["default"] iex(13)> ElixirTalk.watch(pid, "notDefault") {:watching, 2} iex(14)> ElixirTalk.list_tubes_watched(pid) ["default", "notDefault"] iex(15)> ElixirTalk.ignore(pid, "default") {:watching, 1} iex(16)> ElixirTalk.list_tubes_watched(pid) ["notDefault"] ``` -------------------------------- ### Inspect ElixirTalk Jobs (Peek) Source: https://context7.com/jsvisa/elixir_talk/llms.txt Allows peeking at jobs without reserving them, useful for monitoring and debugging. Supports peeking specific jobs by ID, the next ready job, the next delayed job, and buried jobs. Non-existent jobs will return :not_found. ```elixir {:ok, pid} = ElixirTalk.connect() {:inserted, job_id} = ElixirTalk.put(pid, "inspect me", delay: 30) # Peek specific job by ID {:found, job_id, "inspect me"} = ElixirTalk.peek(pid, job_id) # Peek next ready job case ElixirTalk.peek_ready(pid) do {:found, id, data} -> IO.puts("Next job: #{id}") :not_found -> IO.puts("No ready jobs") end # Peek delayed job with shortest delay case ElixirTalk.peek_delayed(pid) do {:found, id, data} -> IO.puts("Next delayed: #{id}") :not_found -> IO.puts("No delayed jobs") end # Peek buried job case ElixirTalk.peek_buried(pid) do {:found, id, data} -> IO.puts("Buried: #{id}") :not_found -> IO.puts("No buried jobs") end # Deleted or non-existent jobs return not_found :not_found = ElixirTalk.peek(pid, 99999) ``` -------------------------------- ### Reserve and Process Jobs with ElixirTalk Source: https://context7.com/jsvisa/elixir_talk/llms.txt Retrieves jobs from watched tubes for processing. Supports blocking reservations (infinite wait) and timeout-based reservations. Handles success, timeouts, and deadline soon scenarios. Jobs can be deleted upon successful processing. ```elixir perkembangan {:ok, pid} = ElixirTalk.connect() # Reserve with infinite wait {:reserved, job_id, job_data} = ElixirTalk.reserve(pid) process_job(job_data) :deleted = ElixirTalk.delete(pid, job_id) # Reserve with timeout (in seconds) case ElixirTalk.reserve(pid, 5) do {:reserved, job_id, job_data} -> IO.puts("Processing job #{job_id}: #{job_data}") ElixirTalk.delete(pid, job_id) :timed_out -> IO.puts("No jobs available within 5 seconds") :deadline_soon -> IO.puts("Job about to expire, extend with touch/1") end # Non-blocking reserve (timeout = 0) case ElixirTalk.reserve(pid, 0) do {:reserved, id, data} -> handle_job(id, data) :timed_out -> :no_jobs_available end ``` -------------------------------- ### Retrieve Tube Statistics (Elixir) Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Retrieves statistics for a given tube, identified by its name. The statistics include various command counts, job statuses (ready, reserved, buried, delayed), and tube-specific information like name and pause status. ```elixir iex(21)> ElixirTalk.stats_tube(pid, "default") %{ "cmd-delete" => 0, "cmd-pause-tube" => 0, "current-jobs-buried" => 0, "current-jobs-delayed" => 0, "current-jobs-ready" => 1, "current-jobs-reserved" => 0, "current-jobs-urgent" => 1, "current-using" => 1, "current-waiting" => 0, "current-watching" => 1, "name" => "default", "pause" => 0, "pause-time-left" => 0, "total-jobs" => 1 } ``` -------------------------------- ### Job Lifecycle Management Source: https://context7.com/jsvisa/elixir_talk/llms.txt Controls job states through release, bury, and kick operations for error handling and retry logic. ```APIDOC ## Job Lifecycle Management ### Description Controls job states through release, bury, and kick operations for error handling and retry logic. ### Method `ElixirTalk.release/3`, `ElixirTalk.bury/3`, `ElixirTalk.kick/2` ### Endpoint N/A (Client-side operations) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pid** (pid) - Required - The process identifier of the connected beanstalkd client. - **job_id** (integer) - Required - The ID of the job to manage. - **options** (list of tuples, optional) - Options for `release` and `bury`: - `pri` (integer): New priority level. - `delay` (integer): New delay in seconds. ### Request Example ```elixir {:ok, pid} = ElixirTalk.connect() {:inserted, job_id} = ElixirTalk.put(pid, "task data") {:reserved, job_id, data} = ElixirTalk.reserve(pid) # Release job back to ready queue (for retry) :released = ElixirTalk.release(pid, job_id) # Release with new priority and delay :released = ElixirTalk.release(pid, job_id, [pri: 1000, delay: 60]) # Bury job for later retrieval :buried = ElixirTalk.bury(pid, job_id) # Bury with new priority and delay :buried = ElixirTalk.bury(pid, job_id, [pri: 500, delay: 120]) # Kick jobs from the buried state # Kicks up to 10 jobs 10 = ElixirTalk.kick(pid, 10) ``` ### Response #### Success Response - `:released` - Job successfully released. - `:buried` - Job successfully buried. - `count` (integer) - Number of jobs kicked. #### Error Response Refer to beanstalkd protocol for specific error codes for these operations (e.g., `NOT_FOUND`). #### Response Example ```elixir :released ``` ``` -------------------------------- ### Retrieve Server Statistics (Elixir) Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Accesses comprehensive server-level statistics via the Connection's stats method. This includes uptime, total connections, job counts, command statistics, resource usage, and configuration details. ```elixir iex(22)> ElixirTalk.stats(pid) %{ "binlog-current-index" => 0, "binlog-max-size" => 10485760, "binlog-oldest-index" => 0, "binlog-records-migrated" => 0, "binlog-records-written" => 0, "cmd-delete" => 9, "cmd-ignore" => 15, "cmd-list-tube-used" => 3, "cmd-list-tubes" => 3, "cmd-list-tubes-watched" => 3, "cmd-peek" => 0, "cmd-peek-buried" => 0, "cmd-peek-delayed" => 0, "cmd-peek-ready" => 0, "cmd-pause-tube" => 0, "cmd-put" => 11, "cmd-release" => 0, "cmd-reserve" => 2, "cmd-reserve-with-timeout" => 2, "cmd-stats" => 3, "cmd-stats-job" => 3, "cmd-stats-tube" => 3, "cmd-touch" => 0, "cmd-use" => 16, "cmd-watch" => 19, "current-connections" => 1, "current-jobs-buried" => 0, "current-jobs-delayed" => 0, "current-jobs-ready" => 2, "current-jobs-reserved" => 0, "current-jobs-urgent" => 2, "current-producers" => 1, "current-tubes" => 2, "current-waiting" => 0, "current-workers" => 1, "id" => "def32f0744b36db5", "hostname" => "v", "job-timeouts" => 1, "max-job-size" => 65535, "pid" => 9987, "rusage-stime" => 0.014314, "rusage-utime" => 0.0, "total-connections" => 15, "total-jobs" => 10, "uptime" => 1154, "version" => "1.10+4+g96e8756" } ``` -------------------------------- ### Job Lifecycle Management with ElixirTalk Source: https://context7.com/jsvisa/elixir_talk/llms.txt Controls job states within beanstalkd for error handling and retry logic. Supports releasing jobs back to the ready queue with optional new priority and delay, burying jobs for later retrieval, and kicking jobs to make them ready. ```elixir perkembangan {:ok, pid} = ElixirTalk.connect() {:inserted, job_id} = ElixirTalk.put(pid, "task data") {:reserved, job_id, data} = ElixirTalk.reserve(pid) # Release job back to ready queue (for retry) :released = ElixirTalk.release(pid, job_id) # Release with new priority and delay :released = ElixirTalk.release(pid, job_id, [pri: 1000, delay: 60]) # Bury job (for later inspection/kicking) :buried = ElixirTalk.bury(pid, job_id) # Kick job to make it ready {:kicked, 1} = ElixirTalk.kick(pid) # Kick specific number of jobs {:kicked, 5} = ElixirTalk.kick(pid, 5) ``` -------------------------------- ### Reserved Job with Timeout in ElixirTalk Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Shows how to use the `reserve` command with a timeout in ElixirTalk. This is useful for preventing a process from blocking indefinitely while waiting for a job. A timeout of 0 will perform an immediate check. ```elixir iex(5)> ElixirTalk.reserve(pid, 5) :timed_out iex(5)> ElixirTalk.reserve(pid, 0) :timed_out ``` -------------------------------- ### Manage ElixirTalk Jobs (Bury, Kick, Touch) Source: https://context7.com/jsvisa/elixir_talk/llms.txt Functions to manage the state of jobs within the queue. Burying makes jobs unavailable, kicking makes them ready again, and touching extends their processing time. These operations are crucial for handling job failures and retries. ```elixir :buried = ElixirTalk.bury(pid, job_id) :buried = ElixirTalk.bury(pid, job_id, 1000) {:kicked, count} = ElixirTalk.kick(pid, 10) :kicked = ElixirTalk.kick_job(pid, job_id) :touched = ElixirTalk.touch(pid, job_id) ``` -------------------------------- ### Elixir Producer-Consumer Worker with Error Handling Source: https://context7.com/jsvisa/elixir_talk/llms.txt This Elixir module implements both a producer and a consumer for a task queue. The consumer processes jobs, handles success and different error types (temporary for retries, permanent for burying), and manages connection errors. The producer queues jobs with specified priorities and delays. It utilizes the ElixirTalk library for interacting with a message queue. ```elixir defmodule EmailWorker do def start_consumer do {:ok, pid} = ElixirTalk.connect('10.1.1.5', 14711) ElixirTalk.watch(pid, "emails") ElixirTalk.ignore(pid, "default") process_loop(pid) end defp process_loop(pid) do case ElixirTalk.reserve(pid) do {:reserved, job_id, email_data} -> case send_email(email_data) do :ok -> ElixirTalk.delete(pid, job_id) IO.puts("Email sent successfully: #{job_id}") {:error, :temporary} -> # Retry in 60 seconds with lower priority ElixirTalk.release(pid, job_id, [pri: 1000, delay: 60]) IO.puts("Email rescheduled: #{job_id}") {:error, :permanent} -> # Bury for manual inspection ElixirTalk.bury(pid, job_id) IO.puts("Email buried: #{job_id}") end :deadline_soon -> # Extend processing time ElixirTalk.touch(pid, job_id) {:error, reason} -> IO.puts("Connection error: #{reason}") :timer.sleep(1000) end process_loop(pid) end def start_producer do {:ok, pid} = ElixirTalk.connect('10.1.1.5', 14711) ElixirTalk.use(pid, "emails") # Queue high priority email immediately {:inserted, id1} = ElixirTalk.put(pid, "urgent@example.com", [ pri: 0, ttr: 300 ]) # Queue normal email with delay {:inserted, id2} = ElixirTalk.put(pid, "newsletter@example.com", [ pri: 1000, delay: 3600 ]) IO.puts("Queued jobs: #{id1}, #{id2}") end defp send_email(email_data) do # Email sending logic :ok end end # Start consumer in one process Task.start(fn -> EmailWorker.start_consumer() end) # Start producer in another EmailWorker.start_producer() ``` -------------------------------- ### Control ElixirTalk Tube Pausing Source: https://context7.com/jsvisa/elixir_talk/llms.txt Enables temporary pausing of job reservations from a specific tube. This is useful for maintenance or rate limiting. The pause duration is specified in seconds. Pausing a non-existent tube returns :not_found. ```elixir {:ok, pid} = ElixirTalk.connect() # Pause tube for 60 seconds (no jobs reserved during pause) :paused = ElixirTalk.pause_tube(pid, "emails", 60) # Check pause status in tube stats stats = ElixirTalk.stats_tube(pid, "emails") IO.puts("Pause time remaining: #{stats["pause-time-left"]} seconds") # Non-existent tube returns :not_found :not_found = ElixirTalk.pause_tube(pid, "nonexistent", 30) ``` -------------------------------- ### Retrieve Job Statistics (Elixir) Source: https://github.com/jsvisa/elixir_talk/blob/master/README.md Fetches statistics for a specific job identified by its ID. This function is only available while the job is active. Attempting to retrieve stats for a non-existent or deleted job will result in a ':not_found' error. ```elixir iex(20)> ElixirTalk.stats_job(pid, 26) :not_found ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.