mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Allow two service address to be registered.
Allow Grpc vehicle proxy server bind to two addrs. We need one for vsock to be used by VHAL and another one for local ethernet connection. vsock local loopback does not work on the host. Flag: EXEMPT host-side component. Test: Manual test. Bug: 328316981 Change-Id: I4efc802121b780b663fd8a26b65dc56a001feff6
This commit is contained in:
@@ -40,7 +40,11 @@ static std::shared_ptr<::grpc::ServerCredentials> getServerCredentials() {
|
||||
|
||||
GrpcVehicleProxyServer::GrpcVehicleProxyServer(std::string serverAddr,
|
||||
std::unique_ptr<IVehicleHardware>&& hardware)
|
||||
: mServiceAddr(std::move(serverAddr)), mHardware(std::move(hardware)) {
|
||||
: GrpcVehicleProxyServer(std::vector<std::string>({serverAddr}), std::move(hardware)){};
|
||||
|
||||
GrpcVehicleProxyServer::GrpcVehicleProxyServer(std::vector<std::string> serverAddrs,
|
||||
std::unique_ptr<IVehicleHardware>&& hardware)
|
||||
: mServiceAddrs(std::move(serverAddrs)), mHardware(std::move(hardware)) {
|
||||
mHardware->registerOnPropertyChangeEvent(
|
||||
std::make_unique<const IVehicleHardware::PropertyChangeCallback>(
|
||||
[this](std::vector<aidlvhal::VehiclePropValue> values) {
|
||||
@@ -254,7 +258,9 @@ GrpcVehicleProxyServer& GrpcVehicleProxyServer::Start() {
|
||||
}
|
||||
::grpc::ServerBuilder builder;
|
||||
builder.RegisterService(this);
|
||||
builder.AddListeningPort(mServiceAddr, getServerCredentials());
|
||||
for (const std::string& serviceAddr : mServiceAddrs) {
|
||||
builder.AddListeningPort(serviceAddr, getServerCredentials());
|
||||
}
|
||||
mServer = builder.BuildAndStart();
|
||||
CHECK(mServer) << __func__ << ": failed to create the GRPC server, "
|
||||
<< "please make sure the configuration and permissions are correct";
|
||||
|
||||
@@ -41,6 +41,9 @@ class GrpcVehicleProxyServer : public proto::VehicleServer::Service {
|
||||
public:
|
||||
GrpcVehicleProxyServer(std::string serverAddr, std::unique_ptr<IVehicleHardware>&& hardware);
|
||||
|
||||
GrpcVehicleProxyServer(std::vector<std::string> serverAddrs,
|
||||
std::unique_ptr<IVehicleHardware>&& hardware);
|
||||
|
||||
::grpc::Status GetAllPropertyConfig(
|
||||
::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
|
||||
::grpc::ServerWriter<proto::VehiclePropConfig>* stream) override;
|
||||
@@ -116,7 +119,7 @@ class GrpcVehicleProxyServer : public proto::VehicleServer::Service {
|
||||
static std::atomic<uint64_t> connection_id_counter_;
|
||||
};
|
||||
|
||||
std::string mServiceAddr;
|
||||
std::vector<std::string> mServiceAddrs;
|
||||
std::unique_ptr<::grpc::Server> mServer{nullptr};
|
||||
std::unique_ptr<IVehicleHardware> mHardware;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user