Skip to content

Commit

Permalink
adapt to intializer (#20)
Browse files Browse the repository at this point in the history
* rename ppc-main to wedpr-main

* adapt to intializer

* add gateway initializer
  • Loading branch information
cyjseagull authored Sep 5, 2024
1 parent 0fba05a commit cddb3ee
Show file tree
Hide file tree
Showing 64 changed files with 825 additions and 675 deletions.
3 changes: 2 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ set(ALL_SOURCE_LIST
wedpr-storage/ppc-io wedpr-storage/ppc-storage
wedpr-transport/ppc-gateway wedpr-transport/ppc-front
wedpr-transport/ppc-http wedpr-transport/ppc-rpc wedpr-transport/sdk
wedpr-computing/ppc-psi wedpr-computing/ppc-mpc wedpr-computing/ppc-pir ${CEM_SOURCE})
wedpr-computing/ppc-psi wedpr-computing/ppc-mpc wedpr-computing/ppc-pir ${CEM_SOURCE}
wedpr-initializer wedpr-main)

if(BUILD_WEDPR_TOOLKIT)
# fetch the python dependencies
Expand Down
4 changes: 2 additions & 2 deletions cpp/cmake/TargetSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ set(RPC_TARGET "ppc-rpc")
# libhelper
set(HELPER_TARGET "ppc-helper")

# libinitializer
set(INIT_LIB init)
# wedpr-initializer
set(INIT_LIB "wedpr-inititializer")

# ppc-cem
set(CEM_TARGET "ppc-cem")
Expand Down
4 changes: 0 additions & 4 deletions cpp/libinitializer/CMakeLists.txt

This file was deleted.

74 changes: 0 additions & 74 deletions cpp/libinitializer/FrontInitializer.cpp

This file was deleted.

104 changes: 0 additions & 104 deletions cpp/libinitializer/FrontInitializer.h

This file was deleted.

79 changes: 0 additions & 79 deletions cpp/libinitializer/ProFrontInitializer.h

This file was deleted.

55 changes: 38 additions & 17 deletions cpp/ppc-framework/front/FrontConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

#pragma once
#include "ppc-framework/protocol/EndPoint.h"
#include "ppc-framework/protocol/GrpcConfig.h"
#include "ppc-framework/protocol/INodeInfo.h"
#include <memory>
#include <sstream>
#include <string>
#include <vector>

Expand Down Expand Up @@ -49,40 +52,58 @@ class FrontConfig

virtual void appendGatewayInfo(ppc::protocol::EndPoint&& endpoint)
{
// TODO:check the endpoint
m_gatewayInfo.push_back(endpoint);
}

ppc::protocol::EndPoint const& selfEndPoint() const { return m_selfEndPoint; }
void setSelfEndPoint(ppc::protocol::EndPoint const& endPoint) { m_selfEndPoint = endPoint; }

// TODO here
std::string gatewayEndPoints() { return ""; }
// refer to: https://github.com/grpc/grpc-node/issues/2066
// grpc prefer to using ipv4:${host1}:${port1},${host2}:${port2} as target to support multiple
// servers
std::string gatewayGrpcTarget()
{
std::stringstream oss;
oss << "ipv4:";
for (auto const& endPoint : m_gatewayInfo)
{
oss << endPoint.entryPoint() << ",";
}
return oss.str();
}

std::string const& loadBalancePolicy() const { return m_loadBanlancePolicy; }
void setLoadBalancePolicy(std::string const& loadBanlancePolicy)
void setGrpcConfig(ppc::protocol::GrpcConfig::Ptr grpcConfig)
{
m_loadBanlancePolicy = loadBanlancePolicy;
m_grpcConfig = std::move(grpcConfig);
}
ppc::protocol::GrpcConfig::Ptr const& grpcConfig() const { return m_grpcConfig; }

// generate the nodeInfo
virtual ppc::protocol::INodeInfo::Ptr generateNodeInfo() const = 0;

virtual std::vector<std::string> const& getComponents() const { return m_components; }
void setComponents(std::vector<std::string> const& components) { m_components = components; }

private:
std::string m_loadBanlancePolicy = "round_robin";
protected:
ppc::protocol::GrpcConfig::Ptr m_grpcConfig;
ppc::protocol::EndPoint m_selfEndPoint;
int m_threadPoolSize;
std::string m_nodeID;
std::vector<ppc::protocol::EndPoint> m_gatewayInfo;
std::vector<std::string> m_components;
};

class FrontConfigBuilder
inline std::string printFrontDesc(FrontConfig::Ptr const& config)
{
public:
using Ptr = std::shared_ptr<FrontConfigBuilder>;
FrontConfigBuilder() = default;
virtual ~FrontConfigBuilder() = default;

FrontConfig::Ptr build(int threadPoolSize, std::string nodeID)
if (!config)
{
return std::make_shared<FrontConfig>(threadPoolSize, nodeID);
return "nullptr";
}
};
std::ostringstream stringstream;
stringstream << LOG_KV("endPoint", config->selfEndPoint().entryPoint())
<< LOG_KV("nodeID", config->nodeID())
<< LOG_KV("poolSize", config->threadPoolSize())
<< LOG_KV("target", config->gatewayGrpcTarget());
return stringstream.str();
}
} // namespace ppc::front
5 changes: 2 additions & 3 deletions cpp/ppc-framework/front/FrontInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class FrontInterface
virtual void asyncSendResponse(const std::string& _agencyID, std::string const& _uuid,
front::PPCMessageFace::Ptr _message, ErrorCallbackFunc _callback) = 0;

virtual void registerMessageHandler(uint8_t _taskType, uint8_t _algorithmType,
std::function<void(front::PPCMessageFace::Ptr)> _handler) = 0;
/**
* @brief notice task info to gateway
* @param _taskInfo the latest task information
Expand All @@ -69,9 +71,6 @@ class FrontInterface
// erase the task-info when task finished
virtual bcos::Error::Ptr eraseTaskInfo(std::string const& _taskID) = 0;

// get the agencyList from the gateway
virtual void asyncGetAgencyList(GetAgencyListCallback _callback) = 0;

virtual std::string const& selfEndPoint() const { return m_selfEndPoint; }

protected:
Expand Down
Loading

0 comments on commit cddb3ee

Please sign in to comment.