Skip to content

Version 1.5.0 #69

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 3 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 3 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.0] - 2020-07-01
### Added
- Support `cloudevent` signature type ([#55], [#56])

## [1.5.0] - 2020-07-06
### Changed
- Framework will consume entire request before responding ([#66])

Expand Down Expand Up @@ -70,8 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release

[Unreleased]: https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v2.0.0
[Unreleased]: https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v1.5.0...HEAD
[1.5.0]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.5.0
[1.4.4]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.4.4
[1.4.3]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.4.3
[1.4.2]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.4.2
Expand All @@ -86,8 +83,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[#66]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/66
[#61]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/61
[#56]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/56
[#55]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/55
[#49]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/49
[#44]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/44
[#38]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/38
Expand Down
44 changes: 7 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pip install functions-framework
Or, for deployment, add the Functions Framework to your `requirements.txt` file:

```
functions-framework==2.0.0
functions-framework==1.5.0
```

# Quickstart: Hello, World on your local machine
Expand Down Expand Up @@ -129,57 +129,27 @@ You can configure the Functions Framework using command-line flags or environmen
| `--host` | `HOST` | The host on which the Functions Framework listens for requests. Default: `0.0.0.0` |
| `--port` | `PORT` | The port on which the Functions Framework listens for requests. Default: `8080` |
| `--target` | `FUNCTION_TARGET` | The name of the exported function to be invoked in response to requests. Default: `function` |
| `--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` or `cloudevent` |
| `--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` |
| `--source` | `FUNCTION_SOURCE` | The path to the file containing your function. Default: `main.py` (in the current working directory) |
| `--debug` | `DEBUG` | A flag that allows to run functions-framework to run in debug mode, including live reloading. Default: `False` |

# Enable CloudEvents

# Enable Google Cloud Functions Events

The Functions Framework can unmarshall incoming
Google Cloud Functions [event](https://cloud.google.com/functions/docs/concepts/events-triggers#events) payloads to `data` and `context` objects.
These will be passed as arguments to your function when it receives a request.
Note that your function must use the `event`-style function signature:

The Functions Framework can unmarshall incoming [CloudEvents](http://cloudevents.io) payloads to `data` and `context` objects. These will be passed as arguments to your function when it receives a request. Note that your function must use the event-style function signature:

```python
def hello(data, context):
print(data)
print(context)
```

To enable automatic unmarshalling, set the function signature type to `event`
using a command-line flag or an environment variable. By default, the HTTP
signature will be used and automatic event unmarshalling will be disabled.

For more details on this signature type, check out the Google Cloud Functions
documentation on
[background functions](https://cloud.google.com/functions/docs/writing/background#cloud_pubsub_example).

See the [running example](examples/cloud_run_event).

# Enable CloudEvents

The Functions Framework can unmarshall incoming
[CloudEvent](http://cloudevents.io) payloads to a `cloudevent` object.
It will be passed as an argument to your function when it receives a request.
Note that your function must use the `cloudevent`-style function signature


```python
def hello(cloudevent):
print("Received event with ID: %s" % cloudevent.EventID())
return 200
```

To enable automatic unmarshalling, set the function signature type to `cloudevent` using the `--signature-type` command-line flag or the `FUNCTION_SIGNATURE_TYPE` environment variable. By default, the HTTP signature type will be used and automatic event unmarshalling will be disabled.
To enable automatic unmarshalling, set the function signature type to `event` using the `--signature-type` command-line flag or the `FUNCTION_SIGNATURE_TYPE` environment variable. By default, the HTTP signature type will be used and automatic event unmarshalling will be disabled.

See the [running example](examples/cloud_run_cloudevents).
For more details on this signature type, check out the Google Cloud Functions documentation on [background functions](https://cloud.google.com/functions/docs/writing/background#cloud_pubsub_example).

# Advanced Examples

More advanced guides can be found in the [`examples/`](./examples/) directory. You can also find examples
on using the CloudEvent Python SDK [here](https://github.com/cloudevents/sdk-python).
More advanced guides can be found in the [`examples/`](./examples/) directory.

# Contributing

Expand Down
3 changes: 1 addition & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Python Functions Frameworks Examples

* [`cloud_run_http`](./cloud_run_http/) - Deploying an HTTP function to [Cloud Run](http://cloud.google.com/run) with the Functions Framework
* [`cloud_run_event`](./cloud_run_event/) - Deploying a [Google Cloud Functions Event](https://cloud.google.com/functions/docs/concepts/events-triggers#events) function to [Cloud Run](http://cloud.google.com/run) with the Functions Framework
* [`cloud_run_cloudevents`](./cloud_run_cloudevents/) - Deploying a [CloudEvent](https://github.com/cloudevents/sdk-python) function to [Cloud Run](http://cloud.google.com/run) with the Functions Framework
* [`cloud_run_event`](./cloud_run_event/) - Deploying a CloudEvent function to [Cloud Run](http://cloud.google.com/run) with the Functions Framework
15 changes: 0 additions & 15 deletions examples/cloud_run_cloudevents/Dockerfile

This file was deleted.

52 changes: 0 additions & 52 deletions examples/cloud_run_cloudevents/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions examples/cloud_run_cloudevents/main.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/cloud_run_cloudevents/requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion examples/cloud_run_event/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ RUN pip install gunicorn functions-framework
RUN pip install -r requirements.txt

# Run the web service on container startup.
CMD exec functions-framework --target=hello --signature_type=event
CMD exec functions-framework --target=hello --signature-type=event
3 changes: 0 additions & 3 deletions examples/cloud_run_event/README.md

This file was deleted.

3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

setup(
name="functions-framework",
version="2.0.0",
version="1.5.0",
description="An open source FaaS (Function as a service) framework for writing portable Python functions -- brought to you by the Google Cloud Functions team.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand All @@ -52,7 +52,6 @@
"click>=7.0,<8.0",
"watchdog>=0.10.0",
"gunicorn>=19.2.0,<21.0; platform_system!='Windows'",
"cloudevents<1.0",
],
entry_points={
"console_scripts": [
Expand Down
Loading