Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change approach for SDK #59

Merged
merged 29 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d9f2a01
start with ideal function structure
darwin67 Nov 2, 2023
a77a817
get dummy fn to compile
darwin67 Nov 2, 2023
2977640
delete old test functions
darwin67 Nov 2, 2023
6c86295
serve function
darwin67 Nov 3, 2023
0943ff5
add slug and mod as backward compatibility
darwin67 Nov 3, 2023
4aa32b6
fix typo with registration
darwin67 Nov 3, 2023
835a387
remove old invoke logic
darwin67 Nov 3, 2023
bb9e3af
disable some tests to get it passing for now
darwin67 Nov 3, 2023
611fb60
replace old version of function module
darwin67 Nov 3, 2023
1d9a80b
fix linter
darwin67 Nov 3, 2023
835e6c9
flatten module structure
darwin67 Nov 3, 2023
fd726b3
remove unused fields
darwin67 Nov 3, 2023
18538dc
change test function to steps
darwin67 Nov 3, 2023
095823a
rename command to exec to reduce name overload (visually)
darwin67 Nov 3, 2023
fc1604e
rename dev file
darwin67 Nov 4, 2023
9d64763
add utility function for converting map to atom keys
darwin67 Nov 4, 2023
250193a
add ctx
darwin67 Nov 4, 2023
c65c16d
move logic up
darwin67 Nov 4, 2023
340a90b
remove more calls
darwin67 Nov 4, 2023
4f3df8c
change module name
darwin67 Nov 4, 2023
8309eff
step run working but not showing step output on UI
darwin67 Nov 4, 2023
038cc82
return list of opcode
darwin67 Nov 4, 2023
96ec024
fix linter and dialyzer failures
darwin67 Nov 4, 2023
b856054
add sleep
darwin67 Nov 4, 2023
019aafd
add sleep until
darwin67 Nov 5, 2023
eafb1f9
add wait_for_event
darwin67 Nov 5, 2023
61ff0a6
add send_event
darwin67 Nov 5, 2023
1a665b8
fix based on linter
darwin67 Nov 5, 2023
58edc0f
test coverage upload
darwin67 Nov 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ jobs:
run: make deps

- name: Run tests with coverage
run: mix coveralls.github
run: mix coveralls.json
env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

formatter:
name: Formatter
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ changelog:

.PHONY: inngest-dev
inngest-dev:
inngest-cli dev -u http://127.0.0.1:4000/api/inngest
inngest-cli dev -v -u http://127.0.0.1:4000/api/inngest
63 changes: 33 additions & 30 deletions dev/event.ex
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
defmodule Inngest.Dev.EventFn do
defmodule Inngest.Dev.EventFn2 do
@moduledoc false

use Inngest.Function,
name: "test func",
event: "test/event"
use Inngest.Function
alias Inngest.{FnOpts, Trigger}

# batch_events: %{max_size: 3, timeout: "10s"}
@func %FnOpts{id: "test-func-v2", name: "test func v2"}
@trigger %Trigger{event: "test/hello"}

run "test 1st run" do
{:ok, %{run: "do something"}}
end
@impl true
def exec(ctx, %{run_id: run_id, step: step} = _args) do
IO.inspect("First log")

step "test 1st step" do
{:ok, %{hello: "world"}}
end
greet =
step.run(ctx, "hello", fn ->
"Hello world"
end)
|> IO.inspect()

sleep "2s"
step.sleep(ctx, "sleep-test", "10s")
# step.sleep(ctx, "sleep-until-test", "2023-11-05T00:12:00Z")

step "test 2nd step" do
{:ok, 100}
end
IO.inspect("Second log")

sleep "2s"
# sleep "until 1m later" do
# "2023-07-18T07:31:00Z"
# end

step "test 3rd - state accumulate" do
{:ok, %{result: "ok"}}
end
# step.wait_for_event(ctx, "wait-test", %{
# event: "test/yolo",
# timeout: "1h"
# # match: "data.foo"
# })
# |> IO.inspect()

# wait_for_event "test/wait" do
# match = "data.yo"
# [timeout: "1d", if: "event.#{match} == async.#{match}"]
# end
step.send_event(ctx, "test-event-sending", %{
name: "test/foobar",
data: %{"foo" => "bar"}
})
|> IO.inspect()

# wait_for_event "test/wait", do: [timeout: "1d", match: "data.yo"]
name =
step.run(ctx, "name", fn ->
"John Doe"
end)
|> IO.inspect()

run "result", %{data: data} do
{:ok, data}
{:ok, "#{greet} #{name}"} |> IO.inspect()
end
end
11 changes: 0 additions & 11 deletions dev/scheduled/cron.ex

This file was deleted.

5 changes: 4 additions & 1 deletion lib/inngest/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ end

defimpl Jason.Encoder, for: Inngest.Event do
def encode(value, opts) do
Jason.Encode.map(Map.from_struct(value), opts)
value
|> Map.from_struct()
|> Map.drop([:datetime])
|> Jason.Encode.map(opts)
end
end
Loading