defmodule Medicode.ClassificationSupervisor do @moduledoc """ Supervisor responsible for classifying transcription text """ # Automatically defines child_spec/1 use DynamicSupervisor def start_link(init_arg) do DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__) end @impl true def init(_init_arg) do DynamicSupervisor.init(strategy: :one_for_one) end def start_classification(transcription_chunk) do # Shorthand to retrieve the child specification from the `child_spec/1` method of the given module. spec = { Medicode.ClassificationServer, %{chunk: transcription_chunk, name: "transcription_chunk:#{transcription_chunk.id}"} } DynamicSupervisor.start_child(__MODULE__, spec) end end