{"id":37019204,"url":"https://github.com/smartbuf/smartbuf-springcloud","last_synced_at":"2026-01-14T02:04:00.735Z","repository":{"id":39950314,"uuid":"222907922","full_name":"smartbuf/smartbuf-springcloud","owner":"smartbuf","description":"smartbuf-springcloud is a spring-cloud serialization plugin based on smartbuf with better performance, it could coexist with json and seamleassly switch.","archived":false,"fork":false,"pushed_at":"2025-07-12T02:11:39.000Z","size":1007,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-25T07:30:36.059Z","etag":null,"topics":["performance-optimization","serialization","smartbuf","spring-cloud"],"latest_commit_sha":null,"homepage":"","language":"Java","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/smartbuf.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":"2019-11-20T10:08:34.000Z","updated_at":"2019-11-22T13:57:18.000Z","dependencies_parsed_at":"2022-09-13T13:40:58.060Z","dependency_job_id":null,"html_url":"https://github.com/smartbuf/smartbuf-springcloud","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/smartbuf/smartbuf-springcloud","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartbuf%2Fsmartbuf-springcloud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartbuf%2Fsmartbuf-springcloud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartbuf%2Fsmartbuf-springcloud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartbuf%2Fsmartbuf-springcloud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartbuf","download_url":"https://codeload.github.com/smartbuf/smartbuf-springcloud/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartbuf%2Fsmartbuf-springcloud/sbom","scorecard":{"id":832681,"data":{"date":"2025-08-11","repo":{"name":"github.com/smartbuf/smartbuf-springcloud","commit":"3529ad856b7fb9c001116b9271ad81033bebfc0e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/14 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"156 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-vmq6-5m68-f53m","Warn: Project is vulnerable to: GHSA-668q-qrv7-99fm","Warn: Project is vulnerable to: GHSA-6v67-2wr5-gvf4","Warn: Project is vulnerable to: GHSA-pr98-23f8-jwxv","Warn: Project is vulnerable to: GHSA-h46c-h94j-95f3","Warn: Project is vulnerable to: GHSA-wf8f-6423-gfxg","Warn: Project is vulnerable to: GHSA-4gq5-ch57-c2mg","Warn: Project is vulnerable to: GHSA-4w82-r329-3q67","Warn: Project is vulnerable to: GHSA-57j2-w4cx-62h2","Warn: Project is vulnerable to: GHSA-5949-rw7g-wx7w","Warn: Project is vulnerable to: GHSA-5r5r-6hpj-8gg9","Warn: Project is vulnerable to: GHSA-5ww9-j83m-q7qx","Warn: Project is vulnerable to: GHSA-645p-88qh-w398","Warn: Project is vulnerable to: GHSA-6fpp-rgj9-8rwc","Warn: Project is vulnerable to: GHSA-85cw-hj65-qqv9","Warn: Project is vulnerable to: GHSA-89qr-369f-5m5x","Warn: Project is vulnerable to: GHSA-8c4j-34r4-xr8g","Warn: Project is vulnerable to: GHSA-8w26-6f25-cm9x","Warn: Project is vulnerable to: GHSA-9gph-22xh-8x98","Warn: Project is vulnerable to: GHSA-9m6f-7xcq-8vf8","Warn: Project is vulnerable to: GHSA-c8hm-7hpq-7jhg","Warn: Project is vulnerable to: GHSA-cf6r-3wgc-h863","Warn: Project is vulnerable to: GHSA-cggj-fvv3-cqwv","Warn: Project is vulnerable to: GHSA-cjjf-94ff-43w7","Warn: Project is vulnerable to: GHSA-cmfg-87vq-g5g4","Warn: Project is vulnerable to: GHSA-cvm9-fjm9-3572","Warn: Project is vulnerable to: GHSA-f3j5-rmmp-3fc5","Warn: Project is vulnerable to: GHSA-f9xh-2qgp-cq57","Warn: Project is vulnerable to: GHSA-fmmc-742q-jg75","Warn: Project is vulnerable to: GHSA-fqwf-pjwf-7vqv","Warn: Project is vulnerable to: GHSA-gjmw-vf9h-g25v","Warn: Project is vulnerable to: GHSA-gwp4-hfv6-p7hw","Warn: Project is vulnerable to: GHSA-gww7-p5w4-wrfv","Warn: Project is vulnerable to: GHSA-h3cw-g4mq-c5x2","Warn: Project is vulnerable to: GHSA-h592-38cm-4ggp","Warn: Project is vulnerable to: GHSA-h822-r4r5-v8jg","Warn: Project is vulnerable to: GHSA-jjjh-jjxp-wpff","Warn: Project is vulnerable to: GHSA-m6x4-97wx-4q27","Warn: Project is vulnerable to: GHSA-mph4-vhrx-mv67","Warn: Project is vulnerable to: GHSA-mx7p-6679-8g3q","Warn: Project is vulnerable to: GHSA-p43x-xfjf-5jhr","Warn: Project is vulnerable to: GHSA-q93h-jc49-78gg","Warn: Project is vulnerable to: GHSA-qjw2-hr98-qgfh","Warn: Project is vulnerable to: GHSA-qr7j-h6gg-jmgc","Warn: Project is vulnerable to: GHSA-qxxx-2pp7-5hmx","Warn: Project is vulnerable to: GHSA-r3gr-cxrf-hg25","Warn: Project is vulnerable to: GHSA-r695-7vr9-jgc2","Warn: Project is vulnerable to: GHSA-rfx6-vp9g-rh7v","Warn: Project is vulnerable to: GHSA-rgv9-q543-rqg4","Warn: Project is vulnerable to: GHSA-rpr3-cw39-3pxh","Warn: Project is vulnerable to: GHSA-v585-23hc-c647","Warn: Project is vulnerable to: GHSA-vfqx-33qm-g869","Warn: Project is vulnerable to: GHSA-w3f4-3q6j-rh82","Warn: Project is vulnerable to: GHSA-wh8g-3j2c-rqj5","Warn: Project is vulnerable to: GHSA-5mg8-w23w-74h3","Warn: Project is vulnerable to: GHSA-7g45-4rm6-3mm3","Warn: Project is vulnerable to: GHSA-mvr2-9pj6-7w5j","Warn: Project is vulnerable to: GHSA-pvp8-3xj6-8c6x","Warn: Project is vulnerable to: GHSA-hfrx-6qgj-fp6c","Warn: Project is vulnerable to: GHSA-vv7r-c36w-3prj","Warn: Project is vulnerable to: GHSA-78wr-2p64-hpwj","Warn: Project is vulnerable to: GHSA-gwrp-pvrq-jmwv","Warn: Project is vulnerable to: GHSA-j288-q9x7-2f5v","Warn: Project is vulnerable to: GHSA-4cx2-fc23-5wg6","Warn: Project is vulnerable to: GHSA-6xx3-rg99-gc3p","Warn: Project is vulnerable to: GHSA-72m5-fvvv-55m6","Warn: Project is vulnerable to: GHSA-8xfc-gm6g-vgpv","Warn: Project is vulnerable to: GHSA-hr8g-6v94-x4m9","Warn: Project is vulnerable to: GHSA-v435-xc8x-wvr9","Warn: Project is vulnerable to: GHSA-wjxj-5m7g-mg7q","Warn: Project is vulnerable to: GHSA-cm59-pr5q-cw85","Warn: Project is vulnerable to: GHSA-rc42-6c7j-7h5r","Warn: Project is vulnerable to: GHSA-xf96-w227-r7c4","Warn: Project is vulnerable to: GHSA-mg83-c7gq-rv5c","Warn: Project is vulnerable to: GHSA-36p3-wjmg-h94x","Warn: Project is vulnerable to: GHSA-hh26-6xwr-ggv7","Warn: Project is vulnerable to: GHSA-4gc7-5j7h-4qph","Warn: Project is vulnerable to: GHSA-4wp7-92pw-q264","Warn: Project is vulnerable to: GHSA-g5mm-vmx4-3rg7","Warn: Project is vulnerable to: GHSA-558x-2xjg-6232","Warn: Project is vulnerable to: GHSA-564r-hj7v-mcr5","Warn: Project is vulnerable to: GHSA-9cmq-m9j5-mvww","Warn: Project is vulnerable to: GHSA-wxqc-pxw9-g2p8","Warn: Project is vulnerable to: GHSA-2rmj-mq67-h97g","Warn: Project is vulnerable to: GHSA-2wrp-6fg6-hmc5","Warn: Project is vulnerable to: GHSA-4wrc-f8pq-fpqp","Warn: Project is vulnerable to: GHSA-ccgv-vj62-xf9h","Warn: Project is vulnerable to: GHSA-hgjh-9rj2-g67j","Warn: Project is vulnerable to: GHSA-3mc7-4q67-w48m","Warn: Project is vulnerable to: GHSA-98wm-3w3q-mw94","Warn: Project is vulnerable to: GHSA-9w3m-gqgf-c4p9","Warn: Project is vulnerable to: GHSA-c4r9-r8fh-9vj2","Warn: Project is vulnerable to: GHSA-hhhw-99gj-p3c3","Warn: Project is vulnerable to: GHSA-mjmj-j48q-9wg2","Warn: Project is vulnerable to: GHSA-rvwf-54qp-4r6v","Warn: Project is vulnerable to: GHSA-w37g-rhq8-7m4j","Warn: Project is vulnerable to: GHSA-27xj-rqx5-2255","Warn: Project is vulnerable to: GHSA-288c-cq4h-88gq","Warn: Project is vulnerable to: GHSA-58pp-9c76-5625","Warn: Project is vulnerable to: GHSA-5p34-5m6p-p58g","Warn: Project is vulnerable to: GHSA-758m-v56v-grj4","Warn: Project is vulnerable to: GHSA-95cm-88f5-f2c7","Warn: Project is vulnerable to: GHSA-9vvp-fxw6-jcxr","Warn: Project is vulnerable to: GHSA-c265-37vj-cwcc","Warn: Project is vulnerable to: GHSA-c2q3-4qrh-fm48","Warn: Project is vulnerable to: GHSA-h4rc-386g-6m85","Warn: Project is vulnerable to: GHSA-j823-4qch-3rgm","Warn: Project is vulnerable to: GHSA-mc6h-4qgp-37qh","Warn: Project is vulnerable to: GHSA-qmqc-x3r4-6v39","Warn: Project is vulnerable to: GHSA-rf6r-2c4q-2vwg","Warn: Project is vulnerable to: GHSA-v3xw-c963-f5hc","Warn: Project is vulnerable to: GHSA-4jrv-ppp4-jm57","Warn: Project is vulnerable to: GHSA-w33c-445m-f8w7","Warn: Project is vulnerable to: GHSA-2w73-fqqj-c92p","Warn: Project is vulnerable to: GHSA-339q-62wm-c39w","Warn: Project is vulnerable to: GHSA-3jrv-jgp8-45v3","Warn: Project is vulnerable to: GHSA-8vh8-vc28-m2hf","Warn: Project is vulnerable to: GHSA-9442-gm4v-r222","Warn: Project is vulnerable to: GHSA-95rf-557x-44g5","Warn: Project is vulnerable to: GHSA-9623-mqmm-5rcf","Warn: Project is vulnerable to: GHSA-97cq-f4jm-mv8h","Warn: Project is vulnerable to: GHSA-cccf-7xw3-p2vr","Warn: Project is vulnerable to: GHSA-ch7q-gpff-h9hp","Warn: Project is vulnerable to: GHSA-fj7c-vg2v-ccrm","Warn: Project is vulnerable to: GHSA-g4cp-h53p-v3v8","Warn: Project is vulnerable to: GHSA-gv2w-88hx-8m9r","Warn: Project is vulnerable to: GHSA-jwgx-9mmh-684w","Warn: Project is vulnerable to: GHSA-m4mm-pg93-fv78","Warn: Project is vulnerable to: GHSA-mfhv-gwf8-4m88","Warn: Project is vulnerable to: GHSA-p9w3-gwc2-cr49","Warn: Project is vulnerable to: GHSA-pfcc-3g6r-8rg8","Warn: Project is vulnerable to: GHSA-qjwc-v72v-fq6r","Warn: Project is vulnerable to: GHSA-rf6q-vx79-mjxr","Warn: Project is vulnerable to: GHSA-rhcw-wjcm-9h6g","Warn: Project is vulnerable to: GHSA-v76w-3ph8-vm66","Warn: Project is vulnerable to: GHSA-vf6r-mmhc-3xcm","Warn: Project is vulnerable to: GHSA-vjxc-frw4-jmh5","Warn: Project is vulnerable to: GHSA-w6qf-42m7-vh68","Warn: Project is vulnerable to: GHSA-xpp6-8r3j-ww43","Warn: Project is vulnerable to: GHSA-w69w-jvc7-wjgv","Warn: Project is vulnerable to: GHSA-7r82-7xv7-xcpj","Warn: Project is vulnerable to: GHSA-3p86-9955-h393","Warn: Project is vulnerable to: GHSA-vrpq-qp53-qv56","Warn: Project is vulnerable to: GHSA-v6w3-2prq-h95f","Warn: Project is vulnerable to: GHSA-7v6m-28jr-rg84","Warn: Project is vulnerable to: GHSA-m8p2-495h-ccmh","Warn: Project is vulnerable to: GHSA-rmrm-75hp-phr2","Warn: Project is vulnerable to: GHSA-x83m-pf6f-pf9g","Warn: Project is vulnerable to: GHSA-7f88-5hhx-67m2","Warn: Project is vulnerable to: GHSA-jjfh-589g-3hjx","Warn: Project is vulnerable to: GHSA-g5h3-w546-pj7f","Warn: Project is vulnerable to: GHSA-32xf-jwmv-9hf3","Warn: Project is vulnerable to: GHSA-4x49-w62v-76q7","Warn: Project is vulnerable to: GHSA-g86w-v5vg-9gxf","Warn: Project is vulnerable to: GHSA-8wx2-9q48-vm9r","Warn: Project is vulnerable to: GHSA-g5vr-rgqm-vf78"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T18:09:06.107Z","repository_id":39950314,"created_at":"2025-08-23T18:09:06.107Z","updated_at":"2025-08-23T18:09:06.107Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["performance-optimization","serialization","smartbuf","spring-cloud"],"created_at":"2026-01-14T02:04:00.209Z","updated_at":"2026-01-14T02:04:00.725Z","avatar_url":"https://github.com/smartbuf.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smartbuf-springcloud  [![Travis CI](https://travis-ci.org/smartbuf/smartbuf-springcloud.svg?branch=master)](https://travis-ci.org/smartbuf/smartbuf-springcloud)\n\n[中文文档](https://sulin.me/2019/JGDXHH.html)\n\n`smartbuf-springcloud` is a `spring-cloud` serialization plugin based on `smartbuf`.\n\n# [SmartBuf](https://github.com/smartbuf/smartbuf-java) Introduce\n\n`smartbuf` is a novel, efficient, intelligent and easy-to-use cross-language serialization framework. \nIt has the same high performance as `protobuf`, and has the same versatility, scalability and flexibility as `json`. \n\nIn `Java` ecosystem, it supports multiple `RPC` through the following plugins:\n\n + [`smartbuf-dubbo`](https://github.com/smartbuf/smartbuf-dubbo): Provides a serialization plugin in `stream` mode for `dubbo`.\n + [`smartbuf-springcloud`](https://github.com/smartbuf/smartbuf-springcloud): Provides a serialization plugin in `packet` mode for `spring-cloud`.\n\nThe following is a detailed introduction of the `smartbuf-springcloud`.\n\n# Introduce\n\nThis plugin wraps `packet` mode of [`smartbuf`](https://github.com/smartbuf/smartbuf-java), \nand exposes an `HTTP` message converter named `application/x-smartbuf` to `spring` via the custom `SmartbufMessageConverter`.\n\nThis new `application/x-smartbuf` could provide better performance during data trasfer of complex object.\n\n# `application/x-smartbuf`\n\nThis plugin declares an `Auto-Configuration` named `SmartbufAutoConfiguration` in `META-INFO/spring.factories`.\n\n`spring-boot` will scan and register it during initializing, it's fully automatic, no additional configuration is required.\nFor more infomation, please refer to [SpringBoot Doc](https://docs.spring.io/autorepo/docs/spring-boot/2.0.0.M3/reference/html/boot-features-developing-auto-configuration.html)。\n\n`SmartbufAutoConfiguration` will add a new `SmartbufMessageConverter` instance into `spring` container, \nit's a custom `HttpMessageConverter`, and its `MediaType` is `application/x-smartbuf`.\n\n`spring-mvc` will include this `SmartbufMessageConverter` into `messageConverters`, and uses it globally.\nIf the headers of the subsequent `http` requests include `accept: application/x-smartbuf` or `content-type: application/x-smartbuf`, \n`spring-mvc` will use `SmartbufMessageConverter` to decode its input, and encode its output.\n\nThe whole process is similar to the implementation of `application/json`, expect that the `application/x-smartbuf` is \nbased on another serialization: [SmartBuf](https://github.com/smartbuf/smartbuf-java)\n\n**SUMMARY: No additional configuration is required, this plugin will register `application/x-smartbuf` \ninto `spring-mvc` automatically, it has no effect on normal `http` request, \nand will be activated only if `accept` or `context-type` in the headers matche `application/x-smartbuf`.**\n\n# Demonstration\n\nThis chapter introduces how to add and use `smartbuf-springcloud` into your project with a simple example.\n\n## Add Maven Dependency\n\nYou could add `smartbuf-springcloud` dependency by the following `maven` configuration:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.smartbuf\u003c/groupId\u003e\n  \u003cartifactId\u003esmartbuf-springcloud\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Use `application/json`\n\nThe `spring-cloud` layer uses `http` to communicate with the server's `spring-mvc`, the `controller` might like this:\n\n```java\n@RestController\npublic class DemoController {\n\n    @PostMapping(\"/hello\")\n    public String sayHello(String name) { return \"hello \" + name; }\n}\n```\n\nThe client could use this `FeignClient` to invoke server:\n\n```java\n@FeignClient(name = \"demo\")\npublic interface DemoClient {\n\n    @PostMapping(value = \"/hello\", consumes = \"application/json\", produces = \"application/json\")\n    String hello(@RequestParam(\"name\") String name);\n}\n```\n\nWhen client uses `DemoClient` to invoke server's `DemoController`, \n`feign` will send a request to server based on `consumes` and `produces`, the headers will like this:\n\n\u003e=== MimeHeaders ===  \n\u003eaccept = **application/json**  \n\u003econtent-type = **application/json**  \n\u003euser-agent = Java/1.8.0_191  \n\u003econnection = keep-alive\n\nThe `spring-mvc` of server  will determine to use `application/json` to perform `input` decoding and `output` decoding \nbased on `accept` and `content-type` in the headers of request.   \n\n## Use `application/x-smartbuf`\n\nAs mentioned earily, `smartbuf-springcloud` will automatically register a codec named `application/x-smartbuf` into `spring-mvc`,\nso after add the `maven` dependency, no additional configuration is required.\n\nTo use `application/x-smartbuf`, you just need to change `DemoClient` like this: \n\n```java\n@FeignClient(name = \"demo\")\npublic interface DemoClient {\n\n    @PostMapping(value = \"/hello\", consumes = \"application/x-smartbuf\", produces = \"application/x-smartbuf\")\n    String hello(@RequestParam(\"name\") String name);\n}\n```\n\nPlease pay attention to the changes in `consumes` and `produces`.\n\nAfter that, `feign` will use `application/x-smartbuf` to communicate with the server's `spring-mvc` automatically, \nthe headers will like this:\n\n\u003e=== MimeHeaders ===  \n\u003eaccept = **application/x-smartbuf**  \n\u003econtent-type = **application/x-smartbuf**  \n\u003euser-agent = Java/1.8.0_191  \n\u003econnection = keep-alive\n\nEven better, you can use `application/json` and `application/x-smartbuf` at the same time, like this:\n\n```java\n@FeignClient(name = \"demo\")\npublic interface DemoClient {\n\n    @PostMapping(value = \"/hello\", consumes = \"application/json\", produces = \"application/json\")\n    String helloJSON(@RequestParam(\"name\") String name);\n\n    @PostMapping(value = \"/hello\", consumes = \"application/x-smartbuf\", produces = \"application/x-smartbuf\")\n    String helloSmartbuf(@RequestParam(\"name\") String name);\n}\n```\n\nThe client could use `application/json` to communicate with the server by invoke `helloJSON`,\nand use `application/x-smartbuf` by invoke `helloSmartbuf`.\n\nThe server's `spring-mvc` will switch to correct converter automatically based on the specified `accept` and `content-type`. \n\nYou can `checkout` this project and find the whole example in `demo` submodule. \n\n# Performance Comparison\n\nThe advantage of `smartbuf` is the high compression ratio brought by its partition serialization, \nespecially when it comes to complex objects and arrays, its space utilization is far superior to other serialization schemes.\n\nFor RPC, the serialization time is often nanoseconds, \nwhile the logical processing and network transmission are often in the order of milliseconds.\nTherefore, the following test will use a single thread to performing test.\n\nBelow we test the difference between `json` and `smartbuf` through three different types of `api`.\n\n## `hello` Comparison\n\n`hello` is the `helloJson` and `helloSmartbuf` mentioned above. \nThe input and output parameters are `String`, its internal logic is very simple, `400,000` times requests will cost:\n\n + `JSON`: **169s**\n + `SmartBuf`: **170s**\n\nNetwork input(`bytes_input`) and output(`bytes_output`) are like this:\n\n![hello-bytes](https://github.com/smartbuf/smartbuf-springcloud/raw/master/doc/imgs/springcloud-hello.png)\n\nSince `smartbuf` encoding requires an few extra bytes to describe the complete data information, \nits space utilization is not as good as `json` when dealing with simple data like `String`.\n\n## `getUser` Comparison\n\n`getUser`'s implementation is like this:\n\n```java\n@RestController\npublic class DemoController {\n\n    private UserModel user = xxx; // initialized at somewhere else\n\n    @PostMapping(\"/getUser\")\n    public UserModel getUser(Integer userId) { return user; }\n}\n```\n\nThe `user` is a pre-allocated object for testing, \nits model can be found in the `UserModel` class in the `demo` source.\n\nThe client's `FeignClient` is defined as following:\n\n```java\n@FeignClient(name = \"demo\")\npublic interface DemoClient {\n\n    @PostMapping(value = \"/getUser\", consumes = \"application/json\", produces = \"application/json\")\n    UserModel getUserJSON(@RequestParam(\"userId\") Integer userId);\n\n    @PostMapping(value = \"/getUser\", consumes = \"application/x-smartbuf\", produces = \"application/x-smartbuf\")\n    UserModel getUserSmartbuf(@RequestParam(\"userId\") Integer userId);\n}\n```\n\n`300,000` times invocation will cost:\n\n + `JSON`: **162s**\n + `SmartBuf`: **149s**\n\nNetwork input(`bytes_input`) and output(`bytes_output`) are like this:\n\n![getUser-bytes](https://github.com/smartbuf/smartbuf-springcloud/raw/master/doc/imgs/springcloud-getUser.png)\n\nWe can see that the parameter `userId` is a single data type, \nso the network traffic used by `json` and `smartbuf` is almost the same.\nThe return result `UserModel` is a more complex object, \nand the `json` network resource consumption is nearly **3 times** of `smartbuf`.\n\nBecause the test environment is `localhost`, \nnetwork transmission time does not have much impact on the total time consumption of the interface.\n\n## `queryPost` Comparison\n\n`queryPost`'s implementation is like this:\n\n```java\n@RestController\npublic class DemoController {\n\n    private List\u003cPostModel\u003e posts = xxx; // initialized at somewhere else\n\n    @PostMapping(\"/queryPost\")\n    public List\u003cPostModel\u003e queryPost(String keyword) { return posts; }\n}\n```\n\nThe return value `posts` is a pre-allocated `PostModel` array for testing. \nIts length is fixed `100`. its model and initialization can be found in the `demo` source.\n\nThe client's `FeignClient` is defined as follows:\n\n```java\n@FeignClient(name = \"demo\")\npublic interface DemoClient {\n\n    @PostMapping(value = \"/queryPost\", consumes = \"application/json\", produces = \"application/json\")\n    List\u003cPostModel\u003e queryPostJSON(@RequestParam(\"keyword\") String keyword);\n\n    @PostMapping(value = \"/queryPost\", consumes = \"application/x-smartbuf\", produces = \"application/x-smartbuf\")\n    List\u003cPostModel\u003e queryPostSmartbuf(@RequestParam(\"keyword\") String keyword);\n}\n```\n\n`100,000` times invocation will cost:\n\n + `JSON`: **195s**\n + `SmartBuf`: **155s**\n\nNetwork input(`bytes_input`) and output(`bytes_output`) are like this:\n\n![queryPost-bytes](https://github.com/smartbuf/smartbuf-springcloud/raw/master/doc/imgs/springcloud-queryPost.png)\n\nWe can see that the parameter `keyword` is a single `String`, \nso the network traffic used by `json` and `smartbuf` is almost the same.\nThe return result `List\u003cPostModel\u003e` is a large array of complex objects, \nand the `json` network resource consumption is nearly **10 times** of `smartbuf`.\n\nBecause the test environment is `localhost`, \nnetwork transmission time does not have much impact on the total time consumption of the interface.\n\n# Summary\n\nWhen the `RPC`'s input and output are very simple, `application/x-smartbuf` does not have any performance advantages.\n\nWhen the `RPC`'s input and output are large data such as complex objects, arrays, collections.\nUsing `application/x-smartbuf` could greatly reduce the bytes size of the network transmission. \nFor example, in the `queryPost` above, `application/x-smartbuf`'s network transmission is only **1/10** of `application/json`.\n\nWhat is commendable is that the `application/x-smartbuf` and `application/json` can coexist and seamleassly switch.\n\nFor example, you can use `application/json` directly for some simple `api`, \nand use the efficient `application/x-smartbuf` for complex `api` with large object to achieve better performance.\n\nFor example, you can use `application/json` during development and test,\nand switch to `application/x-smartbuf` when going online.\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartbuf%2Fsmartbuf-springcloud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartbuf%2Fsmartbuf-springcloud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartbuf%2Fsmartbuf-springcloud/lists"}