Giter Site home page Giter Site logo

vaibhav-sinha / spring-remoting-grpc Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 10 KB

This library enables using Spring Remoting with gRPC as the underlying transport.

License: Apache License 2.0

Java 95.58% Protocol Buffer 4.42%
java java8 spring springframework grpc grpc-java remoting rpc protobuf3 protobuf

spring-remoting-grpc's Introduction

Spring Remoting gRPC

This library enables using Spring Remoting with gRPC as the underlying transport.

Installation

The artifact is available on Maven Central Repository and can be downloaded by adding the following dependency in pom.xml

<dependency>
    <groupId>com.github.vaibhav-sinha</groupId>
    <artifactId>spring-remoting-grpc</artifactId>
    <version>0.1.0</version>
</dependency>

Usage

Create a Service Exporter bean in the context of the service you want to expose

@Bean
public GrpcInvokerServiceExporter userServiceServer() {
    GrpcInvokerServiceExporter grpcInvokerServiceExporter = new GrpcInvokerServiceExporter();
    grpcInvokerServiceExporter.setServiceInterface(UserService.class);
    grpcInvokerServiceExporter.setService(userService());
    grpcInvokerServiceExporter.setPort(8888);
    return grpcInvokerServiceExporter;
}

Create a Proxy of the service on the client end

@Bean
public UserService userServiceClient() throws Exception {
    return (UserService) grpcInvokerProxyFactoryBean().getObject();
}

@Bean
public GrpcInvokerProxyFactoryBean grpcInvokerProxyFactoryBean() {
    GrpcInvokerProxyFactoryBean grpcInvokerProxyFactoryBean = new GrpcInvokerProxyFactoryBean();
    grpcInvokerProxyFactoryBean.setServiceUrl("localhost:8888");
    grpcInvokerProxyFactoryBean.setServiceInterface(UserService.class);
    return grpcInvokerProxyFactoryBean;
}

Look in the tests to find the complete example.

spring-remoting-grpc's People

Contributors

vaibhav-sinha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

spring-remoting-grpc's Issues

doubt

this is just a demo how to implement service discovery

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.