Skip to content

Commit

Permalink
Simplify examples (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r authored Sep 30, 2024
1 parent 1d1002c commit 38accc1
Show file tree
Hide file tree
Showing 34 changed files with 113 additions and 526 deletions.
6 changes: 3 additions & 3 deletions examples/digital_ocean/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from src.inngest import inngest_client
from src.inngest.client import inngest_client
from src.inngest.functions import hello

import inngest.digital_ocean
from examples import functions
from inngest.experimental.digital_ocean_simulator import DigitalOceanSimulator

main = inngest.digital_ocean.serve(
inngest_client,
functions.create_sync_functions(inngest_client),
[hello],
)

# This should not be used in production. It's just for locally running
Expand Down
3 changes: 0 additions & 3 deletions examples/digital_ocean/src/inngest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .client import inngest_client

__all__ = ["inngest_client"]
14 changes: 14 additions & 0 deletions examples/digital_ocean/src/inngest/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
def hello(
ctx: inngest.Context,
step: inngest.StepSync,
) -> str:
return "Hello world!"
14 changes: 14 additions & 0 deletions examples/django/inngest_django/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .inngest_client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
def hello(
ctx: inngest.Context,
step: inngest.StepSync,
) -> str:
return "Hello world!"
4 changes: 2 additions & 2 deletions examples/django/inngest_django/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from django.urls import path

import inngest.django
from examples import functions

from .functions import hello
from .inngest_client import inngest_client

urlpatterns = [
path("admin/", admin.site.urls),
inngest.django.serve(
inngest_client,
functions.create_sync_functions(inngest_client),
[hello],
),
]
6 changes: 3 additions & 3 deletions examples/fast_api/app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fastapi
from src.inngest import inngest_client
from src.inngest.client import inngest_client
from src.inngest.functions import hello

import inngest.fast_api
from examples import functions

app = fastapi.FastAPI()


inngest.fast_api.serve(
app,
inngest_client,
functions.create_async_functions(inngest_client),
[hello],
)
3 changes: 0 additions & 3 deletions examples/fast_api/src/inngest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .client import inngest_client

__all__ = ["inngest_client"]
3 changes: 1 addition & 2 deletions examples/fast_api/src/inngest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import inngest

logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger = logging.getLogger("uvicorn.inngest")
logger.setLevel(logging.DEBUG)

inngest_client = inngest.Inngest(app_id="fast_api_example", logger=logger)
14 changes: 14 additions & 0 deletions examples/fast_api/src/inngest/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
async def hello(
ctx: inngest.Context,
step: inngest.Step,
) -> str:
return "Hello world!"
12 changes: 5 additions & 7 deletions examples/flask/app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import flask
from src.inngest import inngest_client
from src.flask import app
from src.inngest.client import inngest_client
from src.inngest.functions import hello

import inngest.flask
from examples import functions

app = flask.Flask(__name__)


inngest.flask.serve(
app,
inngest_client,
functions.create_sync_functions(inngest_client),
[hello],
)

app.run(port=8000)
3 changes: 3 additions & 0 deletions examples/flask/src/flask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import flask

app = flask.Flask("my-app")
3 changes: 0 additions & 3 deletions examples/flask/src/inngest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .client import inngest_client

__all__ = ["inngest_client"]
4 changes: 2 additions & 2 deletions examples/flask/src/inngest/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging

import inngest
from src.flask import app

logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger = logging.getLogger(f"{app.logger.name}.inngest")
logger.setLevel(logging.DEBUG)

inngest_client = inngest.Inngest(app_id="flask_example", logger=logger)
14 changes: 14 additions & 0 deletions examples/flask/src/inngest/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
def hello(
ctx: inngest.Context,
step: inngest.StepSync,
) -> str:
return "Hello world!"
50 changes: 0 additions & 50 deletions examples/functions/__init__.py

This file was deleted.

24 changes: 0 additions & 24 deletions examples/functions/batch.py

This file was deleted.

18 changes: 0 additions & 18 deletions examples/functions/cancel.py

This file was deleted.

38 changes: 0 additions & 38 deletions examples/functions/cron.py

This file was deleted.

18 changes: 0 additions & 18 deletions examples/functions/debounce.py

This file was deleted.

18 changes: 0 additions & 18 deletions examples/functions/duplicate_step_name.py

This file was deleted.

25 changes: 0 additions & 25 deletions examples/functions/error_step.py

This file was deleted.

Loading

0 comments on commit 38accc1

Please sign in to comment.