platypush.backend.http.poll

class platypush.backend.http.poll.HttpPollBackend(requests, *args, **kwargs)[source]

This backend will poll multiple HTTP endpoints/services and return events the bus whenever something new happened. Supported types: platypush.backend.http.request.JsonHttpRequest (for polling updates on a JSON endpoint), platypush.backend.http.request.rss.RssUpdates (for polling updates on an RSS feed). Example configuration:

backend.http.poll:
    requests:
        -
            # Poll for updates on a JSON endpoint
            method: GET
            type: platypush.backend.http.request.JsonHttpRequest
            args:
                url: https://host.com/api/v1/endpoint
                headers:
                    Token: TOKEN
                params:
                    updatedSince: 1m
                timeout: 5  # Times out after 5 seconds (default)
            poll_seconds: 60  # Check for updates on this endpoint every 60 seconds (default)
            path: ${response['items']}  # Path in the JSON to check for new items.
                                        # Python expressions are supported.
                                        # Note that 'response' identifies the JSON root.
                                        # Default value: JSON root.
        -
            # Poll for updates on an RSS feed
            type: platypush.backend.http.request.rss.RssUpdates
            url: http://www.theguardian.com/rss/world
            title: The Guardian - World News
            poll_seconds: 120
            max_entries: 10

Triggers: an update event for the relevant HTTP source if it contains new items. For example:

__init__(requests, *args, **kwargs)[source]
Parameters:requests (dict) – Configuration of the requests to make (see class description for examples)
run()[source]

Starts the backend thread. To be implemented in the derived classes if the loop method isn’t defined.