{"id":15564144,"url":"https://github.com/and3rson/isc","last_synced_at":"2025-04-09T17:04:38.792Z","repository":{"id":52704836,"uuid":"83671392","full_name":"and3rson/isc","owner":"and3rson","description":"Inter-service communication layer for Python with Django support","archived":false,"fork":false,"pushed_at":"2021-04-20T17:26:24.000Z","size":120,"stargazers_count":9,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T23:29:12.385Z","etag":null,"topics":["amqp","gevent","pika","python","python2","python3","rpc"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/and3rson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-02T11:40:51.000Z","updated_at":"2022-06-10T17:12:35.000Z","dependencies_parsed_at":"2022-08-22T07:01:48.791Z","dependency_job_id":null,"html_url":"https://github.com/and3rson/isc","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fisc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fisc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fisc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and3rson%2Fisc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/and3rson","download_url":"https://codeload.github.com/and3rson/isc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248074975,"owners_count":21043490,"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":["amqp","gevent","pika","python","python2","python3","rpc"],"created_at":"2024-10-02T16:38:37.911Z","updated_at":"2025-04-09T17:04:38.762Z","avatar_url":"https://github.com/and3rson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What is an ISC?\n\nISC is *RPC on steroids.*\n\nThis is a framework for Python designed to build distributed applications. It is designed to play well with Django and helps you to quickly build architectures from scratch.\n\nISC stands for Inter-Service Communication. It is **the library you missed to write scalable distributed systems using microservices pattern in Django.**\n\nIt uses RabbitMQ as messaging broker and is compatible with gevent monkey patching.\n\n[![Coverage Status](https://coveralls.io/repos/github/and3rson/isc/badge.svg?1)](https://coveralls.io/github/and3rson/isc) [![Build Status](https://travis-ci.org/and3rson/isc.svg)](https://travis-ci.org/and3rson/isc) [![Documentation Status](https://readthedocs.org/projects/isc/badge/?version=latest)](http://isc.readthedocs.io/en/latest/?badge=latest)\n\n# Django + ISC = ♥\n\nISC supports Django and makes it easy and intuitive to build a distributed system using. We're trying to make you capable of walking away from the monolythic architecture of typical Django apps.\n\n# The philosophy\n\n- **Distribution.** Service is an application (Python, Django, Flask or whatever) that performs a set of tasks, and performs them well.\n- **Encapsulation.** If service needs to perform the work that the other service is responsible for, it should ask the other service to do so.\n- **Abstraction.** All services are clients, irregardlessly of whether they provide functions or perform RPC calls to other services. Service doesn't need to know the address or specifications of each other. Services can also broadcast messages to multiple other services.\n\n# Psst: You can also write some of your [services in NodeJS](https://www.npmjs.com/package/isclib)!\n\nAnd of course they can communicate with your Django apps because they share the same protocol. How cool is that?\n\n# How does it work?\n\n1. You declare some services which are basically just classes with exposed methods.\n2. *[Not required for Django]* You instantiate \u0026 register your services.\n3. You run the worker that handles incoming requests and delivers function return values back to the caller (Classic RPC pattern.) For Django this is achieved by running `./manage.py isc`.\n4. [Django only] Apart from having the `isc` running, you'll now want to also start your web server with `./manage.py runserver` in a different terminal. Now you have 2 processes running: 1 for Django itself and 1 for ISC worker that will perform tasks asynchronously. Because `isc` is a Django management command, you can easily use all of Django's fascilities in your ISC services: ORM, templating etc. You can even send RPC calls from one services to the others.\n\n# Dependencies\n\n- `pika`\n- `kombu`\n- A running `rabbitmq` server.\n\n# Documentation\n\nThe docs are available via [ReadTheDocs](http://isc.readthedocs.io/en/latest/).\n\n# Installation\n\n```bash\npip install isclib\n```\n\n# All-in-one example\n\n## Server\n\n`test_server.py`\n\n```python\n#!/usr/bin/env python3.6\n\nfrom isc.server import Node, expose, on, local_timer\n\n\nclass ExampleService(object):\n    name = 'example'\n\n    @expose\n    def foo(self):\n        return 'bar'\n\n    @expose\n    def dangerous_operation(self):\n        raise Exception('BOOM')\n\n    def private_method(self):\n        print('Cannot call me!')\n\n    @on('boom')\n    def do_stuff(self, data):\n        print(data['place'], 'exploded')\n\n    @local_timer(timeout=5)\n    def print_statistics(self):\n        # Will be called every 5 seconds.\n        print('Staying alive!')\n\n\nservice = ExampleService()\nnode = Node()\nnode.register_service(service)\n\nif __name__ == '__main__':\n    node.run()\n```\n\n## Client\n\n`test_client.py`\n\n```python\n#!/usr/bin/env python3.6\n\nfrom isc.client import Client, RemoteException\n\n# `Client` is thread-safe, no need to perform any connection pooling.\nclient = Client()\n\n# Call single method\nclient.example.foo()  # returns 'bar'\n\n# Raises RemoteException\nclient.example.dangerous_operation()\n\n# Send a broadcast\nclient.notify('boom', dict(place='old_building'))\n\n# Raises RemoteException\nclient.private_method()\n\n# Do not wait for result\nfuture = client.example.foo.call_async()\n# ...or if you want, you can manually wait for it:\nfuture.wait()\nprint(future.value)\n```\n\n# Playing with Django\n\nUsing ISC with Django is very simple.\n\nIn order to integrate ISC into your Django app, you need to perform those steps:\n\n1. Classically, add `isc` to `INSTALLED_APPS`.\n\n2. Add configuration for your services into your `settings.py`:\n\n```python\nISC = {\n    # Specify where your RabbitMQ lives.\n    'url': os.getenv('RABBITMQ_URL', 'amqp://guest:guest@127.0.0.1:5672/'),\n\n    # Enumerate your service classes here\n    'services': [\n        'myapp.services.ExampleService',\n        'myapp.services.UserService',\n        'myapp.services.ChatService',\n    ],\n\n    # Hooks are methods that are evaluated when an RPC request is handler.\n    # 'hooks': {\n    #     'post_success': 'myapp.utils.handle_success'\n    #     'post_error': 'myapp.utils.handle_error',\n    # },\n    # Size of worker thread pool for server\n    # 'thread_pool_size': 8\n}\n```\n\n3. Start the worker that handles incoming requests to your services by running `./manage.py isc` and that's it!\n\n4. In order to test calling some ISC methods from the services you've just defined run `./manage.py iscshell`:\n\n```python\n$ ./manage.py iscshell\n\u003e\u003e\u003e print(rpc.example.foo())\nbar\n```\n\n5. You can now write other applications that retrieve data from your app via ISC. They can also host their own services.\n\n# Supported Python versions\n\nISC is supported on Python 2.7+ \u0026 3.5+\n\n# Contribution\n\nCreated by Andrew Dunai. Inspired by Nameko.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fand3rson%2Fisc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fand3rson%2Fisc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fand3rson%2Fisc/lists"}