From 919b4bc4be26ac20c45bd4e03a825f45d91e538a Mon Sep 17 00:00:00 2001 From: "jackdaw@loafle.com" Date: Thu, 27 Apr 2017 20:48:34 +0900 Subject: [PATCH] change grpc param --- pom.xml | 6 ++++++ src/main/java/com/loafle/overflow/Server.java | 6 +++--- src/main/proto/remote.proto | 12 +++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index dfe8b6c..2206332 100644 --- a/pom.xml +++ b/pom.xml @@ -79,6 +79,12 @@ 1.0.0-SNAPSHOT + + com.loafle.overflow + crawler + 1.0.0-SNAPSHOT + + diff --git a/src/main/java/com/loafle/overflow/Server.java b/src/main/java/com/loafle/overflow/Server.java index bbc0e96..516a101 100644 --- a/src/main/java/com/loafle/overflow/Server.java +++ b/src/main/java/com/loafle/overflow/Server.java @@ -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 responseObserver) { + public void add(InputAdd req, StreamObserver 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) diff --git a/src/main/proto/remote.proto b/src/main/proto/remote.proto index 4b0d4c1..5619e00 100644 --- a/src/main/proto/remote.proto +++ b/src/main/proto/remote.proto @@ -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;