drop grpc
This commit is contained in:
parent
b35bbce103
commit
67b099e8af
@ -19,8 +19,6 @@ endif
|
||||
|
||||
USE_PULSAR :=
|
||||
|
||||
ENABLE_GRPC :=
|
||||
|
||||
START_GROUP := -Wl,--start-group
|
||||
END_GROUP := -Wl,--end-group
|
||||
|
||||
@ -38,7 +36,6 @@ qrtool: qrtool.cpp libqr.cpp \
|
||||
$(if $(USE_PULSAR), mq_worker.cpp) \
|
||||
base64.cpp mq_worker.h base64.h \
|
||||
http.o \
|
||||
$(if $(ENABLE_GRPC), fileprocess.o fileprocess.pb.o fileprocess.grpc.pb.o) \
|
||||
Makefile
|
||||
$(CXX) -o $@ \
|
||||
$(if $(STATIC), -static) \
|
||||
@ -59,8 +56,6 @@ qrtool.zip: qrtool
|
||||
cd qrtool.zip-workdir && zip qrtool.zip qrtool.$(shell git describe --always).x86_64 && mv qrtool.zip ..
|
||||
rm -rf qrtool.zip-workdir
|
||||
|
||||
fileprocess.o: fileprocess.grpc.pb.h
|
||||
|
||||
qrtool.web.js: EMCC_FLAGS := \
|
||||
-O3
|
||||
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
#include "fileprocess.h"
|
||||
#include "fileprocess.grpc.pb.h"
|
||||
#include <grpc++/server_builder.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace grpc;
|
||||
using namespace fileprocess;
|
||||
|
||||
class FileProcessServer final : public FileProcess::Service {
|
||||
|
||||
handler_fn _handle_image;
|
||||
|
||||
Status ProcessFiles(ServerContext* context, const Files* request,
|
||||
Output *resp) override {
|
||||
printf("process files\n");
|
||||
for (auto file: request->files()) {
|
||||
printf("file: %s\n", file.path().c_str());
|
||||
string output_path;
|
||||
vector<uint8_t> output;
|
||||
vector<uint8_t> input(file.data().begin(), file.data().end());
|
||||
auto r = _handle_image(file.path(), input, output_path, output);
|
||||
auto d = resp->add_files();
|
||||
if (r) {
|
||||
d->set_succeeded(false);
|
||||
d->set_error("Failed to process image");
|
||||
} else {
|
||||
d->set_succeeded(true);
|
||||
d->set_path(output_path);
|
||||
string data(output.begin(), output.end());
|
||||
d->set_data(data);
|
||||
}
|
||||
}
|
||||
printf("done\n");
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
Status ProcessArchive(ServerContext* context, ServerReaderWriter<Output, ArchiveFile> *stream) override {
|
||||
ArchiveFile request;
|
||||
while (stream->Read(&request)) {
|
||||
if (request.data().size() <= 0) continue;
|
||||
string output_path;
|
||||
vector<uint8_t> output;
|
||||
vector<uint8_t> input(request.data().begin(), request.data().end());
|
||||
string path = request.path();
|
||||
path += string("-files/") + request.path_in_archive();
|
||||
auto r = _handle_image(path, input, output_path, output);
|
||||
Output d;
|
||||
if (r) {
|
||||
d.set_succeeded(false);
|
||||
string error = "Failed to process image " + request.path_in_archive();
|
||||
d.set_error(error);
|
||||
} else {
|
||||
d.set_succeeded(true);
|
||||
d.set_path(output_path);
|
||||
string data(output.begin(), output.end());
|
||||
d.set_data(data);
|
||||
}
|
||||
stream->Write(d);
|
||||
}
|
||||
return Status::OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
FileProcessServer(handler_fn handle_image) :
|
||||
_handle_image(handle_image)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
int run_server(const string &server_addr, handler_fn handle_image) {
|
||||
FileProcessServer service(handle_image);
|
||||
|
||||
ServerBuilder builder;
|
||||
builder.AddListeningPort(server_addr, grpc::InsecureServerCredentials());
|
||||
builder.RegisterService(&service);
|
||||
builder.SetMaxSendMessageSize(128 * 1024 * 1024);
|
||||
std::unique_ptr<Server> server(builder.BuildAndStart());
|
||||
std::cout << "Server listening on " << server_addr << std::endl;
|
||||
server->Wait();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
#ifndef _FILEPROCESS_H_
|
||||
#define _FILEPROCESS_H_
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
typedef int (*handler_fn)(const std::string &input_path,
|
||||
const std::vector<uint8_t> &input,
|
||||
std::string &output_path,
|
||||
std::vector<uint8_t> &output);
|
||||
|
||||
int run_server(const std::string &server_addr, handler_fn handle_image);
|
||||
|
||||
#endif
|
||||
@ -17,9 +17,6 @@
|
||||
#include <opencv2/dnn.hpp>
|
||||
|
||||
#include "mq_worker.h"
|
||||
#if ENABLE_GRPC
|
||||
#include "fileprocess.h"
|
||||
#endif
|
||||
#include "http.h"
|
||||
#include "libqr.h"
|
||||
|
||||
|
||||
@ -6,15 +6,11 @@ libdbus-1-3
|
||||
libexpat1
|
||||
libgcc-s1
|
||||
libgpg-error0
|
||||
libgrpc++1
|
||||
libgrpc10
|
||||
libgtk-3-0
|
||||
libjsoncpp25
|
||||
liblzma5
|
||||
libopenexr25
|
||||
libopenjp2-7
|
||||
libpcre3
|
||||
libprotobuf23
|
||||
libselinux1
|
||||
nginx
|
||||
python3-bottle
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user