datasette-events-forward


Namedatasette-events-forward JSON
Version 0.1a1 PyPI version JSON
download
home_page
SummaryForward Datasette events to another instance
upload_time2024-02-20 21:56:05
maintainer
docs_urlNone
authorSimon Willison
requires_python>=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # datasette-events-forward

[![PyPI](https://img.shields.io/pypi/v/datasette-events-forward.svg)](https://pypi.org/project/datasette-events-forward/)
[![Changelog](https://img.shields.io/github/v/release/datasette/datasette-events-forward?include_prereleases&label=changelog)](https://github.com/datasette/datasette-events-forward/releases)
[![Tests](https://github.com/datasette/datasette-events-forward/actions/workflows/test.yml/badge.svg)](https://github.com/datasette/datasette-events-forward/actions/workflows/test.yml)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/datasette/datasette-events-forward/blob/main/LICENSE)

Forward Datasette events to another instance

## Installation

Install this plugin in the same environment as Datasette.
```bash
datasette install datasette-events-forward
```

## Configuration

Configure the plugin like so:

```json
{
    "plugins": {
        "datasette-events-forward": {
            "api_token": "***",
            "api_url": "https://stats.datasette.cloud/data/-/create",
            "instance": "localhost"
        }
    }
}
```
The plugin will then gather all events and forward them to the specified instance, adding them to a table called `datasette_events` which will be created if it does not exist.

The `instance` key can be used to differentiate different instances that report to the same backend. Events are identified with a ULID to ensure they are unique even across different instances.

Events are forwarded in batches of up to 10, no more than once every 10 seconds.

Full list of configuration settings:

- `api_url`: The write API URL of a Datasette instance to forward the events to.
- `api_token`: The API token to use when sending events. Use `{"$env": "FORWARD_TOKEN"}` to read the token from the `FORWARD_TOKEN` environment variable.
- `instance`: A string to identify the instance that is sending the events.

The `api_url` can be either a `https://datasette.example.com/data/datasette_events/-/insert` endpoint for inserting rows, or a `https://datasette.example.com/data/-/create` endpoint for creating a table and inserting rows into it. If the table does not yet exist you should use the `/-/create` variant, otherwise use the `/-/insert` variant.

If you use `/-/insert` your API token just needs `insert-row` permissions. For `/-/create` you will need `create-table` permissions as well.

And to control the rate at which batches of events are sent to the Datasette write API:

- `batch_limit`: The number of events to send in each batch, defaults to 10. The Datasette write API has a 100 row limit by default so this should be set to a value less than that.
- `max_rate`: The maximum number of deliver HTTP requests to send in the specified time period, defaults to 1.
- `time_period`: The time period for the rate limiting in seconds, defaults to 10.

## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd datasette-events-forward
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "datasette-events-forward",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Simon Willison",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/d6/ac/7b151bd9c7d60f3da859483d2212cfc87e9703628e8ba8753b9489ae42f2/datasette-events-forward-0.1a1.tar.gz",
    "platform": null,
    "description": "# datasette-events-forward\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-events-forward.svg)](https://pypi.org/project/datasette-events-forward/)\n[![Changelog](https://img.shields.io/github/v/release/datasette/datasette-events-forward?include_prereleases&label=changelog)](https://github.com/datasette/datasette-events-forward/releases)\n[![Tests](https://github.com/datasette/datasette-events-forward/actions/workflows/test.yml/badge.svg)](https://github.com/datasette/datasette-events-forward/actions/workflows/test.yml)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/datasette/datasette-events-forward/blob/main/LICENSE)\n\nForward Datasette events to another instance\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n```bash\ndatasette install datasette-events-forward\n```\n\n## Configuration\n\nConfigure the plugin like so:\n\n```json\n{\n    \"plugins\": {\n        \"datasette-events-forward\": {\n            \"api_token\": \"***\",\n            \"api_url\": \"https://stats.datasette.cloud/data/-/create\",\n            \"instance\": \"localhost\"\n        }\n    }\n}\n```\nThe plugin will then gather all events and forward them to the specified instance, adding them to a table called `datasette_events` which will be created if it does not exist.\n\nThe `instance` key can be used to differentiate different instances that report to the same backend. Events are identified with a ULID to ensure they are unique even across different instances.\n\nEvents are forwarded in batches of up to 10, no more than once every 10 seconds.\n\nFull list of configuration settings:\n\n- `api_url`: The write API URL of a Datasette instance to forward the events to.\n- `api_token`: The API token to use when sending events. Use `{\"$env\": \"FORWARD_TOKEN\"}` to read the token from the `FORWARD_TOKEN` environment variable.\n- `instance`: A string to identify the instance that is sending the events.\n\nThe `api_url` can be either a `https://datasette.example.com/data/datasette_events/-/insert` endpoint for inserting rows, or a `https://datasette.example.com/data/-/create` endpoint for creating a table and inserting rows into it. If the table does not yet exist you should use the `/-/create` variant, otherwise use the `/-/insert` variant.\n\nIf you use `/-/insert` your API token just needs `insert-row` permissions. For `/-/create` you will need `create-table` permissions as well.\n\nAnd to control the rate at which batches of events are sent to the Datasette write API:\n\n- `batch_limit`: The number of events to send in each batch, defaults to 10. The Datasette write API has a 100 row limit by default so this should be set to a value less than that.\n- `max_rate`: The maximum number of deliver HTTP requests to send in the specified time period, defaults to 1.\n- `time_period`: The time period for the rate limiting in seconds, defaults to 10.\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd datasette-events-forward\npython3 -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Forward Datasette events to another instance",
    "version": "0.1a1",
    "project_urls": {
        "CI": "https://github.com/datasette/datasette-events-forward/actions",
        "Changelog": "https://github.com/datasette/datasette-events-forward/releases",
        "Homepage": "https://github.com/datasette/datasette-events-forward",
        "Issues": "https://github.com/datasette/datasette-events-forward/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a684a7215582afbe5b7744d6ad6dd3a3349efdb7a20a1f781acf849d6ec7496",
                "md5": "6dad3ed006a76ec614e2ff5ea6c8a700",
                "sha256": "a54f74bb2581a3038e8cafdac7a916438c9e511b9ac5f97d60d160601f24605f"
            },
            "downloads": -1,
            "filename": "datasette_events_forward-0.1a1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6dad3ed006a76ec614e2ff5ea6c8a700",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8989,
            "upload_time": "2024-02-20T21:56:04",
            "upload_time_iso_8601": "2024-02-20T21:56:04.343422Z",
            "url": "https://files.pythonhosted.org/packages/1a/68/4a7215582afbe5b7744d6ad6dd3a3349efdb7a20a1f781acf849d6ec7496/datasette_events_forward-0.1a1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6ac7b151bd9c7d60f3da859483d2212cfc87e9703628e8ba8753b9489ae42f2",
                "md5": "62b2936369e7dd251046ad5422d0e00b",
                "sha256": "c9baad19b113dc834ea5c8f0f4b6f6986e86ad0ace320b5c33711892316ed0a2"
            },
            "downloads": -1,
            "filename": "datasette-events-forward-0.1a1.tar.gz",
            "has_sig": false,
            "md5_digest": "62b2936369e7dd251046ad5422d0e00b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9229,
            "upload_time": "2024-02-20T21:56:05",
            "upload_time_iso_8601": "2024-02-20T21:56:05.887559Z",
            "url": "https://files.pythonhosted.org/packages/d6/ac/7b151bd9c7d60f3da859483d2212cfc87e9703628e8ba8753b9489ae42f2/datasette-events-forward-0.1a1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-20 21:56:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datasette",
    "github_project": "datasette-events-forward",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "datasette-events-forward"
}
        
Elapsed time: 0.26160s