{"id":21323467,"url":"https://github.com/sinkedship/cerberus-spring-boot-starter","last_synced_at":"2025-08-22T12:32:45.173Z","repository":{"id":53284330,"uuid":"200568419","full_name":"sinkedship/cerberus-spring-boot-starter","owner":"sinkedship","description":"Spring boot starter project for cerberus","archived":false,"fork":false,"pushed_at":"2021-08-16T06:12:34.000Z","size":64,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-12-18T05:51:57.183Z","etag":null,"topics":["cerberus","service-discovery","service-registration","spring-boot-starter","thrift"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinkedship.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-08-05T02:28:49.000Z","updated_at":"2022-04-13T08:55:15.000Z","dependencies_parsed_at":"2022-09-26T22:00:30.584Z","dependency_job_id":null,"html_url":"https://github.com/sinkedship/cerberus-spring-boot-starter","commit_stats":null,"previous_names":["sinkedship/cerberus-spring-boot"],"tags_count":2,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinkedship%2Fcerberus-spring-boot-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinkedship%2Fcerberus-spring-boot-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinkedship%2Fcerberus-spring-boot-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinkedship%2Fcerberus-spring-boot-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinkedship","download_url":"https://codeload.github.com/sinkedship/cerberus-spring-boot-starter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225797281,"owners_count":17525663,"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":["cerberus","service-discovery","service-registration","spring-boot-starter","thrift"],"created_at":"2024-11-21T20:24:06.647Z","updated_at":"2024-11-21T20:24:07.147Z","avatar_url":"https://github.com/sinkedship.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring boot starter for cerberus\n\nSpring Boot autoconfigure and starter module for Cerberus.\n\nIt contains Spring Boot starter for both server and client side, which is:\n\n```cerberus-server-bootstrap-spring-boot-starter``` and ```cerberus-client-proxy-spring-boot-starter```, respectively.\n\n## How to use Cerberus Spring Boot Starter\n\n### Server side\n\nAdd dependency in Maven:\n\n```maven\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.sinkedship.cerberus\u003c/groupId\u003e\n    \u003cartifactId\u003ecerberus-server-bootstrap-spring-boot-starter\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nCreate your server Spring Boot application:\n\n```java\n@SpringBootApplication\npublic class SampleStarterServer implements CommandLineRunner {\n\n    @Autowired\n    private CerberusServerBootstrap.Builder builder;\n\n    public static void main(String[] args) {\n        SpringApplication.run(SampleStarterServer.class, args);\n    }\n\n    @Override\n    public void run(String... args) {\n        A_ServiceImpl a = new A_ServiceImpl();\n        B_ServiceImpl b = new B_ServiceImpl();\n        // ...\n        X_ServiceImpl x = new X_ServiceImpl();\n\n        builder.withService(a)\n                .withService(b)\n                // .withService(...)\n                .withService(x)\n                .build().boot();\n    }\n}\n```\n\n```cerberus-server-bootstrap-spring-boot-starter``` configurates all the configurations from ```application.properties``` file specified by you or uses default values for which are not provided.\n\nAll you need to do is ```Autowired``` a ```CerberusServerBootstrap.Builder```, build any Thrift services with this builder with your business logic and boot it up!\n\n#### All available server configurations by now\n\nConfig key|Category|Type|Default value|Remark\n---|---|---|---:|:---\ncerberus.server.bootstrap.data-center|common|string(enum)|local|Data center used by Cerberus\ncerberus.server.bootstrap.register-host|common|string|an available inet IPv4 address|Host address(an external or internal address) that registered to data center\ncerberus.server.bootstrap.bind-host|common|string|an available inet IPv4 address|Binding host for server\ncerberus.server.bootstrap.bind-port|common|number|an available arbitrary port number|Binding port for server\ncerberus.server.bootstrap.accept-backlog|common|nubmer|1024|Underlying netty accept backlog\ncerberus.server.bootstrap.request-timeout|common|number|60000|Request time-out for any Thrift RPC call, measured in ***millisecond***\ncerberus.server.bootstrap.io-thread-count|common|number|3|Thread counts used by underlying netty I/O event loop group\ncerberus.server.bootstrap.worker-thread-count|common|number|available processors * 2|Thread counts used by underlying netty worker event loop group\ncerberus.data-center.zookeeper.connect-string|zookeeper|string|localhost:2181|Connection string used to connect to Zookeeper: ***$HOST_1:$PORT_1,...,$HOST_X:$PORT_X***\ncerberus.data-center.zookeeper.base-path|zookeeper|string|cerberus|Path used as 'ROOT' path in Zookeeper\ncerberus.data-center.zookeeper.session-timeout|zookeeper|number|15000|Zookeeper session timeout, measured in ***millisecond***\ncerberus.data-center.consul.host|consul|string|localhost|Connecting host to Consul client agent\ncerberus.data-center.consul.port|consul|number|8500|Connecting port to Consul client agent\ncerberus.data-center.etcd.end-points|etcd|string|http://localhost:2379|Endpoint urls to Etcd client\ncerberus.data-center.etcd.key-prefix|etcd|string|cerberus/services|Keys' prefix used to register service\ncerberus.data-center.etcd.service-ttl|etcd|number|5000|Service time to live in Etcd, measure in ***millisecond***\ncerberus.data-center.etcd.service-keep-interval|etcd|number|3000|Interval to keep service alive which should be smaller than ttl, measure in ***millisecond***\n\n### Client side\n\nAdd dependency in Maven:\n\n```maven\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.sinkedship.cerberus\u003c/groupId\u003e\n    \u003cartifactId\u003ecerberus-client-proxy-spring-boot-starter\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nCreate your own client Spring Boot application:\n\n* Provides all your business services to Spring using Java config style\n\n```java\n@Configuration\npublic class ServiceConfiguration {\n\n    @Bean\n    public A_Service.Async asyncAService(CerberusServiceFactory factory) {\n        return factory.newService(A_Service.Async.class);\n    }\n\n    @Bean\n    public A_Service aService(CerberusServiceFactory factory) {\n        return factory.newService(A_Service.class);\n    }\n\n    @Bean\n    public B_Service.Async asyncBService(CerberusServiceFactory factory) {\n        return factory.newService(B_Service.Async.class);\n    }\n\n    @Bean\n    public B_Service bService(CerberusServiceFactory factory) {\n        return factory.newService(B_Service.class);\n    }\n\n    // And so on\n}\n```\n\n```cerberus-client-proxy-spring-boot-start``` creates the ```CerberusServiceFactory``` internally and injected to Spring container if it's not appeared in Spring context. And of course, you can still provide your own ```CerberusServiceFactory``` to Spring manually without the autowired one as above.\n\n* Create your client Spring Boot application\n\n```java\n@SpringBootApplication\npublic class SampleStarterClient implements CommandLineRunner {\n\n    private final Logger logger = LoggerFactory.getLogger(SampleStarterClient.class);\n\n    // Autowired any services you have already defined\n    @Autowired\n    private A_Service aService;\n\n    // @Autowired\n    // private B_Service.Async bAsyncService;\n\n    public static void main(String[] args) {\n        SpringApplication.run(SampleStarterClient.class, args);\n    }\n\n    @Override\n    public void run(String... args) {\n        // aService.do_something(...);\n    }\n}\n```\n\nAll you need to do is defining your own Thrift services and let ```CerberusServiceFactory``` creates them for you and put them into Spring container.\n\n#### All available client configurations by now\n\nConfig key|Category|Type|Default value|Remark\n---|---|---|---:|:---\ncerberus.client.proxy.data-center|common|string(enum)|local|Data center used by Cerberus\ncerberus.client.proxy.connect-timeout|common|number|500|Connection timeout, measured in ***millisecond***\ncerberus.client.proxy.request-timeout|common|number|60000|Request timeout for a Thrift RPC call, measured in ***millisecond***\ncerberus.data-center.zookeeper.connect-string|zookeeper|string|localhost:2181|Connection string used to connect to Zookeeper: ***$HOST_1:$PORT_1,...,$HOST_X:$PORT_X***\ncerberus.data-center.zookeeper.base-path|zookeeper|string|cerberus|Path used as 'ROOT' path in Zookeeper\ncerberus.data-center.zookeeper.session-timeout|zookeeper|number|15000|Zookeeper session timeout, measured in ***millisecond***\ncerberus.data-center.local.connect-host|local|string|localhost|Host used to connect to remote server in Local data center mode\ncerberus.data-center.local.connect-port|local|number|0|Port used to connect to remove server in Local data center mode\ncerberus.data-center.consul.host|consul|string|localhost|Connecting host to Consul client agent\ncerberus.data-center.consul.port|consul|number|8500|Connecting port to Consul client agent\ncerberus.data-center.etcd.end-points|etcd|string|http://localhost:2379|Endpoint urls to Etcd client\ncerberus.data-center.etcd.key-prefix|etcd|string|cerberus/services|Keys' prefix used to register service\ncerberus.data-center.k8s.api-server-host|k8s|string|System ENV: KUBERNETES_SERVICE_HOST|K8S API server host\ncerberus.data-center.k8s.api-server-port|k8s|number|System ENV: KUBERNETES_SERVICE_PORT|K8S API server port\ncerberus.data-center.k8s.auth-token|k8s|string|Token file from ```/var/run/secrets/kubernetes.io/serviceaccount/token``` in pod|Auth token to create API client\ncerberus.data-center.k8s.namespace|k8s|string|default|Namespace in kubernetes\ncerberus.data-center.k8s.verify-ssl|k8s|boolean|true|Whether to verify certificate and hostname when making https requests to Kubernetes API server\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinkedship%2Fcerberus-spring-boot-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinkedship%2Fcerberus-spring-boot-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinkedship%2Fcerberus-spring-boot-starter/lists"}