     end
   end
 
-  @doc """
-  Loads pipeline settings from the named application configuration.
+  @spec from_config(Config.t) :: t
+  defp from_config(config) do
+    repo = Repo.new(config[:repo_provider], config[:repo_owner], config[:repo_name])
+    bot_name = repo.provider.whoami(config)
+    reqs =
+      repo.provider.download_merge_requests(repo, config)
+      |> Map.new(fn req -> {req.id, req} end)
 
-  Any options specified in `opts` will then override those settings.
-  """
-  @spec load_config(atom, Keyword.t) :: Config.t
-  def load_config(name, opts \\ []) when is_atom(name) do
-    _ = Logger.info "loading #{inspect name} pipeline configuration"
-
-    Config.load(:pipeline, name) |> Keyword.merge(opts)
-  end
-
-  @doc """
-  Returns the provider account's effective user identity.
-  """
-  @spec whoami(t) :: String.t
-  def whoami(pipeline) do
-    pipeline.repo.provider.whoami(pipeline.config)
-  end
-
-  @doc """
-  Initializes the pipeline's merge requests by downloading a list of the
-  repository's open MRs.
-
-  This replaces any existing MRs that were stored in the pipeline.
-  """
-  @spec init_merge_requests(t) :: t
-  def init_merge_requests(pipeline) do
-    reqs =
-      pipeline.repo.provider.download_merge_requests(pipeline.repo, pipeline.config)
-      |> Map.new(fn(req) -> {req.id, req} end)
-
-    %{pipeline | merge_requests: reqs}
+    %Pipeline{
+      config: config,
+      repo: repo,
+      bot_name: bot_name,
+      merge_requests: reqs,
+      worker: config[:worker]
+    }
   end
 
   @spec handle_comment(Comment.t, Repo.t) :: :ok

  alias Gullintanni.Comment
  alias Gullintanni.Repo
  alias Gullintanni.Worker
  require Logger

  @typedoc "The pipeline type"
  @type t ::
    %Pipeline{
      config: Config.t,
      repo: Repo.t,
      merge_requests: map,
      worker: Worker.t
    }

    end
  end

  defp via_tuple(pipeline), do: {:via, :gproc, gproc_key(pipeline)}

  @spec gproc_key(t | Repo.t | String.t) :: tuple
  defp gproc_key(%Pipeline{} = pipeline), do: gproc_key(pipeline.repo)
  defp gproc_key(%Repo{} = repo), do: gproc_key("#{repo}")
  defp gproc_key(name) when is_binary(name) do
    {:n, :l, {__MODULE__, name}}
  end

  # TODO: remove this after figuring out appropriate module interfaces
  def __whereis__(pipeline), do: :gproc.where(gproc_key(pipeline))

  # Creates a new pipeline with the given `config` settings.
  #
  # Returns `{:ok, pipeline}` if the configuration is valid, otherwise
  # `{:error, :invalid_config}`.
  @spec new(Config.t) :: {:ok, t} | {:error, :invalid_config}
  defp new(config) do
    with config = Config.parse_runtime_settings(config),
         true <- valid_config?(config),
         pipeline = from_config(config) do
      {:ok, pipeline}
    else
      _ -> {:error, :invalid_config}
    end
  end

