https://github.com/antonmi/start-flowex
Examples how to start Flowex pipelines
https://github.com/antonmi/start-flowex
Last synced: over 1 year ago
JSON representation
Examples how to start Flowex pipelines
- Host: GitHub
- URL: https://github.com/antonmi/start-flowex
- Owner: antonmi
- Created: 2017-03-09T15:58:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-09T17:13:10.000Z (over 9 years ago)
- Last Synced: 2025-01-22T08:47:11.285Z (over 1 year ago)
- Language: Elixir
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# StartFlowex
### Examples how to start [Flowex](https://github.com/antonmi/flowex) pipelines
###In general there are three options:
#### 1. Start pipelines in arbitrary supervised process
```elixir
defmodule PipelineGenServer do
use GenServer
def init(_opts) do
pipeline_one = PipelineOne.start
pipeline_two = PipelineTwo.start
{:ok, %{pipeline_one: pipeline_one, pipeline_two: pipeline_two}}
end
end
```
You can also store pipeline structure in Agent or Application environment
#### 2. Start one pipeline per application. In that case pipeline supervisor will be the main supervisor in the application:
```elixir
defmodule OnePipelinePerApp do
use Application
def start(_type, _opts) do
pipeline = PipelineOne.start
Application.put_env(:start_flowex, :pipeline, pipeline)
{:ok, pipeline.sup_pid}
end
end
```
#### 3. Start several pipelines inside one application using `supervised_start` function. In that case pipeline supervisors will be placed under application supervisor:
```elixir
defmodule TwoPipelinesPerApp do
use Application
def start(_type, _opts) do
{:ok, supervisor_pid} = Supervisor.start_link([], strategy: :one_for_one, name: :multi_flowex_sup)
pipeline_one = PipelineOne.supervised_start(supervisor_pid)
pipeline_two = PipelineTwo.supervised_start(supervisor_pid)
Application.put_env(:start_flowex, :pipeline_one, pipeline_one)
Application.put_env(:start_flowex, :pipeline_two, pipeline_two)
{:ok,supervisor_pid}
end
end
```
You can play around with different cases by choosing application module in `application` function in `mix.exs` file
```elixir
def application do
[
mod: {InsideSupervisedGenServer, []}
# mod: {OnePipelinePerApp, []}
# mod: {TwoPipelinesPerApp, []}
]
end```