{"id":21095179,"url":"https://github.com/dan-and-dna/singleinst-examples","last_synced_at":"2025-10-23T23:23:07.228Z","repository":{"id":109621167,"uuid":"564844911","full_name":"DAN-AND-DNA/singleinst-examples","owner":"DAN-AND-DNA","description":"example for single instance module","archived":false,"fork":false,"pushed_at":"2022-11-11T16:41:03.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T07:11:50.343Z","etag":null,"topics":["bff","bff-api","examples","grpc","microservices","restful-api","single-instance","singleinstance"],"latest_commit_sha":null,"homepage":"","language":null,"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/DAN-AND-DNA.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-11T16:27:24.000Z","updated_at":"2022-11-11T17:13:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbf2fc5a-f18b-45c8-af13-f2e2f0338086","html_url":"https://github.com/DAN-AND-DNA/singleinst-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DAN-AND-DNA/singleinst-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAN-AND-DNA%2Fsingleinst-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAN-AND-DNA%2Fsingleinst-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAN-AND-DNA%2Fsingleinst-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAN-AND-DNA%2Fsingleinst-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DAN-AND-DNA","download_url":"https://codeload.github.com/DAN-AND-DNA/singleinst-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAN-AND-DNA%2Fsingleinst-examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265898332,"owners_count":23845774,"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":["bff","bff-api","examples","grpc","microservices","restful-api","single-instance","singleinstance"],"created_at":"2024-11-19T22:24:03.131Z","updated_at":"2025-10-23T23:23:07.140Z","avatar_url":"https://github.com/DAN-AND-DNA.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# examples\n\n[中文文档](README_cn.md)\n\n## KVStorage\nA very simple key value data storage service to illustrate the use of single instance modules:\n\n1. WebBFF provides Restful API for the web side, encapsulates the back-end interface and provides a small amount of data caching\n2. KVService, grpc service, provides data access service\n3. UserService, grpc service, provides user permission verification service\n\n```c++\nArchitecture in k8s        ______________________________ \n                          | k8s             KVService   |\n                          |               /             |  \n                          |        WebBFF - KVService   |  -- DB clusters\n                          |      /        \\             |\nClients -- WAF -- SLB --  | Ingress         KVService   | \n                          |      \\                      |\n                          |        WebBFF - UserService |  -- Redis clusters\n                          |               \\             |\n                          |                 UserService |\n                          |_____________________________|\n```\n\n## 用法\n1. git clone https://github.com/DAN-AND-DNA/singleinst \n2. git clone https://github.com/DAN-AND-DNA/singleinst-examples\n3. cp -r ./singleinst-examples/examples ./singleinst/\n4. Start each of the 3 services in examples\n5. Send a POST request using postman to get the token:  \n    http://127.0.0.1:3737/nanogo/webbff/webbff/login \n6. Fill the header Token and send a POST request to set the value:  \n    http://127.0.0.1:3737/nanogo/webbff/webbff/set \n7. Fill the header Token and send a POST request to set the value:   \n    http://127.0.0.1:3737/nanogo/webbff/webbff/get\n\n```golang\n// login request\n{\n    \n    \"name\": \"Dan\",\n    \"password\": \"12345678\"\n}\n\n// login response\n{\n    \"token\": \"login_abcdef1234567\",\n    \"base_userinfo\": {\n        \"uid\": \"u10001\",\n        \"username\": \"Dan\",\n        \"age\": 30\n    }\n}\n\n// set request\n{\n    \"new_value\":{\n        \"key\": \"money\",\n        \"value\": \"99991\"\n    }\n}\n\n// get request\n{\n    \"key\": \"money\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-and-dna%2Fsingleinst-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-and-dna%2Fsingleinst-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-and-dna%2Fsingleinst-examples/lists"}