Skip to main content

No project description provided

Project description

DJ StreamIO

Framework for making it easy to post stream updates to (stream.io)[https://getstream.io]

Installation

PyPI version

pip install dj-streamio

Configuration

1. Add streamio to INSTALLED_APPS

2. Configure your models for tracking:

e.g.:

from streamio.mixins import StreamModelMixin

class Todo(models.Model, StreamModelMixin):

    collection = 'todos'
    feed_name = 'todo'
    feed_actor_field = 'owner_id'
    feed_once_off_actions = ["create"]
    feed_related_mapping = [
        # feed_slug, model_field
        ('user', 'owner_id'),
        ('todo', 'id'),
    ]
    # a list of object_id prefixes to look for in the `object_ids` field
    # e.g.: todo.object_ids = ["foo:1", "bar:2"]
    feed_object_ids_mapping = ["foo", "bar"]
    enrichment_serializer = 'example_app.models.TodoSerializer'

Notes:

  1. We add StreamModelMixin to our model
  2. Add the various meta fields
  3. Profit

Track actions:

todo = Todo.objects.first()
todo.track_action('create')
todo.track_action('start')
todo.track_action('complete')

Add notifications:

todo = Todo.objects.first()

# note: you'll need to setup a webhook to actually handle forwarding!
# https://getstream.io/docs/#realtime-webhooks

# a combination of ways to propagate this notification (all are optional)
forward = {
    "sms": ['+27...', '+27...'],
    "inapp": ['user:1', 'user:2'], # inapp notification channels
    "email: ['jane@soap.com', 'joe@soap.com']
}

todo.add_notification(
    verb="..",
    notify=[user1.id, user2.id],
    message='hello!',
    forward = forward
)

Get Feed

todo = Todo.objects.first()
# get feed with all the defaults
todo.get_feed()

# you can set any extra args with kwargs:
# available parameters: https://getstream.io/docs/python/#retrieve
todo.get_feed({"limit": 5, "offset": 5, "enrich": False})

Low level usage

from streamio.streamio import get_client
stream = get_client() # returns a standard logged-in stream.io client
...

Note:

  • See also: StreamObject and StreamUser

TODOS:

  • Provide alternative backends (later)

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

dj-streamio-0.2.3.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file dj-streamio-0.2.3.tar.gz.

File metadata

  • Download URL: dj-streamio-0.2.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for dj-streamio-0.2.3.tar.gz
Algorithm Hash digest
SHA256 1890d959aebcd5b2831787bc8518f24496b7367e73cace7e4a7909e3cf35e101
MD5 ddd2d820ceaa781d79ffe2c7e7645396
BLAKE2b-256 333b8f0eb9f4e6e4e0dae378f454b5d7ad2be91cf8a089b8aa2b7207d5eb6bb3

See more details on using hashes here.

Supported by

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