{"id":27376971,"url":"https://github.com/joezeo/reactive-server","last_synced_at":"2025-04-13T12:57:51.931Z","repository":{"id":47402709,"uuid":"340243804","full_name":"Joezeo/reactive-server","owner":"Joezeo","description":"Reactive web server  template, using Webflux + Reactive-Mongodb as basic framework, a template for efficiently dealing with highly concurrent requests.","archived":false,"fork":false,"pushed_at":"2022-07-22T18:30:14.000Z","size":119,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T12:57:47.655Z","etag":null,"topics":["akka","async-events","reactive","reactive-mongo","template-project","template-server","web-server","webflux"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Joezeo.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}},"created_at":"2021-02-19T03:06:28.000Z","updated_at":"2022-08-21T18:17:11.000Z","dependencies_parsed_at":"2022-08-12T13:22:39.009Z","dependency_job_id":null,"html_url":"https://github.com/Joezeo/reactive-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joezeo%2Freactive-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joezeo%2Freactive-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joezeo%2Freactive-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joezeo%2Freactive-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Joezeo","download_url":"https://codeload.github.com/Joezeo/reactive-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717261,"owners_count":21150389,"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":["akka","async-events","reactive","reactive-mongo","template-project","template-server","web-server","webflux"],"created_at":"2025-04-13T12:57:51.374Z","updated_at":"2025-04-13T12:57:51.921Z","avatar_url":"https://github.com/Joezeo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reactive_server\n\nThis project is a reactive web server template, using webflux + reactive-mongodb as basic framework, a template for efficiently dealing with highly concurrent requests.  \n\nA simple test server bases on this template from my own have `4000+` throughput per second(TPS) under `10000+` concurrency with `1s` response time in average via pressure test by Jmeter.\n\n### Usage\n**1. Reactive Http action**  \nThe most important class was `com.toocol.common.web.AbstractHttpAction`, one HttpAction represent one http request handler, and add annotation `com.toocol.common.web.ActionMapping` to register http uri mapping. By default, the required HTTP request method is `post`, and the `content-type` is `application/json`.This is an example:  \n```java\n@Slf4j\n// uri is represent to \"/article/add_article\"\n@ActionMapping(module = \"article\", action = \"add_article\")\npublic class AddArticleAction extends AbstractHttpAction\u003cString\u003e implements IVessel {\n\n    @Override\n    public Mono\u003cString\u003e action(JSONObject param) throws Exception {\n        ArticleAddress articleAddress = ArticleAddress.builder()\n                .digest(UUID.randomUUID().toString())\n                .url(\"https://www.toocol.article/1001\")\n                .build();\n                \n        return vessel().articleAddressRepo.insert(articleAddress)\n                .thenReturn(\"Success\");\n    }\n\n}\n```\n\n**2. Reactive mongodb repository**  \nJust create a document class implement `com.toocol.common.database.IDocument` and add annotation `org.springframework.data.mongodb.core.mapping.Document`, then create a interface extends `com.toocol.common.database.mongo.AsyncMongoRepo`:  \n```yml\nspring:\n  data:\n    mongodb:\n      host: localhost\n      port: 27017\n      database: your-database\n```\n```java\npublic interface ArticleAddressRepo extends AsyncMongoRepo\u003cObjectId, ArticleAddress\u003e {\n\n}\n```\n```java\n@NoArgsConstructor\n@AllArgsConstructor\n@Getter\n@Setter\n@Builder\n@Document(collection = \"article_address\")\npublic class ArticleAddress implements IDocument {\n    private static final long serialVersionUID = -4092392708753755910L;\n\n    @Id\n    private ObjectId id;\n\n    /**\n     * the digest of article, use md5 algorithm.\n     */\n    private String digest;\n\n    /**\n     * the url of article's HTML file.\n     */\n    private String url;\n\n    public String getId() {\n        return id.toHexString();\n    }\n\n    public void setId(String id) {\n        this.id = new ObjectId(id);\n    }\n}\n```\n\n**3. Vessel**  \nThis template using extra Vessel to avoid the problem of circular dependency, you need add two class like this in your own project(or you can just ignore it with your own way):  \n```java\n@Primary\n@Component\npublic class Vessel extends DefaultVessel {\n\n    /**\n     * every bean in spring should add to there.\n     */\n    public ArticleAddressRepo articleAddressRepo;\n\n}\n```\n```java\n/**\n* This interface was created to acquire Vessel instance\n*/\npublic interface IVessel extends IBasisVessel\u003cVessel\u003e {\n    /**\n     * @return vessel instance\n     */\n    @Override\n    default Vessel vessel() {\n        return AbstractVessel.get().as();\n    }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoezeo%2Freactive-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoezeo%2Freactive-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoezeo%2Freactive-server/lists"}