资源简介
GRPC简单应用(Java+Python),java和python版本的grpc调用实现,附文档
代码片段和文件信息
/*
* Copyright 2015 gRPC Authors All rights reserved.
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.taidi.nlp.ner.grpc;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.taidi.nlp.ner.grpc.DeepNerRequest.Builder;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.StatusRuntimeException;
/**
* A simple client that requests a greeting from the {@link HelloWorldServer}.
*/
public class DeepNerClient {
private static final Logger logger = Logger.getLogger(DeepNerClient.class.getName());
private final ManagedChannel channel;
private final QueryRpcGrpc.QueryRpcBlockingStub blockingStub;
/** Construct client connecting to HelloWorld server at {@code host:port}. */
public DeepNerClient(String host int port) {
this(ManagedChannelBuilder.forAddress(host port)
// Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
// needing certificates.
.usePlaintext(true)
.build());
}
/** Construct client for accessing RouteGuide server using the existing channel. */
DeepNerClient(ManagedChannel channel) {
this.channel = channel;
blockingStub = QueryRpcGrpc.newBlockingStub(channel);
}
public void shutdown() throws InterruptedException {
channel.shutdown().awaitTermination(5 TimeUnit.SECONDS);
}
/** Say hello to server. */
public void query(String name) {
logger.info(“Will try to greet “ + name + “ ...“);
Builder request = DeepNerRequest.newBuilder();
request.setQuery(“听听他们的歌“);
request.setDomain(“music“);
String[] str = {“False song False False False False False False False False False False False False False False False False False False False“
“False song False False False False False False False False False False False False False False False False False False False“
“False song False anaphor False False album False False False False False anaphor_song False False False False False False False False“
“False song False anaphor False False album False False False False False anaphor_song False False False False False False False False“
“False False False anaphor False False False False False False False False anaphor_song False False False False False False False False“
相关资源
- mysql数据处理,java用户登录处理
- 法律咨询信息系统(java+jsp+sqlserver)
- Java快速开发平台源码(renren-fast)
- 锐聘学院QST青软JavaWeb十二个打包
- 3.3.6微信支付JAVA版demo
- javaweb网上购物系统源码(附数据库脚
- javaweb校园宿舍系统(附数据库脚本)
- JavaWeb书城项目(附数据库脚本)
- 基于JAVA_JSP电子书系统(源码+数据库
- Java网络编程知识点总结.xmind
- 一站式Java网络编程 BIO-NIO-AIO资料源码
- jsp讲解
- 基于SSH框架的JavaWeb项目—人员信息管
- javaweb实现的邮件收发系统(附数据库
- Java 仿QQ(附客户端以及服务端源码)
- Java TCP IP Socket
- java定时发送邮件(基于quartz)
- Java Swing开发的《星际争霸》游戏
- java+数据库商品交易管理系统(附数据
- 使用java语言编译一个计算器
- java swing工资管理系统(源码+数据库
- JAVALibrary
- 微信企业号回调模式Java版
- 顺丰丰桥接口开发详细教程源码含下
- Java博客概要设计文档
- 药品进销存管理系统(论文范文_JSP
- 奖学金管理系统java+jsp+mysql
- 毕设参考——基于java酒店管理
- Java写的一个简单的字体更改程序
- java8学习教程之lambda表达式的使用方法
评论
共有 条评论