From 67b099e8af0b66e33f733472371344752405018c Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Sun, 2 Nov 2025 21:07:10 +0000 Subject: [PATCH] drop grpc --- alg/Makefile | 5 --- alg/fileprocess.cpp | 84 --------------------------------------------- alg/fileprocess.h | 13 ------- alg/qrtool.cpp | 3 -- packages.txt | 4 --- 5 files changed, 109 deletions(-) delete mode 100644 alg/fileprocess.cpp delete mode 100644 alg/fileprocess.h diff --git a/alg/Makefile b/alg/Makefile index 081de12..7873e46 100644 --- a/alg/Makefile +++ b/alg/Makefile @@ -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 diff --git a/alg/fileprocess.cpp b/alg/fileprocess.cpp deleted file mode 100644 index 492c48c..0000000 --- a/alg/fileprocess.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "fileprocess.h" -#include "fileprocess.grpc.pb.h" -#include - -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 output; - vector 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 *stream) override { - ArchiveFile request; - while (stream->Read(&request)) { - if (request.data().size() <= 0) continue; - string output_path; - vector output; - vector 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(builder.BuildAndStart()); - std::cout << "Server listening on " << server_addr << std::endl; - server->Wait(); - return 0; -} - diff --git a/alg/fileprocess.h b/alg/fileprocess.h deleted file mode 100644 index 0addd89..0000000 --- a/alg/fileprocess.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _FILEPROCESS_H_ -#define _FILEPROCESS_H_ -#include -#include -#include -typedef int (*handler_fn)(const std::string &input_path, - const std::vector &input, - std::string &output_path, - std::vector &output); - -int run_server(const std::string &server_addr, handler_fn handle_image); - -#endif diff --git a/alg/qrtool.cpp b/alg/qrtool.cpp index c5f2cc3..90e4c05 100644 --- a/alg/qrtool.cpp +++ b/alg/qrtool.cpp @@ -17,9 +17,6 @@ #include #include "mq_worker.h" -#if ENABLE_GRPC -#include "fileprocess.h" -#endif #include "http.h" #include "libqr.h" diff --git a/packages.txt b/packages.txt index a458371..cf491a9 100644 --- a/packages.txt +++ b/packages.txt @@ -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