Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stocks29/graphex
A task graph execution library for elixir
https://github.com/stocks29/graphex
Last synced: 16 days ago
JSON representation
A task graph execution library for elixir
- Host: GitHub
- URL: https://github.com/stocks29/graphex
- Owner: stocks29
- License: mit
- Created: 2015-07-26T19:13:29.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-14T01:17:31.000Z (about 9 years ago)
- Last Synced: 2024-11-11T20:44:13.183Z (about 1 month ago)
- Language: Elixir
- Size: 148 KB
- Stars: 12
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-elixir - graphex - A library for composing and executing task graphs in elixir. [Docs](https://hexdocs.pm/graphex) (Algorithms and Data structures)
- awesome-elixir - graphex - A library for composing and executing task graphs in elixir. (Algorithms and Data structures)
README
Graphex
=======[![Build Status](https://travis-ci.org/stocks29/graphex.svg)](https://travis-ci.org/stocks29/graphex)
A library for composing and executing task graphs in elixir.
### Add as Dependency
```elixir
{:graphex, "~> 0.2.1"}
```Also, be sure to add `:graphex` to your application's list of OTP applications since it has a supervision tree that must be started before using the library.
## Usage
Each node is represented by a separate process so tasks will run in parallel if possible.
```elixir
incr = fn node ->
fn r -> r[node] + 1
endresult = exec_graph :e, [
[name: :a, fun: fn _ -> 0 end],
[name: :b, fun: incr.(:a), deps: [:a]],
[name: :c, fun: incr.(:b), deps: [:b]],
[name: :d, fun: incr.(:b), deps: [:b]],
[name: :e, fun: incr.(:c), deps: [:c]],
]assert result == 3
```## Errors and Retries
Each node can be automatically retried if the function causes the process to die. In order to automatically retry, just set the `:tries` attribute to a number greater than 1.
```elixir
[name: :b, fun: &something_that_might_error/0, deps: [:some_data], tries: 3],
```This would automatically retry vertex `:b` up to 3 times.
If the node fails all tries, it will publish `{:error, {:graphex, some_error}}` to all of the nodes that depend on it. The dependent nodes can then either continue their processing or simply return an error which will be passed along to the nodes which depend on it.