Skip to content

Commit

Permalink
fix typo with registration
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin67 committed Nov 3, 2023
1 parent 0943ff5 commit 4aa32b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
20 changes: 9 additions & 11 deletions lib/inngest/router/register.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,15 @@ defmodule Inngest.Router.Register do
defp register(path, functions, opts) do
framework = Keyword.get(opts, :framework)

payload =
%{
url: Config.app_host() <> path,
v: "1",
deployType: "ping",
sdk: Config.sdk_version(),
framework: framework,
appName: Config.app_name(),
functions: functions |> Enum.map(fn {_, v} -> v.mod.serve(path) end)
}
|> IO.inspect()
payload = %{
url: Config.app_host() <> path,
v: "0.1",
deployType: "ping",
sdk: Config.sdk_version(),
framework: framework,
appName: Config.app_name(),
functions: functions |> Enum.map(fn {_, v} -> v.mod.serve(path) end)
}

key = Inngest.Signature.hashed_signing_key(Config.signing_key())
headers = if is_nil(key), do: [], else: [authorization: "Bearer " <> key]
Expand Down
13 changes: 4 additions & 9 deletions lib/inngest/v1/function.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ defmodule Inngest.V1.Function do
alias Inngest.Config
alias Inngest.Function.Trigger

@callback id() :: binary()

@callback slug() :: binary()

@callback name() :: binary()
Expand All @@ -23,23 +21,20 @@ defmodule Inngest.V1.Function do
@behaviour Inngest.V1.Function

@impl true
def id() do
def slug() do
__MODULE__.__info__(:attributes)
|> Keyword.get(:func)
|> List.first()
|> Map.get(:id)
end

@impl true
def slug(), do: id()

@impl true
def name() do
case __MODULE__.__info__(:attributes)
|> Keyword.get(:func)
|> List.first()
|> Map.get(:name) do
nil -> id()
nil -> slug()
name -> name
end
end
Expand All @@ -57,15 +52,15 @@ defmodule Inngest.V1.Function do
id: :step,
name: "step",
runtime: %Step.RunTime{
url: "${Config.app_host() <> path}?fnId=#{id()}&step=step"
url: "#{Config.app_host() <> path}?fnId=#{slug()}&step=step"
},
retries: %Step.Retry{}
}
}

def serve(path) do
%{
id: id(),
id: slug(),
name: name(),
triggers: [trigger()],
steps: step(path),
Expand Down

0 comments on commit 4aa32b6

Please sign in to comment.