Skip to content

Instantly share code, notes, and snippets.

@juddey
Created April 17, 2018 19:34
Show Gist options
  • Save juddey/1972a5675df5047c81e7163678df0390 to your computer and use it in GitHub Desktop.
Save juddey/1972a5675df5047c81e7163678df0390 to your computer and use it in GitHub Desktop.
Transcoding first attempt
defmodule Texapp.ServiceMonitor do
@services [Texapp.ServiceMonitor.Transcoder]
defmodule Result do
defstruct score: 0, text: nil, url: nil
end
def start_link(service, query, query_ref, owner) do
service.start_link(query, query_ref, owner)
end
def compute(query, opts \\ []) do
# %{type: moment, id: the id, job_id: Transcoder job id})
services = opts[:services] || @services
IO.inspect(services)
services
|> Enum.map(&spawn_query(&1, query))
end
defp spawn_query(service, query) do
query_ref = make_ref()
opts = [service, query, query_ref, self()]
{:ok, pid} = Supervisor.start_child(Texapp.Web.AwsSupervisor, opts)
{pid, query_ref}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment