Skip to content

Functions

Introduction

With the schmuckliCloud functions service, you are able to create custom server side code on your own system and integrate it with the cloud service. This allows you to execute code on a server side perspective. This is useful for powerful tasks, which should not run on client devices.

The functions are event-driven. That means they are executing, when a certain event on the system happens like, when someone inserts a rowset. It also can be compared to webhooks, because all the calls are handled over a HTTP call to the destination server.

Basic architecture of the functions service

In the picture above, you can see the basic architecture of the functions service. Several modules are implementing triggers, which fires events when something happening. In that event, every trigger contains a small set of metadata. This allows you to identify for example modified rowsets or which user has signed in. All that data is sent to the Function handler, this is the main process, where it detects what events are configured for each function and will send then a HTTP request to the given URL to a external system.

Once the external system responds back, it goes back to the Functions handler, where it will be forwarded to the Logging process. There it stores all the logs for at least 7 days. These logs can be viewed in the schmuckliCloud console.

Events

Events are based on a specific number. In the follwing list, you can see the complete list of events with their id number and data, which will be sent to the external system.

Event ID Event name Event specific data
1000 STORAGE_INSERT row_id The id of the inserted row.
container The container, where the row inserted.
bucket The bucket, where the container is contained.
dataset The dataset, where the data was inserted.
1001 STORAGE_UPDATE row_id The id of the updated row.
container The container, where the row updated.
bucket The bucket, where the container is contained.
dataset The dataset, where the data was updated.
1002 STORAGE_DELETE row_id The id of the deleted row.
container The container, where the row deleted.
bucket The bucket, where the container is contained.
dataset The dataset, where the data was delete.
2000 AUTH_LOGIN user_id The id of the authenticated user.
email The email of the signed in user.
2001 AUTH_REGISTER user_id The id of the registered user.
email The email of the signed in user.
lang The language of the registered user.

All these events above are also sent with a few other attributes:

Attribute Description
_secret The secret, which was generated when setting up the link to the external system.
_function_session The function session replaces the auth token from a user. Read more details below.

Function Session

A function session replaces the auth token from a user for the function specific API calling. This allows you to simply manage the data from the user, where the event has been triggered from. A function session token is only up to 10 - 20 minutes valid, when the URL has been triggered. So you have to finish the process until then.