Description
Gobits is a very small module, which acts as a metadata carrier within an event-driven architecture on the Google Cloud Platform (GCP). It automatically adds fields that may be useful downstream to determine the origin of a message.
Usage
Class attributes:
class Gobits:
"""
A small class that gathers information (bits) for a pub/sub message payload.
Attributes:
_request Holds information about the cloud function request.
_context Holds information about the cloud function context.
envelope The envelope containing a pub/sub message.
message The pub/sub message to be processed.
processed Time of processing (UTC).
gcp_project The source GCP project.
execution_id The id of the execution.
execution_type Type of the service processing the message.
execution_trigger_type Type of the trigger invoking the processor.
function_name Name of the processing cloud function.
function_version Version of the processing cloud function.
event_id The id of the trigger event.
message_id The pub/sub message id.
message_publish_time Time of publishing to pub/sub (UTC).
source_subscription The originating pub/sub subscription.
"""
Cloud function with HTTP trigger:
from gobits import Gobits
def handler(request):
metadata = Gobits.from_request(request=request)
message = {
'gobits': [metadata.to_json()],
'data': []
}
Cloud function with other trigger:
from gobits import Gobits
def handler(data, context):
metadata = Gobits.from_context(context=context)
message = {
'gobits': [metadata.to_json()],
'data': []
}
Testing
Sometimes you want to test a cloud function locally. Be sure to pass mock objects containing the correct fields (if applicable).
from main import handler
from unittest.mock import Mock
mock_data = Mock()
mock_context = Mock()
mock_context.event_id = "12345678"
handler(mock_data, mock_context)
Metadata
Release files for gobits 1.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gobits-1.0.10.tar.gz | 16.3 kB | Without provenance | Details for gobits-1.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gobits-1.0.10-py3-none-any.whl | Python 3 | none | any | Details for gobits-1.0.10-py3-none-any.whl |
Total release size: 32.3 kB
Release files / gobits-1.0.10.tar.gz
| Download URL | gobits-1.0.10.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59d29811e61117c9d738a6d1d1d4697edce3844d44ccbb63c49be58e38e60c15
|
|
BLAKE2b-256 checksum How to use checksums |
0a12ad7d4708f286e575e2023e97e7d2abc022f5089e6628204a12a513195367
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / gobits-1.0.10-py3-none-any.whl
| Download URL | gobits-1.0.10-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65355a894d127c3a52a98f732b1da054d0e68ecac139c652d1e50b1f99043ff3
|
|
BLAKE2b-256 checksum How to use checksums |
47a6303ed3ecf6567bb41c9dd3e6781214aa8c501d9f3145e9924d74d2d3a7a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for gobits 1.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.