config
Your function will be given your Node's runtime configuration in the config
attribute. This attribute is a Python dict.
NOTE - this is the runtime configuration for your Node. It will be the union of your Tenant's configuration and your Node's configuration.
This can be used to get any sort of configuration that you function may require - e.g. database credentials.
For example, using a processor
function:
handle_bulk_data
You may write a function that requires the ability to store bulk data to reduce message size. Normally this will only be useful in processor
functions.
The Context object provides you easy access to the Bulk Data Storage capabilities of EchoStream via the handle_bulk_data
method. This method has the following signature:
data
: the bulk data that you wish to store. May be a bytearray, bytes or a BinaryIO objectcontentEncoding
: the compression to apply to the object when it is stored. Eitherdeflate
orgzip
. Defaults togzip
.
When called, handle_bulk_data
will take the data
you provide, compress it according to contentEncoding
, store it in your Tenant's Bulk Data Storage area, and return to you a URL that allows you to download that data.
For eaxmple, let's assume that during processing you need to call an API, retrieve a large binary object (e.g. - an image), and attach that image to the message that you forward on.
logger
Often you will want to log messages from within your function, and then subsequently have those log message made available to you (see Log monitoring).
The Context object provides you the logger
attribute to do just that. This attribute is a Python Logger object, and it must be used to log messages from within your function.
For example, using a processor
function:
node
The Context object contains the attribute node
. This is a string that is the name of the Node that is running your function.
By passing the current Node into your function (via the Context object), EchoStream enables you to write generic code that can be used across Nodes (or placed in the Function Library). Without this, your function would not know what Node it was being executed in.
This is useful if your function needs to know what Node it is operating in, either for logging or conditional processing.
For example, using a bitmapper
function:
table
As stated in the Tenant section, every Tenant is provided a DynamoDB Table to store inter-Node or inter-execution state into.
The Context object exposes this Table to your function via the table
attribute. This attribute will return to you a boto3 Table resource. The returned Table resource is thread-safe.
For example, using a processor
function:
You may use this Table in any way that you wish.
tenant
The Context object contains the attribute tenant
. This is a string that is the name of the Tenant that contains the Node that is running your function.
By passing the current Tenant into your function (via the Context object), EchoStream enables you to write generic code that can be used in one or more Tenants. Without this, your function would not know what Tenant it was being executed in.
This is useful if your function needs to know what Tenant it is operating in, either for logging or conditional processing.