Coder Social home page Coder Social logo

varpa89 / spring-thrift-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aatarasoff/spring-thrift-starter

0.0 1.0 0.0 242 KB

Set of cool annotations that helps you building Thrift applications with Spring Boot

License: MIT License

Java 100.00%

spring-thrift-starter's Introduction

Apache Thrift Starter for Spring Boot

Join the chat at https://gitter.im/aatarasoff/spring-thrift-starter Build Status

Set of cool annotations that helps you building Thrift applications with Spring Boot.

How to connect the project

Its very simple:

repositories {
    jcenter()
}
compile 'info.developerblog.spring.thrift:spring-thrift-starter:1.4.0.RELEASE'

How to use this

Server-side

Annotation @ThriftController("servlet_path") helps you building server controller for request processing

@ThriftController("/api")
public class TGreetingServiceController implements TGreetingService.Iface {

    @Override
    public String greet(TName name) throws TException {
        // your logic
    }
}

Client-side

@ThriftClient(serviceId = "registered_service", (path) = "server_handler_path") helps you with multithreaded client with full Spring Cloud support.

@ThriftClient(serviceId = "greeting-service", path = "/api")
TGreetingService.Client client;

@ThriftClientsMap(mapperClass) annotation helps to create a string-keyed map of clients for a set of services having the same interface, allowing to define the concrete callee instance at runtime:

@ThriftClientsMap(mapperClass = SampleMapper.class)
Map<String, TGreetingService.Client> clientsMap;

Mapper class requirements:

  • must extend AbstractThriftClientKeyMapper
  • must be registered as a bean in the application context

Thrift Client configuration

greeting-service:                     #service name
  endpoint: http://localhost:8080/api #direct endpoint
  ribbon:                             #manually ribbon
      listOfServers: localhost:8080
  path: /service                      #general path
  connectTimeout: 1000                #default=1000
  readTimeout: 10000                  #default=30000

thrift.client.max.threads: 10         #default=8

If you use service discovery backend (as Eureka or Consul) only path maybe needed.

See tests for better understanding.

Sleuth support

Since 1.0.0 starter have supported Spring Cloud Sleuth for tracing.

Special thanks to

Enjoy!

spring-thrift-starter's People

Contributors

aatarasoff avatar jihor avatar lavcraft avatar matthew-gladyshev avatar enrique-fernandez-polo avatar salmondx avatar sergeevii123 avatar gitter-badger avatar adyach avatar alekseigoremykin avatar

Watchers

Pavel Varchenko 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.