{"id":20632477,"url":"https://github.com/citusdata/citus-example-microservices","last_synced_at":"2025-09-26T17:31:36.897Z","repository":{"id":182296774,"uuid":"656795709","full_name":"citusdata/citus-example-microservices","owner":"citusdata","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-30T21:36:26.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-16T14:16:18.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/citusdata.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,"governance":null}},"created_at":"2023-06-21T16:50:40.000Z","updated_at":"2024-04-15T15:38:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"8987c101-73c4-44a4-b824-45fa6713f3ae","html_url":"https://github.com/citusdata/citus-example-microservices","commit_stats":null,"previous_names":["citusdata/citus-example-microservices"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citusdata%2Fcitus-example-microservices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citusdata%2Fcitus-example-microservices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citusdata%2Fcitus-example-microservices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citusdata%2Fcitus-example-microservices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/citusdata","download_url":"https://codeload.github.com/citusdata/citus-example-microservices/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234327128,"owners_count":18814704,"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-11-16T14:16:19.695Z","updated_at":"2025-09-26T17:31:31.606Z","avatar_url":"https://github.com/citusdata.png","language":"Python","readme":"# Citus Example: Microservices\n\nThree microservices used to demonstrte setting up Citus as scalable storage backend for microservices.\n\n# Citus setup\n\n```sql\n    SET citus.enable_schema_based_sharding TO ON;\n\n    CREATE SCHEMA AUTHORIZATION user_service;\n    CREATE SCHEMA AUTHORIZATION time_service;\n    CREATE SCHEMA AUTHORIZATION ping_service;\n```\n\nExecute the corresponding SQL file as every service.\n\n```bash\npsql -U user_service -f user_service/user.sql\npsql -U time_service -f time_service/time.sql\npsql -U ping_service -f ping_service/ping.sql\n```\n\n# Connection configuration\n\nModify the `db_config` variable for every service in their `app.py`.\n\n```python\ndb_config = {\n    'host': 'localhost',\n    'database': 'citus',\n    'user': 'time_service',\n    'port': 9700\n}\n```\n\n# Running the apps\n\nChange into every app directory and run them in their own python env.\n\n```bash\ncd user\npipenv install\npipenv shell\npython app.py\n```\n\nRepeat the above for `time` and `ping` service.\n\n# Execute some commands against the API\n\n```bash\n\n    # Create 10 users\n    curl -X POST -H \"Content-Type: application/json\" -d '[\n      {\"name\": \"John Doe\", \"email\": \"john@example.com\"},\n      {\"name\": \"Jane Smith\", \"email\": \"jane@example.com\"},\n      {\"name\": \"Mike Johnson\", \"email\": \"mike@example.com\"},\n      {\"name\": \"Emily Davis\", \"email\": \"emily@example.com\"},\n      {\"name\": \"David Wilson\", \"email\": \"david@example.com\"},\n      {\"name\": \"Sarah Thompson\", \"email\": \"sarah@example.com\"},\n      {\"name\": \"Alex Miller\", \"email\": \"alex@example.com\"},\n      {\"name\": \"Olivia Anderson\", \"email\": \"olivia@example.com\"},\n      {\"name\": \"Daniel Martin\", \"email\": \"daniel@example.com\"},\n      {\"name\": \"Sophia White\", \"email\": \"sophia@example.com\"}\n    ]' http://localhost:5000/users\n\n    # List users\n    curl http://localhost:5000/users\n\n    # Get current time\n    curl http://localhost:5001/current_time\n\n    # Ping example.com\n    curl -X POST -H \"Content-Type: application/json\" -d '{\"host\": \"example.com\"}' http://localhost:5002/ping\n\n```\n\n# LICENSE\n\nCopyright (c) 2023, Microsoft\n\nLicensed under the MIT license - feel free to incorporate the code in your own projects!","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitusdata%2Fcitus-example-microservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcitusdata%2Fcitus-example-microservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitusdata%2Fcitus-example-microservices/lists"}