Skip to content

Instantly share code, notes, and snippets.

View rafaels88's full-sized avatar
🔮
coming up with something

Rafael Soares dos Santos rafaels88

🔮
coming up with something
View GitHub Profile
@rafaels88
rafaels88 / quiqup.opus_skip_stage.ex
Created September 13, 2018 05:11
Quiqup - Opus skip stage
defmodule Quiqup.DispatchOrderStagePipeline do
use Opus.Pipeline
# ...
skip if: :job_is_finished?
# ...
@spec job_is_finished?(map()) :: bool()
end
@rafaels88
rafaels88 / quiqup.opus_disable_module_instrumentation.ex
Created September 13, 2018 05:10
Quiqup - Opus disable module instrumentation
defmodule Quiqup.DispatchOrderStagePipeline do
use Opus.Pipeline, instrument?: false
# ...
end
@rafaels88
rafaels88 / quiqup.opus_raise_module.ex
Created September 13, 2018 05:08
Quiqup - Opus raise entire module
defmodule Quiqup.DispatchOrderStagePipeline do
use Opus.Pipeline, raise: true
# ...
end
@rafaels88
rafaels88 / quiqup.opus_pipeline_call.ex
Created September 13, 2018 05:07
Quiqup - Calling an Opus Pipeline
Quiqup.DispatchOrderStagePipeline.call(%{order: order})
@rafaels88
rafaels88 / quiqup.pipeline_instrumentation.ex
Created September 11, 2018 10:38
Quiqup - Opus Pipeline Instrumentation
defmodule PipelineInstrumentation do
def instrument(:pipeline_started, %{pipeline: Quiqup.DispatchOrderStagePipeline}, %{input: input}) do
# publish the metrics to a specific backend
end
def instrument(:stage_completed, %{stage: %{pipeline: Quiqup.DispatchOrderStagePipeline}}, %{time: time}) do
# publish the metrics to a specific backend
end
end
@rafaels88
rafaels88 / quiqup.opus_instrumentation.ex
Created September 11, 2018 10:37
Quiqup - Opus Instrumentation
defmodule Quiqup.DispatchOrderStagePipeline do
step :persist
instrument :stage_completed, %{stage: %{name: :persist}}, fn %{time: time} ->
# send to the monitoring tool of your choice
end
end
@rafaels88
rafaels88 / quiqup.opus_specific_stage.ex
Created September 11, 2018 10:36
Quiqup - Opus Specific Stage
Quiqup.DispatchOrderStagePipeline.call(%{order: order}, only: [:valid_input?])
Quiqup.DispatchOrderStagePipeline.call(%{order: order}, except: [:push_notification, :emit_event])
@rafaels88
rafaels88 / quiqup.opus_stage_options.ex
Created September 11, 2018 10:35
Quiqup - Opus Stage Options
defmodule Quiqup.DispatchOrderStagePipeline do
use Opus.Pipeline
import Quiqup.Notifier, only: [emit_event: 1]
check :valid_input?, with: &match?(%{order: _}, &1)
check :validate_order, error_message: :order_is_not_valid
step :assign_next_stage_slug, raise: true, if: :should_assign?
step :assign_courier, instrument?: false
step :persist_stage, raise: [PersistanceError]
step :push_notification, retry_times: 3, retry_backoff: fn -> lin_backoff(10, 2) |> cap(100) end
@rafaels88
rafaels88 / quiqup.opus_link2.ex
Created September 11, 2018 10:34
Quiqup - Opus Link 2
defmodule Quiqup.PersistCollectStagePipeline do
step :persist_stage
def call?(%{order: order}) do
# check stuff and return true or false
end
def persist_stage(%{order: order})
end
@rafaels88
rafaels88 / quiqup.opus_link.ex
Last active September 13, 2018 05:14
Quiqup - Opus Link