ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - opt-elixir/faktory_worker: Elixir Faktory worker https://hexdocs.pm/faktory_worker
Elixir Faktory worker https://hexdocs.pm/faktory_worker - opt-elixir/faktory_worker
Visit Site

GitHub - opt-elixir/faktory_worker: Elixir Faktory worker https://hexdocs.pm/faktory_worker

GitHub - opt-elixir/faktory_worker: Elixir Faktory worker https://hexdocs.pm/faktory_worker

Faktory Worker

A worker client for Faktory.

Documentation

Faktory Worker documentation is available at https://hexdocs.pm/faktory_worker.

Getting up and running

To get started with Faktory Worker first add the dependency to your mix.exs file.

defp deps do
  [
    {:faktory_worker, "~> 1.9.6"}
  ]
end

Faktory Worker can then be configured to start as part of your application by adding it to the Application.start/2 function.

defmodule MyApp.Application do
  use Application

  def start(_, _) do
    children = [
      FaktoryWorker
    ]

    Supervisor.start_link(children,
      strategy: :one_for_one,
      name: MyApp.Supervisor
    )
  end
end

Make sure you have configured your application to start in your mix.exs file.

def application do
  [
    mod: {MyApp.Application, []}
  ]
end

This will start Faktory Worker using the default configuration. For details on how to configure Faktory Worker see the FaktoryWorker documentation.

Next you can create a worker to handle job processing.

defmodule MyApp.SomeWorker do
  use FaktoryWorker.Job

  def perform(job_data) do
    do_some_work(job_data)
  end
end

Now you can start sending jobs to faktory and they will be automatically picked up by the worker.

:ok = MyApp.SomeWorker.perform_async("hey there!")

Important! Since version 1.6.1 Broadway was removed from dependencies and response from perfomr_async is tuple {:ok, job_meta} with meta information about scheduled job.

{:ok, job_meta} = MyApp.SomeWorker.perform_async("hey there!")

Sending multiple job arguments

It's possible to send more than one argument to Faktory by passing a list of data to perform_async/1. Picking up from the example in the Getting up and running section we can modify our worker by adding another perform function with an arity that matches the number of job arguments we expect to send to Faktory.

defmodule MyApp.SomeWorker do
  use FaktoryWorker.Job

  ...

  def perform(arg1, arg2) do
    do_some_work(arg1, arg2)
  end
end

With this new function in place you can now send multiple job arguments to Faktory.

:ok = MyApp.SomeWorker.perform_async(["arg 1", "arg 2"])

Configuration

The full list of configuration options are available in the Configuration documentation.

Logging

By default Faktory Worker will not output any log messages but instead emit events using the Telemetry library.

To enable the built in logging you will need to attach the default Telemetry handler provided by FaktoryWorker. The ideal place to do this is in your Application.start/2 callback.

defmodule MyApp.Application do
  use Application

  def start(_, _) do
    FaktoryWorker.attach_default_telemetry_handler()

    ...
  end
end

With this in place Faktory Worker will now output log messages for each of the events emitted.

For a full list of Faktory Worker events or for details on handling these events see the Logging documentation.

Contributing

We always appreciate contributions whether they are testing, reporting issues, feedback or submitting PRs. If you would like to work on Faktory Worker please follow the Developing section for details on how to get setup for developing and running the test suite.

Developing

Faktory Worker includes a docker compose file that provisions all of the Faktory instances required to run the test suite.

If you have docker compose installed you can run the up command from the Faktory Worker directory to start everything required.

$ docker-compose up -d
Creating faktory_worker_test          ... done
Creating faktory_worker_test_tls      ... done
Creating faktory_worker_password_test ... done

Faktory have free open-source solution and enterprise edition.

If you don't have enterprise license then tests will fail on enterprise features (batching operations etc). In this case you can exclude them by tag :enterprise

$ mix test --exclude enterprise

If you are enterprise user all tests should pass

$ mix test

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory