Coder Social home page Coder Social logo

cola's Introduction

cola

A light rpc framework.

Grab a cola and drink it, out of the box. (mainly due to a cats' name :), variable naming is the hardest part aha)

Just for learning, the implementation is naive, refactoring.

Features

  • Support multiple protocol such as JDK, Protostuff, hessian, JSON(fastjson), kyro.
  • Support features like load-balance(random, Round-Robin, Least-active, Consistent Hash).
  • Support service discovery services like ZooKeeper.
  • Support oneway, synchronous, asynchronous invoking and callback.
  • Easy integrated with provided Spring boot starter

Requirements

The minimum requirements to run the quick start are:

  • JDK 1.8 or above

Quick Start

ZooKeeper

start Zookeeper, docker example.

docker run --privileged=true -d --name zookeeper --publish 2181:2181  -d zookeeper:latest

import dependency

<dependency>
    <groupId>com.lunaticf</groupId>
    <artifactId>cola-spring-boot-starter</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

you can also use it without spring boot, see test for example.

configuration

// client
cola:
  loadbalance: random
  register: 127.0.0.1:2181
  serializer: hessian

// server
cola:
  register: 127.0.0.1:2181
  serializer: hessian
  server: 127.0.0.1:8888
  threads: 10

define service

public interface HelloService {
    String hello(String name);
}

server

// impl
@ColaService(HelloService.class)
public class HelloServiceImpl implements HelloService {
    @Override
    public String hello(String name) {
        return "hello ! " + name;
    }
}

client

@ColaReference(invokeType = InvokeType.AYSNC)
HelloService helloService;

// invoke
helloService.hello("lcf");
RPCFuture future = RPCContext.getContext().getFuture();

// add callback
future.addCallback(response -> {
 if (response.hasError()) {
    System.out.println("请求发送失败");
 } else {
    System.out.println("请求发送成功");
 }
});

System.out.println(future.get());

please refer to cola-example for detail.

cola's People

Contributors

lunaticf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.