Commit 795ebdd6 authored by liuyan's avatar liuyan

add:增加测试grpc代码和项目结构说明

parent 5a40de11
File added
......@@ -42,6 +42,11 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.devh</groupId>-->
<!-- <artifactId>grpc-spring-boot-starter</artifactId>-->
<!-- <version>2.15.0.RELEASE</version>-->
<!-- </dependency>-->
<!-- 核心模块-->
<dependency>
......@@ -61,10 +66,60 @@
<artifactId>ruoyi-generator</artifactId>
</dependency>
<!-- gRPC 核心库 -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.56.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.56.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.56.1</version>
</dependency>
</dependencies>
<build>
<extensions>
<!-- 引入 os-maven-plugin 插件 -->
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.1</version>
</extension>
</extensions>
<plugins>
<!--protoc-gen-grpc-java 是一个用于 Protocol Buffers(Protobuf)的代码生成插件-->
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<!-- 指定 protoc 编译器的依赖 -->
<protocArtifact>com.google.protobuf:protoc:3.21.12:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<!-- 指定 protoc-gen-grpc-java 插件的依赖 -->
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.56.1:exe:${os.detected.classifier}</pluginArtifact>
<protoSourceRoot>src/main/proto</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......@@ -93,4 +148,4 @@
<finalName>${project.artifactId}</finalName>
</build>
</project>
\ No newline at end of file
</project>
package com.ruoyi;
import com.ruoyi.client.server.GrpcFileServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* @return
* @Version: v1.0
* @Author: LiuYan
* @Date 2025-4-12 15:35
*
* 服务启动以后需要回调启动grpc服务
*
**/
@Component
@Order(1) // 多个 Runner 时定义执行顺序(值越小优先级越高)
public class MyCommandLineRunner implements CommandLineRunner {
@Autowired
GrpcFileServer grpcFileServer;
@Override
public void run(String... args) {
grpcFileServer.initServer();
}
}
package com.ruoyi.client.server;
import com.ruoyi.client.service.FileServiceImpl;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//自己实现的grpc服务类
@Component
public class GrpcFileServer {
@Autowired
private FileServiceImpl fileServiceImpl;
public void initServer(){
try {
// 创建服务实例
Server server = ServerBuilder.forPort(50051)
.addService(fileServiceImpl) // 关键控制器注册
.build();
server.start();
System.out.println("Server started on port 50051");
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
//当JVM关闭时回调钩子,关闭grpc服务
server.shutdown();
System.out.println("Server stopped");
}));
//保持主进程不退出持续监控
server.awaitTermination();
}catch (Exception e){
e.printStackTrace();
}
}
}
package com.ruoyi.client.service;
import com.google.protobuf.ByteString;
import com.ruoyi.grpc.file.*;
import io.grpc.stub.StreamObserver;
import org.springframework.stereotype.Service;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@Service
public class FileServiceImpl extends FileServiceGrpc.FileServiceImplBase {
@Override
public StreamObserver<FileUploadRequest> uploadFile(StreamObserver<FileUploadResponse> responseObserver) {
return new StreamObserver<FileUploadRequest>() {
private String filename;
private FileOutputStream fos;
private long totalSize = 0;
@Override
public void onNext(FileUploadRequest request) {
if (request.hasFilename()) {
filename = request.getFilename();
try {
fos = new FileOutputStream("server_files/" + filename);
} catch (IOException e) {
responseObserver.onError(e);
}
} else {
try {
byte[] chunk = request.getChunk().toByteArray();
totalSize += chunk.length;
fos.write(chunk);
} catch (IOException e) {
responseObserver.onError(e);
}
}
}
@Override
public void onError(Throwable t) {
System.err.println("Upload failed: " + t.getMessage());
}
@Override
public void onCompleted() {
try {
fos.close();
responseObserver.onNext(FileUploadResponse.newBuilder()
.setStatus("Success")
.setSize(totalSize)
.build());
responseObserver.onCompleted();
} catch (IOException e) {
responseObserver.onError(e);
}
}
};
}
@Override
public void downloadFile(FileDownloadRequest request,
StreamObserver<FileDownloadResponse> responseObserver) {
try {
java.io.File file = new java.io.File("server_files/" + request.getFilename());
FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[64 * 1024]; // 64KB chunks
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
responseObserver.onNext(FileDownloadResponse.newBuilder()
.setChunk(ByteString.copyFrom(buffer, 0, bytesRead))
.build());
}
fis.close();
responseObserver.onCompleted();
} catch (IOException e) {
responseObserver.onError(e);
}
}
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
public final class File {
private File() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
static final com.google.protobuf.Descriptors.Descriptor
internal_static_FileUploadRequest_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_FileUploadRequest_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_FileUploadResponse_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_FileUploadResponse_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_FileDownloadRequest_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_FileDownloadRequest_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor
internal_static_FileDownloadResponse_descriptor;
static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_FileDownloadResponse_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
String[] descriptorData = {
"\n\nfile.proto\"@\n\021FileUploadRequest\022\022\n\010fil" +
"ename\030\001 \001(\tH\000\022\017\n\005chunk\030\002 \001(\014H\000B\006\n\004data\"2" +
"\n\022FileUploadResponse\022\016\n\006status\030\001 \001(\t\022\014\n\004" +
"size\030\002 \001(\003\"\'\n\023FileDownloadRequest\022\020\n\010fil" +
"ename\030\001 \001(\t\"%\n\024FileDownloadResponse\022\r\n\005c" +
"hunk\030\001 \001(\0142\205\001\n\013FileService\0227\n\nUploadFile" +
"\022\022.FileUploadRequest\032\023.FileUploadRespons" +
"e(\001\022=\n\014DownloadFile\022\024.FileDownloadReques" +
"t\032\025.FileDownloadResponse0\001B\035\n\023com.ruoyi." +
"grpc.fileP\001Z\004./pbb\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
});
internal_static_FileUploadRequest_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_FileUploadRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_FileUploadRequest_descriptor,
new String[] { "Filename", "Chunk", "Data", });
internal_static_FileUploadResponse_descriptor =
getDescriptor().getMessageTypes().get(1);
internal_static_FileUploadResponse_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_FileUploadResponse_descriptor,
new String[] { "Status", "Size", });
internal_static_FileDownloadRequest_descriptor =
getDescriptor().getMessageTypes().get(2);
internal_static_FileDownloadRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_FileDownloadRequest_descriptor,
new String[] { "Filename", });
internal_static_FileDownloadResponse_descriptor =
getDescriptor().getMessageTypes().get(3);
internal_static_FileDownloadResponse_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_FileDownloadResponse_descriptor,
new String[] { "Chunk", });
}
// @@protoc_insertion_point(outer_class_scope)
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
/**
* Protobuf type {@code FileDownloadRequest}
*/
public final class FileDownloadRequest extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:FileDownloadRequest)
FileDownloadRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use FileDownloadRequest.newBuilder() to construct.
private FileDownloadRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private FileDownloadRequest() {
filename_ = "";
}
@Override
@SuppressWarnings({"unused"})
protected Object newInstance(
UnusedPrivateParameter unused) {
return new FileDownloadRequest();
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileDownloadRequest_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileDownloadRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileDownloadRequest.class, Builder.class);
}
public static final int FILENAME_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile Object filename_ = "";
/**
* <code>string filename = 1;</code>
* @return The filename.
*/
@Override
public String getFilename() {
Object ref = filename_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
filename_ = s;
return s;
}
}
/**
* <code>string filename = 1;</code>
* @return The bytes for filename.
*/
@Override
public com.google.protobuf.ByteString
getFilenameBytes() {
Object ref = filename_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
filename_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filename_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, filename_);
}
getUnknownFields().writeTo(output);
}
@Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filename_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, filename_);
}
size += getUnknownFields().getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof FileDownloadRequest)) {
return super.equals(obj);
}
FileDownloadRequest other = (FileDownloadRequest) obj;
if (!getFilename()
.equals(other.getFilename())) return false;
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
return true;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + FILENAME_FIELD_NUMBER;
hash = (53 * hash) + getFilename().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static FileDownloadRequest parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileDownloadRequest parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileDownloadRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileDownloadRequest parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileDownloadRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileDownloadRequest parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileDownloadRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileDownloadRequest parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static FileDownloadRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static FileDownloadRequest parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static FileDownloadRequest parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileDownloadRequest parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(FileDownloadRequest prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code FileDownloadRequest}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:FileDownloadRequest)
FileDownloadRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileDownloadRequest_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileDownloadRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileDownloadRequest.class, Builder.class);
}
// Construct using com.ruoyi.grpc.file.FileDownloadRequest.newBuilder()
private Builder() {
}
private Builder(
BuilderParent parent) {
super(parent);
}
@Override
public Builder clear() {
super.clear();
bitField0_ = 0;
filename_ = "";
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return File.internal_static_FileDownloadRequest_descriptor;
}
@Override
public FileDownloadRequest getDefaultInstanceForType() {
return FileDownloadRequest.getDefaultInstance();
}
@Override
public FileDownloadRequest build() {
FileDownloadRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public FileDownloadRequest buildPartial() {
FileDownloadRequest result = new FileDownloadRequest(this);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartial0(FileDownloadRequest result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.filename_ = filename_;
}
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof FileDownloadRequest) {
return mergeFrom((FileDownloadRequest)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(FileDownloadRequest other) {
if (other == FileDownloadRequest.getDefaultInstance()) return this;
if (!other.getFilename().isEmpty()) {
filename_ = other.filename_;
bitField0_ |= 0x00000001;
onChanged();
}
this.mergeUnknownFields(other.getUnknownFields());
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
if (extensionRegistry == null) {
throw new NullPointerException();
}
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
filename_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
default: {
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
done = true; // was an endgroup tag
}
break;
} // default:
} // switch (tag)
} // while (!done)
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.unwrapIOException();
} finally {
onChanged();
} // finally
return this;
}
private int bitField0_;
private Object filename_ = "";
/**
* <code>string filename = 1;</code>
* @return The filename.
*/
public String getFilename() {
Object ref = filename_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
filename_ = s;
return s;
} else {
return (String) ref;
}
}
/**
* <code>string filename = 1;</code>
* @return The bytes for filename.
*/
public com.google.protobuf.ByteString
getFilenameBytes() {
Object ref = filename_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
filename_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string filename = 1;</code>
* @param value The filename to set.
* @return This builder for chaining.
*/
public Builder setFilename(
String value) {
if (value == null) { throw new NullPointerException(); }
filename_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <code>string filename = 1;</code>
* @return This builder for chaining.
*/
public Builder clearFilename() {
filename_ = getDefaultInstance().getFilename();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
* <code>string filename = 1;</code>
* @param value The bytes for filename to set.
* @return This builder for chaining.
*/
public Builder setFilenameBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
filename_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:FileDownloadRequest)
}
// @@protoc_insertion_point(class_scope:FileDownloadRequest)
private static final FileDownloadRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new FileDownloadRequest();
}
public static FileDownloadRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<FileDownloadRequest>
PARSER = new com.google.protobuf.AbstractParser<FileDownloadRequest>() {
@Override
public FileDownloadRequest parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
Builder builder = newBuilder();
try {
builder.mergeFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(builder.buildPartial());
} catch (com.google.protobuf.UninitializedMessageException e) {
throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(e)
.setUnfinishedMessage(builder.buildPartial());
}
return builder.buildPartial();
}
};
public static com.google.protobuf.Parser<FileDownloadRequest> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<FileDownloadRequest> getParserForType() {
return PARSER;
}
@Override
public FileDownloadRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
public interface FileDownloadRequestOrBuilder extends
// @@protoc_insertion_point(interface_extends:FileDownloadRequest)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string filename = 1;</code>
* @return The filename.
*/
String getFilename();
/**
* <code>string filename = 1;</code>
* @return The bytes for filename.
*/
com.google.protobuf.ByteString
getFilenameBytes();
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
/**
* Protobuf type {@code FileDownloadResponse}
*/
public final class FileDownloadResponse extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:FileDownloadResponse)
FileDownloadResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use FileDownloadResponse.newBuilder() to construct.
private FileDownloadResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private FileDownloadResponse() {
chunk_ = com.google.protobuf.ByteString.EMPTY;
}
@Override
@SuppressWarnings({"unused"})
protected Object newInstance(
UnusedPrivateParameter unused) {
return new FileDownloadResponse();
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileDownloadResponse_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileDownloadResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileDownloadResponse.class, Builder.class);
}
public static final int CHUNK_FIELD_NUMBER = 1;
private com.google.protobuf.ByteString chunk_ = com.google.protobuf.ByteString.EMPTY;
/**
* <code>bytes chunk = 1;</code>
* @return The chunk.
*/
@Override
public com.google.protobuf.ByteString getChunk() {
return chunk_;
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!chunk_.isEmpty()) {
output.writeBytes(1, chunk_);
}
getUnknownFields().writeTo(output);
}
@Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!chunk_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, chunk_);
}
size += getUnknownFields().getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof FileDownloadResponse)) {
return super.equals(obj);
}
FileDownloadResponse other = (FileDownloadResponse) obj;
if (!getChunk()
.equals(other.getChunk())) return false;
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
return true;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + CHUNK_FIELD_NUMBER;
hash = (53 * hash) + getChunk().hashCode();
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static FileDownloadResponse parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileDownloadResponse parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileDownloadResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileDownloadResponse parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileDownloadResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileDownloadResponse parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileDownloadResponse parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileDownloadResponse parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static FileDownloadResponse parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static FileDownloadResponse parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static FileDownloadResponse parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileDownloadResponse parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(FileDownloadResponse prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code FileDownloadResponse}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:FileDownloadResponse)
FileDownloadResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileDownloadResponse_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileDownloadResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileDownloadResponse.class, Builder.class);
}
// Construct using com.ruoyi.grpc.file.FileDownloadResponse.newBuilder()
private Builder() {
}
private Builder(
BuilderParent parent) {
super(parent);
}
@Override
public Builder clear() {
super.clear();
bitField0_ = 0;
chunk_ = com.google.protobuf.ByteString.EMPTY;
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return File.internal_static_FileDownloadResponse_descriptor;
}
@Override
public FileDownloadResponse getDefaultInstanceForType() {
return FileDownloadResponse.getDefaultInstance();
}
@Override
public FileDownloadResponse build() {
FileDownloadResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public FileDownloadResponse buildPartial() {
FileDownloadResponse result = new FileDownloadResponse(this);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartial0(FileDownloadResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.chunk_ = chunk_;
}
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof FileDownloadResponse) {
return mergeFrom((FileDownloadResponse)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(FileDownloadResponse other) {
if (other == FileDownloadResponse.getDefaultInstance()) return this;
if (other.getChunk() != com.google.protobuf.ByteString.EMPTY) {
setChunk(other.getChunk());
}
this.mergeUnknownFields(other.getUnknownFields());
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
if (extensionRegistry == null) {
throw new NullPointerException();
}
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
chunk_ = input.readBytes();
bitField0_ |= 0x00000001;
break;
} // case 10
default: {
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
done = true; // was an endgroup tag
}
break;
} // default:
} // switch (tag)
} // while (!done)
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.unwrapIOException();
} finally {
onChanged();
} // finally
return this;
}
private int bitField0_;
private com.google.protobuf.ByteString chunk_ = com.google.protobuf.ByteString.EMPTY;
/**
* <code>bytes chunk = 1;</code>
* @return The chunk.
*/
@Override
public com.google.protobuf.ByteString getChunk() {
return chunk_;
}
/**
* <code>bytes chunk = 1;</code>
* @param value The chunk to set.
* @return This builder for chaining.
*/
public Builder setChunk(com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
chunk_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <code>bytes chunk = 1;</code>
* @return This builder for chaining.
*/
public Builder clearChunk() {
bitField0_ = (bitField0_ & ~0x00000001);
chunk_ = getDefaultInstance().getChunk();
onChanged();
return this;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:FileDownloadResponse)
}
// @@protoc_insertion_point(class_scope:FileDownloadResponse)
private static final FileDownloadResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new FileDownloadResponse();
}
public static FileDownloadResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<FileDownloadResponse>
PARSER = new com.google.protobuf.AbstractParser<FileDownloadResponse>() {
@Override
public FileDownloadResponse parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
Builder builder = newBuilder();
try {
builder.mergeFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(builder.buildPartial());
} catch (com.google.protobuf.UninitializedMessageException e) {
throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(e)
.setUnfinishedMessage(builder.buildPartial());
}
return builder.buildPartial();
}
};
public static com.google.protobuf.Parser<FileDownloadResponse> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<FileDownloadResponse> getParserForType() {
return PARSER;
}
@Override
public FileDownloadResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
public interface FileDownloadResponseOrBuilder extends
// @@protoc_insertion_point(interface_extends:FileDownloadResponse)
com.google.protobuf.MessageOrBuilder {
/**
* <code>bytes chunk = 1;</code>
* @return The chunk.
*/
com.google.protobuf.ByteString getChunk();
}
package com.ruoyi.grpc.file;
import static io.grpc.MethodDescriptor.generateFullMethodName;
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.56.1)",
comments = "Source: file.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class FileServiceGrpc {
private FileServiceGrpc() {}
public static final String SERVICE_NAME = "FileService";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<FileUploadRequest,
FileUploadResponse> getUploadFileMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "UploadFile",
requestType = FileUploadRequest.class,
responseType = FileUploadResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
public static io.grpc.MethodDescriptor<FileUploadRequest,
FileUploadResponse> getUploadFileMethod() {
io.grpc.MethodDescriptor<FileUploadRequest, FileUploadResponse> getUploadFileMethod;
if ((getUploadFileMethod = FileServiceGrpc.getUploadFileMethod) == null) {
synchronized (FileServiceGrpc.class) {
if ((getUploadFileMethod = FileServiceGrpc.getUploadFileMethod) == null) {
FileServiceGrpc.getUploadFileMethod = getUploadFileMethod =
io.grpc.MethodDescriptor.<FileUploadRequest, FileUploadResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "UploadFile"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
FileUploadRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
FileUploadResponse.getDefaultInstance()))
.setSchemaDescriptor(new FileServiceMethodDescriptorSupplier("UploadFile"))
.build();
}
}
}
return getUploadFileMethod;
}
private static volatile io.grpc.MethodDescriptor<FileDownloadRequest,
FileDownloadResponse> getDownloadFileMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "DownloadFile",
requestType = FileDownloadRequest.class,
responseType = FileDownloadResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
public static io.grpc.MethodDescriptor<FileDownloadRequest,
FileDownloadResponse> getDownloadFileMethod() {
io.grpc.MethodDescriptor<FileDownloadRequest, FileDownloadResponse> getDownloadFileMethod;
if ((getDownloadFileMethod = FileServiceGrpc.getDownloadFileMethod) == null) {
synchronized (FileServiceGrpc.class) {
if ((getDownloadFileMethod = FileServiceGrpc.getDownloadFileMethod) == null) {
FileServiceGrpc.getDownloadFileMethod = getDownloadFileMethod =
io.grpc.MethodDescriptor.<FileDownloadRequest, FileDownloadResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "DownloadFile"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
FileDownloadRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
FileDownloadResponse.getDefaultInstance()))
.setSchemaDescriptor(new FileServiceMethodDescriptorSupplier("DownloadFile"))
.build();
}
}
}
return getDownloadFileMethod;
}
/**
* Creates a new async stub that supports all call types for the service
*/
public static FileServiceStub newStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<FileServiceStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<FileServiceStub>() {
@Override
public FileServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new FileServiceStub(channel, callOptions);
}
};
return FileServiceStub.newStub(factory, channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static FileServiceBlockingStub newBlockingStub(
io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<FileServiceBlockingStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<FileServiceBlockingStub>() {
@Override
public FileServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new FileServiceBlockingStub(channel, callOptions);
}
};
return FileServiceBlockingStub.newStub(factory, channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on the service
*/
public static FileServiceFutureStub newFutureStub(
io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<FileServiceFutureStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<FileServiceFutureStub>() {
@Override
public FileServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new FileServiceFutureStub(channel, callOptions);
}
};
return FileServiceFutureStub.newStub(factory, channel);
}
/**
*/
public interface AsyncService {
/**
*/
default io.grpc.stub.StreamObserver<FileUploadRequest> uploadFile(
io.grpc.stub.StreamObserver<FileUploadResponse> responseObserver) {
return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall(getUploadFileMethod(), responseObserver);
}
/**
*/
default void downloadFile(FileDownloadRequest request,
io.grpc.stub.StreamObserver<FileDownloadResponse> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getDownloadFileMethod(), responseObserver);
}
}
/**
* Base class for the server implementation of the service FileService.
*/
public static abstract class FileServiceImplBase
implements io.grpc.BindableService, AsyncService {
@Override public final io.grpc.ServerServiceDefinition bindService() {
return FileServiceGrpc.bindService(this);
}
}
/**
* A stub to allow clients to do asynchronous rpc calls to service FileService.
*/
public static final class FileServiceStub
extends io.grpc.stub.AbstractAsyncStub<FileServiceStub> {
private FileServiceStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected FileServiceStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new FileServiceStub(channel, callOptions);
}
/**
*/
public io.grpc.stub.StreamObserver<FileUploadRequest> uploadFile(
io.grpc.stub.StreamObserver<FileUploadResponse> responseObserver) {
return io.grpc.stub.ClientCalls.asyncClientStreamingCall(
getChannel().newCall(getUploadFileMethod(), getCallOptions()), responseObserver);
}
/**
*/
public void downloadFile(FileDownloadRequest request,
io.grpc.stub.StreamObserver<FileDownloadResponse> responseObserver) {
io.grpc.stub.ClientCalls.asyncServerStreamingCall(
getChannel().newCall(getDownloadFileMethod(), getCallOptions()), request, responseObserver);
}
}
/**
* A stub to allow clients to do synchronous rpc calls to service FileService.
*/
public static final class FileServiceBlockingStub
extends io.grpc.stub.AbstractBlockingStub<FileServiceBlockingStub> {
private FileServiceBlockingStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected FileServiceBlockingStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new FileServiceBlockingStub(channel, callOptions);
}
/**
*/
public java.util.Iterator<FileDownloadResponse> downloadFile(
FileDownloadRequest request) {
return io.grpc.stub.ClientCalls.blockingServerStreamingCall(
getChannel(), getDownloadFileMethod(), getCallOptions(), request);
}
}
/**
* A stub to allow clients to do ListenableFuture-style rpc calls to service FileService.
*/
public static final class FileServiceFutureStub
extends io.grpc.stub.AbstractFutureStub<FileServiceFutureStub> {
private FileServiceFutureStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@Override
protected FileServiceFutureStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new FileServiceFutureStub(channel, callOptions);
}
}
private static final int METHODID_DOWNLOAD_FILE = 0;
private static final int METHODID_UPLOAD_FILE = 1;
private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final AsyncService serviceImpl;
private final int methodId;
MethodHandlers(AsyncService serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@Override
@SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_DOWNLOAD_FILE:
serviceImpl.downloadFile((FileDownloadRequest) request,
(io.grpc.stub.StreamObserver<FileDownloadResponse>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@Override
@SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_UPLOAD_FILE:
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.uploadFile(
(io.grpc.stub.StreamObserver<FileUploadResponse>) responseObserver);
default:
throw new AssertionError();
}
}
}
public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getUploadFileMethod(),
io.grpc.stub.ServerCalls.asyncClientStreamingCall(
new MethodHandlers<
FileUploadRequest,
FileUploadResponse>(
service, METHODID_UPLOAD_FILE)))
.addMethod(
getDownloadFileMethod(),
io.grpc.stub.ServerCalls.asyncServerStreamingCall(
new MethodHandlers<
FileDownloadRequest,
FileDownloadResponse>(
service, METHODID_DOWNLOAD_FILE)))
.build();
}
private static abstract class FileServiceBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
FileServiceBaseDescriptorSupplier() {}
@Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return File.getDescriptor();
}
@Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("FileService");
}
}
private static final class FileServiceFileDescriptorSupplier
extends FileServiceBaseDescriptorSupplier {
FileServiceFileDescriptorSupplier() {}
}
private static final class FileServiceMethodDescriptorSupplier
extends FileServiceBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final String methodName;
FileServiceMethodDescriptorSupplier(String methodName) {
this.methodName = methodName;
}
@Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (FileServiceGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new FileServiceFileDescriptorSupplier())
.addMethod(getUploadFileMethod())
.addMethod(getDownloadFileMethod())
.build();
}
}
}
return result;
}
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
/**
* Protobuf type {@code FileUploadRequest}
*/
public final class FileUploadRequest extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:FileUploadRequest)
FileUploadRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use FileUploadRequest.newBuilder() to construct.
private FileUploadRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private FileUploadRequest() {
}
@Override
@SuppressWarnings({"unused"})
protected Object newInstance(
UnusedPrivateParameter unused) {
return new FileUploadRequest();
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileUploadRequest_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileUploadRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileUploadRequest.class, Builder.class);
}
private int dataCase_ = 0;
private Object data_;
public enum DataCase
implements com.google.protobuf.Internal.EnumLite,
InternalOneOfEnum {
FILENAME(1),
CHUNK(2),
DATA_NOT_SET(0);
private final int value;
private DataCase(int value) {
this.value = value;
}
/**
* @param value The number of the enum to look for.
* @return The enum associated with the given number.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@Deprecated
public static DataCase valueOf(int value) {
return forNumber(value);
}
public static DataCase forNumber(int value) {
switch (value) {
case 1: return FILENAME;
case 2: return CHUNK;
case 0: return DATA_NOT_SET;
default: return null;
}
}
public int getNumber() {
return this.value;
}
};
public DataCase
getDataCase() {
return DataCase.forNumber(
dataCase_);
}
public static final int FILENAME_FIELD_NUMBER = 1;
/**
* <code>string filename = 1;</code>
* @return Whether the filename field is set.
*/
public boolean hasFilename() {
return dataCase_ == 1;
}
/**
* <code>string filename = 1;</code>
* @return The filename.
*/
public String getFilename() {
Object ref = "";
if (dataCase_ == 1) {
ref = data_;
}
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (dataCase_ == 1) {
data_ = s;
}
return s;
}
}
/**
* <code>string filename = 1;</code>
* @return The bytes for filename.
*/
public com.google.protobuf.ByteString
getFilenameBytes() {
Object ref = "";
if (dataCase_ == 1) {
ref = data_;
}
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
if (dataCase_ == 1) {
data_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int CHUNK_FIELD_NUMBER = 2;
/**
* <code>bytes chunk = 2;</code>
* @return Whether the chunk field is set.
*/
@Override
public boolean hasChunk() {
return dataCase_ == 2;
}
/**
* <code>bytes chunk = 2;</code>
* @return The chunk.
*/
@Override
public com.google.protobuf.ByteString getChunk() {
if (dataCase_ == 2) {
return (com.google.protobuf.ByteString) data_;
}
return com.google.protobuf.ByteString.EMPTY;
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (dataCase_ == 1) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, data_);
}
if (dataCase_ == 2) {
output.writeBytes(
2, (com.google.protobuf.ByteString) data_);
}
getUnknownFields().writeTo(output);
}
@Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (dataCase_ == 1) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, data_);
}
if (dataCase_ == 2) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(
2, (com.google.protobuf.ByteString) data_);
}
size += getUnknownFields().getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof FileUploadRequest)) {
return super.equals(obj);
}
FileUploadRequest other = (FileUploadRequest) obj;
if (!getDataCase().equals(other.getDataCase())) return false;
switch (dataCase_) {
case 1:
if (!getFilename()
.equals(other.getFilename())) return false;
break;
case 2:
if (!getChunk()
.equals(other.getChunk())) return false;
break;
case 0:
default:
}
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
return true;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
switch (dataCase_) {
case 1:
hash = (37 * hash) + FILENAME_FIELD_NUMBER;
hash = (53 * hash) + getFilename().hashCode();
break;
case 2:
hash = (37 * hash) + CHUNK_FIELD_NUMBER;
hash = (53 * hash) + getChunk().hashCode();
break;
case 0:
default:
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static FileUploadRequest parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileUploadRequest parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileUploadRequest parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileUploadRequest parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileUploadRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileUploadRequest parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileUploadRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileUploadRequest parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static FileUploadRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static FileUploadRequest parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static FileUploadRequest parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileUploadRequest parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(FileUploadRequest prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code FileUploadRequest}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:FileUploadRequest)
FileUploadRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileUploadRequest_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileUploadRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileUploadRequest.class, Builder.class);
}
// Construct using com.ruoyi.grpc.file.FileUploadRequest.newBuilder()
private Builder() {
}
private Builder(
BuilderParent parent) {
super(parent);
}
@Override
public Builder clear() {
super.clear();
bitField0_ = 0;
dataCase_ = 0;
data_ = null;
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return File.internal_static_FileUploadRequest_descriptor;
}
@Override
public FileUploadRequest getDefaultInstanceForType() {
return FileUploadRequest.getDefaultInstance();
}
@Override
public FileUploadRequest build() {
FileUploadRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public FileUploadRequest buildPartial() {
FileUploadRequest result = new FileUploadRequest(this);
if (bitField0_ != 0) { buildPartial0(result); }
buildPartialOneofs(result);
onBuilt();
return result;
}
private void buildPartial0(FileUploadRequest result) {
int from_bitField0_ = bitField0_;
}
private void buildPartialOneofs(FileUploadRequest result) {
result.dataCase_ = dataCase_;
result.data_ = this.data_;
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof FileUploadRequest) {
return mergeFrom((FileUploadRequest)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(FileUploadRequest other) {
if (other == FileUploadRequest.getDefaultInstance()) return this;
switch (other.getDataCase()) {
case FILENAME: {
dataCase_ = 1;
data_ = other.data_;
onChanged();
break;
}
case CHUNK: {
setChunk(other.getChunk());
break;
}
case DATA_NOT_SET: {
break;
}
}
this.mergeUnknownFields(other.getUnknownFields());
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
if (extensionRegistry == null) {
throw new NullPointerException();
}
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
String s = input.readStringRequireUtf8();
dataCase_ = 1;
data_ = s;
break;
} // case 10
case 18: {
data_ = input.readBytes();
dataCase_ = 2;
break;
} // case 18
default: {
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
done = true; // was an endgroup tag
}
break;
} // default:
} // switch (tag)
} // while (!done)
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.unwrapIOException();
} finally {
onChanged();
} // finally
return this;
}
private int dataCase_ = 0;
private Object data_;
public DataCase
getDataCase() {
return DataCase.forNumber(
dataCase_);
}
public Builder clearData() {
dataCase_ = 0;
data_ = null;
onChanged();
return this;
}
private int bitField0_;
/**
* <code>string filename = 1;</code>
* @return Whether the filename field is set.
*/
@Override
public boolean hasFilename() {
return dataCase_ == 1;
}
/**
* <code>string filename = 1;</code>
* @return The filename.
*/
@Override
public String getFilename() {
Object ref = "";
if (dataCase_ == 1) {
ref = data_;
}
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (dataCase_ == 1) {
data_ = s;
}
return s;
} else {
return (String) ref;
}
}
/**
* <code>string filename = 1;</code>
* @return The bytes for filename.
*/
@Override
public com.google.protobuf.ByteString
getFilenameBytes() {
Object ref = "";
if (dataCase_ == 1) {
ref = data_;
}
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
if (dataCase_ == 1) {
data_ = b;
}
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string filename = 1;</code>
* @param value The filename to set.
* @return This builder for chaining.
*/
public Builder setFilename(
String value) {
if (value == null) { throw new NullPointerException(); }
dataCase_ = 1;
data_ = value;
onChanged();
return this;
}
/**
* <code>string filename = 1;</code>
* @return This builder for chaining.
*/
public Builder clearFilename() {
if (dataCase_ == 1) {
dataCase_ = 0;
data_ = null;
onChanged();
}
return this;
}
/**
* <code>string filename = 1;</code>
* @param value The bytes for filename to set.
* @return This builder for chaining.
*/
public Builder setFilenameBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
dataCase_ = 1;
data_ = value;
onChanged();
return this;
}
/**
* <code>bytes chunk = 2;</code>
* @return Whether the chunk field is set.
*/
public boolean hasChunk() {
return dataCase_ == 2;
}
/**
* <code>bytes chunk = 2;</code>
* @return The chunk.
*/
public com.google.protobuf.ByteString getChunk() {
if (dataCase_ == 2) {
return (com.google.protobuf.ByteString) data_;
}
return com.google.protobuf.ByteString.EMPTY;
}
/**
* <code>bytes chunk = 2;</code>
* @param value The chunk to set.
* @return This builder for chaining.
*/
public Builder setChunk(com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
dataCase_ = 2;
data_ = value;
onChanged();
return this;
}
/**
* <code>bytes chunk = 2;</code>
* @return This builder for chaining.
*/
public Builder clearChunk() {
if (dataCase_ == 2) {
dataCase_ = 0;
data_ = null;
onChanged();
}
return this;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:FileUploadRequest)
}
// @@protoc_insertion_point(class_scope:FileUploadRequest)
private static final FileUploadRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new FileUploadRequest();
}
public static FileUploadRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<FileUploadRequest>
PARSER = new com.google.protobuf.AbstractParser<FileUploadRequest>() {
@Override
public FileUploadRequest parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
Builder builder = newBuilder();
try {
builder.mergeFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(builder.buildPartial());
} catch (com.google.protobuf.UninitializedMessageException e) {
throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(e)
.setUnfinishedMessage(builder.buildPartial());
}
return builder.buildPartial();
}
};
public static com.google.protobuf.Parser<FileUploadRequest> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<FileUploadRequest> getParserForType() {
return PARSER;
}
@Override
public FileUploadRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
public interface FileUploadRequestOrBuilder extends
// @@protoc_insertion_point(interface_extends:FileUploadRequest)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string filename = 1;</code>
* @return Whether the filename field is set.
*/
boolean hasFilename();
/**
* <code>string filename = 1;</code>
* @return The filename.
*/
String getFilename();
/**
* <code>string filename = 1;</code>
* @return The bytes for filename.
*/
com.google.protobuf.ByteString
getFilenameBytes();
/**
* <code>bytes chunk = 2;</code>
* @return Whether the chunk field is set.
*/
boolean hasChunk();
/**
* <code>bytes chunk = 2;</code>
* @return The chunk.
*/
com.google.protobuf.ByteString getChunk();
public FileUploadRequest.DataCase getDataCase();
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
/**
* Protobuf type {@code FileUploadResponse}
*/
public final class FileUploadResponse extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:FileUploadResponse)
FileUploadResponseOrBuilder {
private static final long serialVersionUID = 0L;
// Use FileUploadResponse.newBuilder() to construct.
private FileUploadResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private FileUploadResponse() {
status_ = "";
}
@Override
@SuppressWarnings({"unused"})
protected Object newInstance(
UnusedPrivateParameter unused) {
return new FileUploadResponse();
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileUploadResponse_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileUploadResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileUploadResponse.class, Builder.class);
}
public static final int STATUS_FIELD_NUMBER = 1;
@SuppressWarnings("serial")
private volatile Object status_ = "";
/**
* <code>string status = 1;</code>
* @return The status.
*/
@Override
public String getStatus() {
Object ref = status_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
status_ = s;
return s;
}
}
/**
* <code>string status = 1;</code>
* @return The bytes for status.
*/
@Override
public com.google.protobuf.ByteString
getStatusBytes() {
Object ref = status_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
status_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int SIZE_FIELD_NUMBER = 2;
private long size_ = 0L;
/**
* <code>int64 size = 2;</code>
* @return The size.
*/
@Override
public long getSize() {
return size_;
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(status_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, status_);
}
if (size_ != 0L) {
output.writeInt64(2, size_);
}
getUnknownFields().writeTo(output);
}
@Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(status_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, status_);
}
if (size_ != 0L) {
size += com.google.protobuf.CodedOutputStream
.computeInt64Size(2, size_);
}
size += getUnknownFields().getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof FileUploadResponse)) {
return super.equals(obj);
}
FileUploadResponse other = (FileUploadResponse) obj;
if (!getStatus()
.equals(other.getStatus())) return false;
if (getSize()
!= other.getSize()) return false;
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
return true;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + STATUS_FIELD_NUMBER;
hash = (53 * hash) + getStatus().hashCode();
hash = (37 * hash) + SIZE_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
getSize());
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
public static FileUploadResponse parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileUploadResponse parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileUploadResponse parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileUploadResponse parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileUploadResponse parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static FileUploadResponse parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static FileUploadResponse parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileUploadResponse parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static FileUploadResponse parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static FileUploadResponse parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static FileUploadResponse parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static FileUploadResponse parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(FileUploadResponse prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code FileUploadResponse}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:FileUploadResponse)
FileUploadResponseOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return File.internal_static_FileUploadResponse_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return File.internal_static_FileUploadResponse_fieldAccessorTable
.ensureFieldAccessorsInitialized(
FileUploadResponse.class, Builder.class);
}
// Construct using com.ruoyi.grpc.file.FileUploadResponse.newBuilder()
private Builder() {
}
private Builder(
BuilderParent parent) {
super(parent);
}
@Override
public Builder clear() {
super.clear();
bitField0_ = 0;
status_ = "";
size_ = 0L;
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return File.internal_static_FileUploadResponse_descriptor;
}
@Override
public FileUploadResponse getDefaultInstanceForType() {
return FileUploadResponse.getDefaultInstance();
}
@Override
public FileUploadResponse build() {
FileUploadResponse result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public FileUploadResponse buildPartial() {
FileUploadResponse result = new FileUploadResponse(this);
if (bitField0_ != 0) { buildPartial0(result); }
onBuilt();
return result;
}
private void buildPartial0(FileUploadResponse result) {
int from_bitField0_ = bitField0_;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.status_ = status_;
}
if (((from_bitField0_ & 0x00000002) != 0)) {
result.size_ = size_;
}
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof FileUploadResponse) {
return mergeFrom((FileUploadResponse)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(FileUploadResponse other) {
if (other == FileUploadResponse.getDefaultInstance()) return this;
if (!other.getStatus().isEmpty()) {
status_ = other.status_;
bitField0_ |= 0x00000001;
onChanged();
}
if (other.getSize() != 0L) {
setSize(other.getSize());
}
this.mergeUnknownFields(other.getUnknownFields());
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
if (extensionRegistry == null) {
throw new NullPointerException();
}
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
status_ = input.readStringRequireUtf8();
bitField0_ |= 0x00000001;
break;
} // case 10
case 16: {
size_ = input.readInt64();
bitField0_ |= 0x00000002;
break;
} // case 16
default: {
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
done = true; // was an endgroup tag
}
break;
} // default:
} // switch (tag)
} // while (!done)
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.unwrapIOException();
} finally {
onChanged();
} // finally
return this;
}
private int bitField0_;
private Object status_ = "";
/**
* <code>string status = 1;</code>
* @return The status.
*/
public String getStatus() {
Object ref = status_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
status_ = s;
return s;
} else {
return (String) ref;
}
}
/**
* <code>string status = 1;</code>
* @return The bytes for status.
*/
public com.google.protobuf.ByteString
getStatusBytes() {
Object ref = status_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
status_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string status = 1;</code>
* @param value The status to set.
* @return This builder for chaining.
*/
public Builder setStatus(
String value) {
if (value == null) { throw new NullPointerException(); }
status_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
/**
* <code>string status = 1;</code>
* @return This builder for chaining.
*/
public Builder clearStatus() {
status_ = getDefaultInstance().getStatus();
bitField0_ = (bitField0_ & ~0x00000001);
onChanged();
return this;
}
/**
* <code>string status = 1;</code>
* @param value The bytes for status to set.
* @return This builder for chaining.
*/
public Builder setStatusBytes(
com.google.protobuf.ByteString value) {
if (value == null) { throw new NullPointerException(); }
checkByteStringIsUtf8(value);
status_ = value;
bitField0_ |= 0x00000001;
onChanged();
return this;
}
private long size_ ;
/**
* <code>int64 size = 2;</code>
* @return The size.
*/
@Override
public long getSize() {
return size_;
}
/**
* <code>int64 size = 2;</code>
* @param value The size to set.
* @return This builder for chaining.
*/
public Builder setSize(long value) {
size_ = value;
bitField0_ |= 0x00000002;
onChanged();
return this;
}
/**
* <code>int64 size = 2;</code>
* @return This builder for chaining.
*/
public Builder clearSize() {
bitField0_ = (bitField0_ & ~0x00000002);
size_ = 0L;
onChanged();
return this;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:FileUploadResponse)
}
// @@protoc_insertion_point(class_scope:FileUploadResponse)
private static final FileUploadResponse DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new FileUploadResponse();
}
public static FileUploadResponse getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<FileUploadResponse>
PARSER = new com.google.protobuf.AbstractParser<FileUploadResponse>() {
@Override
public FileUploadResponse parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
Builder builder = newBuilder();
try {
builder.mergeFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(builder.buildPartial());
} catch (com.google.protobuf.UninitializedMessageException e) {
throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(e)
.setUnfinishedMessage(builder.buildPartial());
}
return builder.buildPartial();
}
};
public static com.google.protobuf.Parser<FileUploadResponse> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<FileUploadResponse> getParserForType() {
return PARSER;
}
@Override
public FileUploadResponse getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: file.proto
package com.ruoyi.grpc.file;
public interface FileUploadResponseOrBuilder extends
// @@protoc_insertion_point(interface_extends:FileUploadResponse)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string status = 1;</code>
* @return The status.
*/
String getStatus();
/**
* <code>string status = 1;</code>
* @return The bytes for status.
*/
com.google.protobuf.ByteString
getStatusBytes();
/**
* <code>int64 size = 2;</code>
* @return The size.
*/
long getSize();
}
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.ruoyi.grpc.file";
option go_package = "./pb";
message FileUploadRequest {
//表示这两个字段只能有一个被设置值,要么是文件名称要么是文件块
oneof data {
string filename = 1;
bytes chunk = 2;
}
}
message FileUploadResponse {
string status = 1;
int64 size = 2;
}
message FileDownloadRequest {
string filename = 1;
}
message FileDownloadResponse {
bytes chunk = 1;
}
service FileService {
rpc UploadFile(stream FileUploadRequest) returns (FileUploadResponse);
rpc DownloadFile(FileDownloadRequest) returns (stream FileDownloadResponse);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment