Skip to content

Add Info on the config page #46

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

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
docs: clean up warnings
  • Loading branch information
cyclimse committed Mar 8, 2023
commit 21d9fd14228e6754157943ecda270898f906f89e
26 changes: 17 additions & 9 deletions docs/source/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ When deploying, the `scw-serverless` CLI will look for a Serverless instance in
secret={
"SCW_SECRET_KEY": os.environ["SCW_SECRET_KEY"],
"MY_SECRET_KEY": os.environ["MY_SECRET_KEY"]
},
gateway_domains=["app.example.com"]
},
})

.. autoclass:: scw_serverless.app.Serverless
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I don't know how we could Highlight that the func() method creates the endpoints
  • get() along with the other method should be described in a full section with details on the API gateway config

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a really brilliant idea, it makes sense to group everything API-gateway related into a single big config chapter. Thanks a lot for the suggestion.

:members: func, schedule, get
:members: func

Functions
---------

To configure your serverless functions, you can provide keyword arguments to the decorators. The Function name that will appear in Scaleway console will be the name of your the function's handler.
To configure your serverless functions, you can provide keyword arguments to the decorators. The Function name that will appear in Scaleway console will be the name of your function's handler.

.. autoclass:: scw_serverless.config.function.FunctionKwargs

Expand All @@ -46,19 +45,28 @@ To configure your serverless functions, you can provide keyword arguments to the
memory_limit= 256,
timeout= 300,
description= "Lores Ipsum",
http_option= "enabled" #https only
http_option= "enabled", # https only
)
def handler(event, context):
# Do Things
return {"message": "Hello World"}
return {"body": "Hello World"}

Triggers
--------

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Cron trigger:

  • Is the function private by default ?
  • What is the difference between cron and the schedule() Method in the App object ?
  • Add an example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No, I think it will be made public currently if you don't specify. That doesn't make a lot of sense indeed for crons. I will change it so that @app.schedule() returns sets the privacy to private if not specified.
  • The CronTrigger class can be passed to the @app.schedule() instead of a string. The only benefit of that is to pass a name in addition to the cron schedule.

I don't know why the CronTrigger section only talks about this class because ultimately we want people to use @app.schedule("0 1 * * * *") to make their crons and not @app.func(triggers=[CronTrigger(schedule="0 1 * * * *")], name="toto") I will update the docs to reflect this.

I really the idea of adding the examples directly into the docs as you did, it's really nice 💯

By default, Scaleway Functions are given an http endpoint that can be called to execute your function.
In addition, you can set up additionnal triggers that will run your function on specific occasions.
By default, Scaleway Functions are given an HTTP endpoint that can be called to execute your function.
In addition, you can set up additional triggers that will run your function on specific occasions.

Cron triggers
^^^^^^^^^^^^^

.. autoclass:: scw_serverless.triggers.cron.CronTrigger
To create a function that will run periodically, you can use the `schedule` decorator.
If do not want your function to be publicly available, set the privacy to `private`.

.. code-block:: python

app.schedule("0 8 * * *", privacy="private")
def handler(event, context):
...

.. autofunction:: scw_serverless.app.Serverless.schedule
4 changes: 2 additions & 2 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To showcase the framework and how it can used to deploy serverless applications,
Simple function to get you started.

:doc:`../examples/cron`
Function that gets triggered periodically.
A function that gets triggered periodically.

:doc:`../examples/multiple_modules`
An application with multiple handlers organized in different modules.
Expand All @@ -16,7 +16,7 @@ To showcase the framework and how it can used to deploy serverless applications,
A GitHub action workflow to deploy your application with `scw_serverless`.

:doc:`../examples/pr_notifier`
A Slack bot which alerts on incoming pull requests.
A Slack bot that alerts on incoming pull requests.
It showcases many features of the framework.

.. toctree::
Expand Down
9 changes: 9 additions & 0 deletions docs/source/gateway.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
API Gateway
===========

.. warning:: Not yet implemented.

Routed functions
^^^^^^^^^^^^^^^^

.. autodocs:: scw_serverless.app.Serverless.func
6 changes: 5 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ No need for configuration files, the framework makes it possible to configure yo
:doc:`deploying`
Instructions to deploy your project with the CLI tool.

:doc:`gateway`
Instructions to create an API gateway to manage HTTP routing to functions.

:doc:`examples`
Examples to get you started.

Expand Down Expand Up @@ -41,7 +44,7 @@ This includes the environment variables.
Usage
^^^^^

Annotate your Python functions with the func decorator:
Annotate your Python functions with the `func` decorator:

.. code-block:: python

Expand Down Expand Up @@ -70,4 +73,5 @@ To learn more about the different configuration options, check out :doc:`configu

configuring
deploying
gateway
examples
1 change: 1 addition & 0 deletions scw_serverless/config/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class FunctionKwargs(TypedDict, total=False):
:param http_option: Either "enabled" or "redirected".
If "redirected" (default), allow http traffic to your function.
Blocked otherwise.

.. seealso::

Scaleway Developers Documentation
Expand Down