{"id":17222777,"url":"https://github.com/cheind/rxredis","last_synced_at":"2025-03-25T16:21:57.518Z","repository":{"id":210058430,"uuid":"725585820","full_name":"cheind/rxredis","owner":"cheind","description":"ReactiveX extensions for Redis in Python","archived":false,"fork":false,"pushed_at":"2023-12-03T07:32:33.000Z","size":41,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T14:24:35.943Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-30T13:06:48.000Z","updated_at":"2024-04-15T10:42:47.000Z","dependencies_parsed_at":"2023-11-30T15:47:25.197Z","dependency_job_id":null,"html_url":"https://github.com/cheind/rxredis","commit_stats":null,"previous_names":["cheind/rxredis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Frxredis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Frxredis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Frxredis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Frxredis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheind","download_url":"https://codeload.github.com/cheind/rxredis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245496180,"owners_count":20624846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T04:06:19.997Z","updated_at":"2025-03-25T16:21:57.497Z","avatar_url":"https://github.com/cheind.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"**rxredis**: *ReactiveX extensions for Redis in Python*\n\n## Example\n\nThe following example shows how to split elements of an input stream by parity and write the elements of the resulting groups asynchronously to different output streams.\n\n```python\nimport rxredis as rxr\n\nimport redis\nimport reactivex.operators as ops\n\n# Open Redis\nredis_api: redis.Redis = redis.from_url(\"redis://localhost:6379/0?decode_responses=True\")\n\nstreams = [\"even\", \"odd\"]\n\n# Read marble stream (1,2,...) until timeout\nrxr.from_stream(\n    redis_api,\n    stream=\"prod\",\n    stream_id=\"0\",  # Start at beginning of stream\n    timeout=2000,\n    complete_on_timeout=True,  # Complete observable upon timeout\n).pipe(\n    # Group by parity\n    ops.group_by(lambda x: int(x[1][\"marble\"]) % 2),\n    # Map each group\n    ops.flat_map(\n        lambda grp: grp.pipe(\n            # Push to destination stream\n            rxr.operators.to_stream(redis_api, streams[grp.key]),\n            # Return last element on completion of group\n            ops.last(),\n        )\n    ),\n).subscribe(\n    on_next=lambda x: print(f\"Last consumed {x}\"),\n    on_error=lambda e: print(e),\n    on_completed=lambda: print('Done')\n)\n```\n\nHere is the output of the `monitor` command at Redis. We use a live producer, prefixed with `P\u003e`, and prefix consumer part with `C\u003e`.\n```\nP\u003e \"XADD\" \"prod\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"1\"\nC\u003e \"XREAD\" \"BLOCK\" \"2000\" \"COUNT\" \"1\" \"STREAMS\" \"prod\" \"0\"\nC\u003e \"XADD\" \"odd\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"1\"\nC\u003e \"XREAD\" \"BLOCK\" \"2000\" \"COUNT\" \"1\" \"STREAMS\" \"prod\" \"1701405426087-0\"\nP\u003e \"XADD\" \"prod\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"2\"\nC\u003e \"XADD\" \"even\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"2\"\nC\u003e \"XREAD\" \"BLOCK\" \"2000\" \"COUNT\" \"1\" \"STREAMS\" \"prod\" \"1701405426490-0\"\nP\u003e \"XADD\" \"prod\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"3\"\nC\u003e \"XADD\" \"odd\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"3\"\nC\u003e \"XREAD\" \"BLOCK\" \"2000\" \"COUNT\" \"1\" \"STREAMS\" \"prod\" \"1701405426887-0\"\nP\u003e \"XADD\" \"prod\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"4\"\nC\u003e \"XADD\" \"even\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"4\"\nC\u003e \"XREAD\" \"BLOCK\" \"2000\" \"COUNT\" \"1\" \"STREAMS\" \"prod\" \"1701405427288-0\"\nP\u003e \"XADD\" \"prod\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"5\"\nC\u003e \"XADD\" \"odd\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"5\"\nC\u003e \"XREAD\" \"BLOCK\" \"2000\" \"COUNT\" \"1\" \"STREAMS\" \"prod\" \"1701405427688-0\"\nP\u003e \"XADD\" \"prod\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"6\"\nC\u003e \"XADD\" \"even\" \"MAXLEN\" \"~\" \"500\" \"*\" \"marble\" \"6\"\nC\u003e \"XREAD\" \"BLOCK\" \"2000\" \"COUNT\" \"1\" \"STREAMS\" \"prod\" \"1701405428088-0\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Frxredis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheind%2Frxredis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Frxredis/lists"}