Skip to content

Instantly share code, notes, and snippets.

Emerson Macedo emerleite

Block or report user

Report or block emerleite

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View elixir_brasil.md

Título

s/Serviço TCP de 15 anos/Serviço HTTP em Elixir/g - Backend de anúncios da OLX

Abstract

Nessa apresentação, você vai conhecer os desafios que tivemos na OLX para substituir um serviço TCP de mais de 15 anos, cheio de memory leaks com um database legado, gigante e de modelagem complexa por um serviço Elixir com Banco de dados novo e sem nenhuma interrupção do serviço ou um Big Bang.

Informações complementares / Further details

É uma apresentação de uma arquitetura e detalhes de codificação/implementação muito interessantes. O famoso trocar o pneu do carro com o carro andando, sem perder velocidade, sem tremer o volante e sem freadas bruscas :) Problemas de encoding do banco velho, endpoint antigo confuso, cheio de parâmetros que não se sabia pra que servia, functions do postgres confusas, dentre outros desafios como usar 2 ECTOS, Querys usando Schema e Queries diretas chamando functions, etc. Além de uma arquitetura de CQRS. Em fim, imperdível :p

View keybase.md

Keybase proof

I hereby claim:

  • I am emerleite on github.
  • I am emerleite (https://keybase.io/emerleite) on keybase.
  • I have a public key ASDB6-VoRERcUdEq0htm7oQQEiBdnR6n5odIALzEfGzuFgo

To claim this, I am signing this object:

View decode.txt
Operating System: macOS"
CPU Information: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Number of Available Cores: 8
Available memory: 16 GB
Elixir 1.7.0-dev
Erlang 21.0
Benchmark suite executing with the following configuration:
warmup: 5 s
time: 30 s
@emerleite
emerleite / 1-README.md
Created Oct 9, 2018 — forked from tonytonyjan/1-README.md
Remote React Components Loading
View on_conflict.ex
defmodule Upa.VideoWatchProgress do
def save(attrs) do
struct(Upa.VideoWatchProgress, attrs)
|> changeset
|> Upa.Repo.insert(on_conflict: insert_conflict_strategy(attrs))
|> case do
{:error, _} = error -> raise Upa.DatabaseCommandError
{:ok, changeset} -> :ok
end
end
View event_consumer.ex
defmodule UpaEventSourcing.VideoWatchProgress.EventAggregator do
def start_link(event) do
Task.start_link(fn ->
Upa.VideoWatchProgress.save(event) #Saves to the database
end)
end
end
defmodule UpaEventSourcing.VideoWatchProgress.EventConsumer do
use ConsumerSupervisor
View application.ex
children = [
worker(UpaEventSourcing.VideoWatchProgress.EventStore, []),
worker(UpaEventSourcing.VideoWatchProgress.EventConsumer, [
%{producer: UpaEventSourcing.VideoWatchProgress.EventStore,
processor: UpaEventSourcing.VideoWatchProgress.EventAggregator}
])
]
View config.exs
config :upa, video_watch_progress_min_demand: 1
config :upa, video_watch_progress_max_demand: 192
config :upa, Upa.Repo,
adapter: Ecto.Adapters.MySQL,
hostname: "host.example.com",
database: "our_database",
username: "${MYSQL_USR}",
password: "${MYSQL_PWD}",
pool_size: 48
View event_store.ex
defmodule UpaEventSourcing.VideoWatchProgress.EventStore do
use GenStage
@event_processing_timeout 11 #Max seconds to process a track video watch progress event
def start_link() do
@emerleite
emerleite / video_watch_progress_controller.ex
Last active Feb 2, 2018
VideoWatchProgressController
View video_watch_progress_controller.ex
#Phoenix Action
def track_time(conn, params) do
RequestParamsHandler.prepare(conn, params)
|> EventStore.enqueue #Send to GenStage pipeline
send_resp(conn, 201, "")
end
You can’t perform that action at this time.