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> <version>1.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.loafle.overflow</groupId>
<artifactId>crawler</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<extensions> <extensions>

View File

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

View File

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