Skip to content

Commit 2a9aca9

Browse files
lucasscwcyclimse
andauthored
docs: add Info on the config page (#46)
* Add Info on the config page * docs: clean up warnings --------- Co-authored-by: Andy Méry <amery@scaleway.com>
1 parent d504c10 commit 2a9aca9

File tree

5 files changed

+59
-11
lines changed

5 files changed

+59
-11
lines changed

docs/source/configuring.rst

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,69 @@ Configuring
44
Namespace
55
---------
66

7-
The first step is to create a Serverless instance, which maps to a function namespace.
7+
The first step is to create a Serverless instance, which maps to a function namespace. All your functions will be deployed to this namespace.
88
When deploying, the `scw-serverless` CLI will look for a Serverless instance in the global scope.
99

1010
.. code-block:: python
1111
1212
import os
1313
from scw_serverless import Serverless
1414
15-
app = Serverless("my-namespace", secret={
16-
"SCW_SECRET_KEY": os.environ["SCW_SECRET_KEY"]
15+
app = Serverless(
16+
"my-namespace",
17+
env={
18+
"NON_CONFIDENTIAL_PARAMETERS": "My Param"
19+
},
20+
secret={
21+
"SCW_SECRET_KEY": os.environ["SCW_SECRET_KEY"],
22+
"MY_SECRET_KEY": os.environ["MY_SECRET_KEY"]
23+
},
1724
})
1825
1926
.. autoclass:: scw_serverless.app.Serverless
20-
:members: func, schedule, get
27+
:members: func
2128

2229
Functions
2330
---------
2431

25-
To configure your serverless functions, you can provide keyword arguments to the decorators.
32+
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.
2633

2734
.. autoclass:: scw_serverless.config.function.FunctionKwargs
2835

36+
.. code-block:: python
37+
38+
app = Serverless("example")
39+
app.func(
40+
privacy="public",
41+
env={"key": "value"},
42+
secret={"key": "value"},
43+
min_scale= 0,
44+
max_scale= 5,
45+
memory_limit= 256,
46+
timeout= 300,
47+
description= "Lores Ipsum",
48+
http_option= "enabled", # https only
49+
)
50+
def handler(event, context):
51+
# Do Things
52+
return {"body": "Hello World"}
53+
2954
Triggers
3055
--------
3156

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

3560
Cron triggers
3661
^^^^^^^^^^^^^
3762

38-
.. autoclass:: scw_serverless.triggers.cron.CronTrigger
63+
To create a function that will run periodically, you can use the `schedule` decorator.
64+
If do not want your function to be publicly available, set the privacy to `private`.
65+
66+
.. code-block:: python
67+
68+
app.schedule("0 8 * * *", privacy="private")
69+
def handler(event, context):
70+
...
71+
72+
.. autofunction:: scw_serverless.app.Serverless.schedule

docs/source/examples.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To showcase the framework and how it can used to deploy serverless applications,
77
Simple function to get you started.
88

99
:doc:`../examples/cron`
10-
Function that gets triggered periodically.
10+
A function that gets triggered periodically.
1111

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

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

2222
.. toctree::

docs/source/gateway.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
API Gateway
2+
===========
3+
4+
.. warning:: Not yet implemented.
5+
6+
Routed functions
7+
^^^^^^^^^^^^^^^^
8+
9+
.. autodocs:: scw_serverless.app.Serverless.func

docs/source/index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ No need for configuration files, the framework makes it possible to configure yo
1414
:doc:`deploying`
1515
Instructions to deploy your project with the CLI tool.
1616

17+
:doc:`gateway`
18+
Instructions to create an API gateway to manage HTTP routing to functions.
19+
1720
:doc:`examples`
1821
Examples to get you started.
1922

@@ -41,7 +44,7 @@ This includes the environment variables.
4144
Usage
4245
^^^^^
4346

44-
Annotate your Python functions with the func decorator:
47+
Annotate your Python functions with the `func` decorator:
4548

4649
.. code-block:: python
4750
@@ -70,4 +73,5 @@ To learn more about the different configuration options, check out :doc:`configu
7073

7174
configuring
7275
deploying
76+
gateway
7377
examples

scw_serverless/config/function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class FunctionKwargs(TypedDict, total=False):
4343
:param http_option: Either "enabled" or "redirected".
4444
If "redirected" (default), allow http traffic to your function.
4545
Blocked otherwise.
46+
4647
.. seealso::
4748
4849
Scaleway Developers Documentation

0 commit comments

Comments
 (0)