Skip to content

Instantly share code, notes, and snippets.

@Charlyzzz
Created June 3, 2020 00:06
Show Gist options
  • Save Charlyzzz/c1ac60880ae16e754b02eef2e7c1d452 to your computer and use it in GitHub Desktop.
Save Charlyzzz/c1ac60880ae16e754b02eef2e7c1d452 to your computer and use it in GitHub Desktop.
defmodule ImageFinder do
use Application
def start(_type, _args) do
ImageFinder.Supervisor.start_link
end
def fetch(source_file, target_directory)
tramite = SupervisorDeTramites.spawn_link()
GenServer.call(tramite, {source_file, target_directory})
end
end
defmodule Tramite do
use GenServer
# estado? #linksDescubiertos
def handle_call({archivo, directorio}, quien, estado) do
GenServer.cast(Parser, {archivo, directorio})
{:noreply, ..., 40_000}
end
def handle_cast(:link_descubierto, estado) do
{:noreply, links_descubiertos +1 }
end
def handle_cast(:ultimo_link, estado) do
{:noreply, links_descubiertos +1 }
end
def handle_cast(:link_descargado, estado) do
end
end
# IEX
:ok = ImageFinder.fetch("sample", "out") # Bloquea
:ok = ImageFinder.fetch("sample1", "out") # Bloquea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment