Giter VIP home page Giter VIP logo

thrifts's Introduction

ThriftS

RPC is a classical server-client model, where client sends a request to server, and server replies results to client. ThriftS is a micro RPC framework based on Apache Thrift, it is designed to be as simple as possible, and it should be lightweight. Target language is c# and java.

Runtime

  • For .NET, writting in c#, and built on .NET Framework 4.0, no dependencies except Thrift.
  • For Java, built on java development kit 1.6. Because java generics erase mechanism itself, uses classmate to support generics serialization.

Features

  • No interface description language, using attributes/annotations instead of the Thrift IDL.
  • Based on the original encoding rules to implement the serialization and deserialization.
  • No Thrift code changed.
  • Using binary encoding, support for large data gzip compression.
  • Provide service monitoring using HTTP protocol.
  • Support connection pool in c# client.

Quick Start

I think it's good time for an example.

c# Contract

[ThriftSContract]
public interface IEmployeeService
{
    [ThriftSOperation]
    void SaveEmployee(Employee emp);
}

java Contract

@ThriftSContract
public interface IEmployeeService {
    @ThriftSOperation
    void saveEmployee(Employee emp);
}

c# Service side

public class EmployeeService : IEmployeeService
{
    public void SaveEmployee(Employee emp)
    {
        Console.WriteLine("client save employee. Id: {0},Name: {1}.", emp.EmployeeId, emp.EmployeeName);
    }
}

var server = new ThriftSServer();
server.Start();

java Service side

public class EmployeeService implements IEmployeeService {
    @Override
    public void saveEmployee(Employee emp){
        System.out.println("client save employee. Id: %s,Name: %s.", emp.getEmployeeId(), emp.getEmployeeName());
    }
}

Service side configuration: ThriftS.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="hostConfiguration" type="ThriftS.Service.HostConfigurationSetion,ThriftS.Service"/>
  </configSections>
  <hostConfiguration defaultHost="default" >
    <hosts>
      <host name="default" thriftPort="8384" httpPort="18384" minThreadPoolSize="5" maxThreadPoolSize="200" clientTimeout="60" useBufferedSockets="false">
        <services>
          <service contract="ThriftS.Test.Contract.IEmployeeService"
                   contractAssembly="ThriftS.Test.Contract"
                   handler="ThriftS.Test.Server.EmployeeService"
                   handlerAssembly="ThriftS.Test.Server" />
        </services>
      </host>
    </hosts>
  </hostConfiguration>
</configuration>

Client side

ThriftSClient client = new ThriftSClient("127.0.0.1", 8384);
var proxy = client.CreateProxy<IEmployeeService>();
var employee = new Employee() { EmployeeId = 18168, EmployeeName = "zeeman" };
proxy.SaveEmployee(employee);

Performance

A key feature of ThriftS is performance.

License

Apache License

About me

Email: [email protected]

thrifts's People

Contributors

zeemanhuang avatar scly avatar

Watchers

James Cloos avatar DY 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.