flakemaker


Nameflakemaker JSON
Version 1.0.0.post1 PyPI version JSON
download
home_page
SummaryCreate snowflakes with encoded data in them.
upload_time2024-02-17 21:42:02
maintainer
docs_urlNone
author
requires_python
licenseMIT
keywords snowflake id
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # flakemaker

The `flakemaker` library offers a straightforward approach to generating unique, time-based identifiers similar to Discord's snowflake IDs, but repurposing the worker and process IDs into a generalized "parameter".

## Features

- Generates 64-bit snowflake IDs.
- Customizable epoch.
- Includes a user-defined parameter at snowflake generation. *Note that this replaces the worker and process ids!*

## Quickstart

### Generating a Snowflake

To generate a snowflake, create an instance of `SnowflakeGenerator` and call the `generate` method with your parameter.

```python
from flakemaker import SnowflakeGenerator

generator = SnowflakeGenerator() # you can put a time here in milliseconds since 1970
snowflake = generator.generate(42) # or any value from 0-1023
print(f"Generated snowflake: {snowflake}")
# Generated snowflake: 17359567945990144
```

### Parsing a Snowflake

To parse an existing snowflake and extract its creation time and parameter, use the `parse` method.

```python
dt, parameter = generator.parse(snowflake)
print(f"Timestamp: {dt}, Parameter: {parameter}")
# Timestamp: datetime.datetime(2024, 2, 17, 13, 49, 13, 466377), Parameter: 42
```

This method returns the timestamp of the snowflake as a `datetime` object in UTC and the parameter encoded within the snowflake.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "flakemaker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "SNOWFLAKE,ID",
    "author": "",
    "author_email": "infernostars <infernity@infernity.dev>",
    "download_url": "https://files.pythonhosted.org/packages/54/4d/b0e820e5af3b60f43752c410368eb650e3c256021e3060a392d74358f1fa/flakemaker-1.0.0.post1.tar.gz",
    "platform": null,
    "description": "# flakemaker\n\nThe `flakemaker` library offers a straightforward approach to generating unique, time-based identifiers similar to Discord's snowflake IDs, but repurposing the worker and process IDs into a generalized \"parameter\".\n\n## Features\n\n- Generates 64-bit snowflake IDs.\n- Customizable epoch.\n- Includes a user-defined parameter at snowflake generation. *Note that this replaces the worker and process ids!*\n\n## Quickstart\n\n### Generating a Snowflake\n\nTo generate a snowflake, create an instance of `SnowflakeGenerator` and call the `generate` method with your parameter.\n\n```python\nfrom flakemaker import SnowflakeGenerator\n\ngenerator = SnowflakeGenerator() # you can put a time here in milliseconds since 1970\nsnowflake = generator.generate(42) # or any value from 0-1023\nprint(f\"Generated snowflake: {snowflake}\")\n# Generated snowflake: 17359567945990144\n```\n\n### Parsing a Snowflake\n\nTo parse an existing snowflake and extract its creation time and parameter, use the `parse` method.\n\n```python\ndt, parameter = generator.parse(snowflake)\nprint(f\"Timestamp: {dt}, Parameter: {parameter}\")\n# Timestamp: datetime.datetime(2024, 2, 17, 13, 49, 13, 466377), Parameter: 42\n```\n\nThis method returns the timestamp of the snowflake as a `datetime` object in UTC and the parameter encoded within the snowflake.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Create snowflakes with encoded data in them.",
    "version": "1.0.0.post1",
    "project_urls": null,
    "split_keywords": [
        "snowflake",
        "id"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1669b87d1d45b2291f30b0dc4f8bc8a49acaeb7787c8834e92c51f2b0a861899",
                "md5": "abe2459e22105f858e96cbfda3a06702",
                "sha256": "84c58f3a17ec590e4f33bc618c949848b39d1f2c7d5e6562435d90f5f8b0c4f6"
            },
            "downloads": -1,
            "filename": "flakemaker-1.0.0.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "abe2459e22105f858e96cbfda3a06702",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3577,
            "upload_time": "2024-02-17T21:42:00",
            "upload_time_iso_8601": "2024-02-17T21:42:00.527039Z",
            "url": "https://files.pythonhosted.org/packages/16/69/b87d1d45b2291f30b0dc4f8bc8a49acaeb7787c8834e92c51f2b0a861899/flakemaker-1.0.0.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "544db0e820e5af3b60f43752c410368eb650e3c256021e3060a392d74358f1fa",
                "md5": "39f8f4d8158577510d1e6b2cee14a08e",
                "sha256": "dfb5696dce20200ca904febea188f5d361ef5aa254caa5dec7173fc9710660db"
            },
            "downloads": -1,
            "filename": "flakemaker-1.0.0.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "39f8f4d8158577510d1e6b2cee14a08e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3654,
            "upload_time": "2024-02-17T21:42:02",
            "upload_time_iso_8601": "2024-02-17T21:42:02.127177Z",
            "url": "https://files.pythonhosted.org/packages/54/4d/b0e820e5af3b60f43752c410368eb650e3c256021e3060a392d74358f1fa/flakemaker-1.0.0.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-17 21:42:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "flakemaker"
}
        
Elapsed time: 0.18306s