Skip to main content

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.

Source Distribution

faastm-0.1.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

faastm-0.1.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file faastm-0.1.1.tar.gz.

File metadata

  • Download URL: faastm-0.1.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for faastm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4d8245d8fb82561aa44bd3ccf20be55bf27eeb16b5ce351b9a8571ac79cec97a
MD5 1179d37190259bdc32ad73d27cf7bd31
BLAKE2b-256 78a477407a691b3dc05a0c8e6bc30105744c771028636785a659725580f9da89

See more details on using hashes here.

File details

Details for the file faastm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: faastm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for faastm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 833ff9332165639aedd6f3ada37b9566b671b29d446b4b751b1d185f0ca323fd
MD5 fa099d3e3de7dca14e3589a196d63523
BLAKE2b-256 f8eb759c3ac944ef65c1bcff4a9e540ba8e041a269c218dd3b3221ea55e889d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page