Commit f6bc4860 authored by rinpatch's avatar rinpatch

Move Myhtmlex.Safe to FastHtml.Application

parent ff232f34
......@@ -96,6 +96,7 @@ defmodule :fast_html do
"""
@spec decode(String.t(), format: [format_flag()]) :: tree()
def decode(bin, format: flags) do
Myhtmlex.Safe.decode(bin, flags)
{:ok, res} = Nodex.Cnode.call(FastHtml.Cnode, {:decode, bin, flags})
res
end
end
defmodule Myhtmlex.Safe do
defmodule FastHtml.Application do
@moduledoc false
use Application
app = Mix.Project.config()[:app]
application = Mix.Project.config()[:app]
defp random_sname, do: :crypto.strong_rand_bytes(4) |> Base.encode16(case: :lower)
defp sname, do: :"myhtmlex_#{random_sname()}"
defp sname, do: :"fasthtml_#{random_sname()}"
def start(_type, _args) do
import Supervisor.Spec
......@@ -16,24 +16,15 @@ defmodule Myhtmlex.Safe do
Nodex.Distributed.up()
end
myhtml_worker = Path.join(:code.priv_dir(unquote(app)), "myhtml_worker")
myhtml_worker = Path.join(:code.priv_dir(unquote(application)), "myhtml_worker")
children = [
worker(Nodex.Cnode, [
%{exec_path: myhtml_worker, sname: sname()},
[name: Myhtmlex.Safe.Cnode]
[name: FastHtml.Cnode]
])
]
Supervisor.start_link(children, strategy: :one_for_one, name: Myhtmlex.Safe.Supervisor)
end
def decode(bin) do
decode(bin, [])
end
def decode(bin, flags) do
{:ok, res} = Nodex.Cnode.call(Myhtmlex.Safe.Cnode, {:decode, bin, flags})
res
Supervisor.start_link(children, strategy: :one_for_one, name: FastHtml.Supervisor)
end
end
......@@ -49,12 +49,9 @@ defmodule FastHTML.Mixfile do
def application do
[
extra_applications: [:logger],
mod: {Myhtmlex.Safe, []},
mod: {FastHtml.Application, []},
# used to detect conflicts with other applications named processes
registered: [Myhtmlex.Safe.Cnode, Myhtmlex.Safe.Supervisor],
env: [
mode: Myhtmlex.Safe
]
registered: [FastHtml.Cnode, FastHtml.Supervisor]
]
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment