{"id":19877652,"url":"https://github.com/outbrain-inc/ob1k","last_synced_at":"2025-05-02T12:30:51.274Z","repository":{"id":22249098,"uuid":"25582637","full_name":"outbrain-inc/ob1k","owner":"outbrain-inc","description":"Ob1k - The RPC Framework","archived":true,"fork":false,"pushed_at":"2024-09-10T11:20:48.000Z","size":3128,"stargazers_count":78,"open_issues_count":2,"forks_count":26,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-16T05:41:44.645Z","etag":null,"topics":["asynchronous","composable-futures","java","netty","rpc-framework"],"latest_commit_sha":null,"homepage":null,"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/outbrain-inc.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-10-22T13:24:51.000Z","updated_at":"2024-11-11T18:44:40.000Z","dependencies_parsed_at":"2024-09-10T12:10:52.058Z","dependency_job_id":null,"html_url":"https://github.com/outbrain-inc/ob1k","commit_stats":null,"previous_names":["outbrain-inc/ob1k","outbrain/ob1k"],"tags_count":308,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2Fob1k","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2Fob1k/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2Fob1k/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outbrain-inc%2Fob1k/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outbrain-inc","download_url":"https://codeload.github.com/outbrain-inc/ob1k/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038097,"owners_count":21684624,"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":["asynchronous","composable-futures","java","netty","rpc-framework"],"created_at":"2024-11-12T17:00:28.349Z","updated_at":"2025-05-02T12:30:51.268Z","avatar_url":"https://github.com/outbrain-inc.png","language":"Java","readme":"# Ob1k - A modern RPC Framework\n\n[![Build Status](https://travis-ci.org/outbrain/ob1k.svg?branch=master)](https://travis-ci.org/outbrain/ob1k)\n[![Download](https://api.bintray.com/packages/outbrain/OutbrainOSS/OB1K/images/download.svg)](https://bintray.com/outbrain/OutbrainOSS/OB1K/_latestVersion)\n\n## Overview \nOb1k is an asynchronous light-weight RPC framework for rapid development of async, high performance micro-services.\nUnlike traditional servlet containers, Ob1k is based on [Netty](http://netty.io/) , doing asynchronous event-driven model, and uses a fixed thread-per-core pool for serving.\n\nThe coordination of an asynchronous request is performed by using [ComposableFuture](https://github.com/outbrain/ob1k/tree/master/ob1k-concurrent), which enable you to easily create, compose and combine asynchonous computations.\n\nYou can start an Ob1k embedded server from your code and once started it will serve HTTP requests based on the endpoints you have configured. Check out our [examples](https://github.com/outbrain/ob1k/tree/master/ob1k-example) for that.\n\n## Anatomy \nOb1k project consists of the following sub libraries:\n - **ob1k-concurrent**        - Concurrency utils, contains [ComposableFuture](https://github.com/outbrain/ob1k/tree/master/ob1k-concurrent) - an alternative implementation of futures in Java.\n - **ob1k-core**              - RPC framework client and server infrastructure.\n - **ob1k-http**              - Asynchronous HTTP client\n - **ob1k-db**                - Asynchronous MySQL client.\n - **ob1k-cache**             - Asynchronous Memcached client, and guava cache wrapper.\n - **ob1k-cql**               - Asynchronous Cassandra client.\n - **ob1k-security**          - Authentication and authorization for Ob1k.\n - **ob1k-consul**            - Ob1k based [Consul](https://consul.io/) API which simplifies registration and discovery for Ob1k services.\n - **ob1k-swagger**           - Ob1k swagger plugin that will generate the Swagger APi protocol and also provide the Swagger UI.\n\n## Getting started \nMicro-services architecture consists of a group of different services which communicate with each other.\nOb1k supplies the infrastructure to build such microservices and the means for them to communicate.\nThe communication between services is based on a RPC protocol, (HTTP with JSON or [MessagePack](http://msgpack.org/) payload), using a user provided, strongly typed interface.\n\n*Ob1k* is published to [Bintray](https://bintray.com/outbrain/OutbrainOSS/OB1K).\n\n### Setting up Maven\nTo start using Ob1k, add the following dependency to your pom:\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.outbrain.swinfra\u003c/groupId\u003e\n  \u003cartifactId\u003eob1k-core\u003c/artifactId\u003e\n  \u003cversion\u003e0.x\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Ob1k Server\nLet's start with creating an Ob1k server.\n\nThe first step will be creating a new Ob1k service.\nA [service](https://github.com/outbrain/ob1k/blob/master/ob1k-core/src/main/java/com/outbrain/ob1k/Service.java) (similar to [controller](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller#Components) in MVC) aggregates set of related endpoints into one serving context.\nEach method in the implementation will be mapped to a URL which clients as well as a simple web browsers can invoke.\nIn the next example we are create a service with an endpoint named `helloWorld` which gets no arguments and returns a string.\n\n```java\npublic interface IHelloService extends Service {\n   ComposableFuture\u003cString\u003e helloWorld();\n}\n```\n\nThe method implementation just returns a \"Hello world\" string which will be returned by the Ob1k framework to the client:\n\n```java \npublic class HelloService implements IHelloService {\n   @Override\n   public ComposableFuture\u003cString\u003e helloWorld() {\n     return fromValue(\"Hello World!\");\n   }\n}\n```\n \nNow that you have the service endpoint we can build the Ob1k server. For that, we will need to set the port to use and the base URL which is called context.\nIn addition we need to bind our services to a URL under the context. After setting some more properties (e.g. requestTimeout) we call the build method and this creates a server.\n\n```java \nfinal Server server = ServerBuilder.newBuilder().\n  contextPath(\"/services\").\n  configure(builder -\u003e builder.usePort(8080).requestTimeout(50, TimeUnit.MILLISECONDS)).\n  service(builder -\u003e builder.register(new HelloService(), \"/hello\")).\n  build();\n```\n\nTo start the server:\n```java\nserver.start(); \n```\nNow you can access the service endpoint just go to \n    http://localhost:8080/services/hello/helloWorld\n\n\n### Ob1k Client\nNow we are going to create an Ob1k client. Most of the times Ob1k clients are going to be executed inside an Ob1k service, but for simplicity we will show just the client code for now.\nWe use the `ClientBuilder` to build the client by specifying a target URL, the interface of the service we're invoking, content type (which is controlled by the client) and can be either JSON or MessagePack, timeouts, etc.\n```java\nfinal String target = \"http://localhost:8080/services/hello\";\nfinal IHelloService helloService = new ClientBuilder\u003c\u003e(IHelloService.class).\n            setProtocol(ContentType.JSON).\n            setRequestTimeout(-1).\n            setTargetProvider(new SimpleTargetProvider(target)).\n            build();\n```\nNow that we have `helloService` we can invoke methods on it which will be directed automatically to the server.\n```java\nfinal ComposableFuture\u003cString\u003e helloWorld = helloService.helloWorld();\nSystem.out.println(helloWorld.get());\n```\n\nAnd that's it :)\n\n\n## Examples\nMore examples can be found here \n[ob1k-example](https://github.com/outbrain/ob1k/tree/master/ob1k-example/src/main/java/com/outbrain/ob1k/example/)\n\n## Links\n[Ob1k Presentation Slides](http://www.slideshare.net/eranharel/ob1k-presentation-at-javail)\n\n## License\nOb1k is released under version 2.0 of the [Apache License](http://www.apache.org/licenses/LICENSE-2.0).\n","funding_links":[],"categories":["开发框架"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutbrain-inc%2Fob1k","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutbrain-inc%2Fob1k","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutbrain-inc%2Fob1k/lists"}