Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Experimental one-cell STM for FaaS

Project description

FaaS-based STM

This is a small library that attempts to do STM to update stored state in an object-storage system.

It also interacts with the Slack API.

The whole thing works by saving external effects until the STM commit passes; at that point, the external effects are committed also.

Usage

This can be installed in a Fn-style serverless function like this:

import logging

from slacker import Text, BaseDispatch, handle, debounce

LOG = logging.getLogger(__name__)


def handler(ctx, data=None):
    LOG.debug("got request: %s", data)
    try:
        response = handle(ctx, data, bot_class=MyBot)
        LOG.debug("returning %s %s", response.status_code, response.response_data)
        return response
    except Exception as e:
        LOG.exception("something went wrong: %s", e)


class MyBot(BaseDispatch):
    @debounce(30, text=lambda t: t.ts)
    def on_message(self, srv=None, sender=None, channel=None, receivers=None, text=None):
        if text.match("hello") is not None:
            srv.broadcast(channel=channel,
                          text=Text("hello, world!"))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for faastm, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size faastm-0.1.1-py3-none-any.whl (15.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size faastm-0.1.1.tar.gz (8.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page