change grpc param

This commit is contained in:
jackdaw@loafle.com 2017-04-27 20:48:34 +09:00
parent 58f89980ac
commit 919b4bc4be
3 changed files with 18 additions and 6 deletions

View File

@ -79,6 +79,12 @@
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.loafle.overflow</groupId>
<artifactId>crawler</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<extensions>

View File

@ -144,7 +144,7 @@ public class Server {
for (Init in : list) {
Crawler crawler = crawlerMap.get(in.getName().name());
try {
obj = crawler.init(in.getPath());
obj = crawler.init(in.getData().toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
@ -164,11 +164,11 @@ public class Server {
}
@Override
public void add(Input req, StreamObserver<Output> responseObserver) {
public void add(InputAdd req, StreamObserver<Output> responseObserver) {
Crawler crawler = crawlerMap.get(req.getName().name());
if(crawler != null) {
try {
Object obj = crawler.add(req.getId());
Object obj = crawler.add(req.getData().toByteArray());
Output reply = Output.newBuilder()
.setData(ByteString.copyFrom(convertObjectToBytes(obj)))
.setStartDate(0)

View File

@ -3,6 +3,7 @@ syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.loafle.overflow.rpc";
enum Crawlers {
HEALTH_ACTIVEDIRECTORY = 0;
HEALTH_DNS = 1;
@ -39,7 +40,7 @@ enum Crawlers {
// services
service Config {
rpc Add (Input) returns (Output) {}
rpc Add (InputAdd) returns (Output) {}
rpc Remove (Input) returns (Output) {}
rpc Init (InputArray) returns (Output) {}
}
@ -48,6 +49,7 @@ service Data {
rpc Get (Input) returns (Output) {}
}
service Status {
rpc Status(Empty) returns (Boolean) {}
}
@ -57,14 +59,13 @@ message Boolean {
bool check = 1;
}
// request models
message InputArray {
repeated Init in = 1;
}
message Init {
Crawlers name = 1;
string path = 2;
bytes data = 2;
}
message Input {
@ -72,6 +73,11 @@ message Input {
string id =2;
}
message InputAdd {
Crawlers name = 1;
bytes data =2;
}
// response models
message Output {
int64 startDate = 1;