GithubHelp home page GithubHelp logo

polarismesh / polaris-cpp Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 14.0 9.83 MB

Lightweight C++ SDK used as Proxyless Service Governance

License: Other

Starlark 0.32% Makefile 0.69% Shell 0.01% C++ 97.78% C 1.18% Dockerfile 0.01%
fault-tolerance health-check rate-limit authenticate traffic-control load-balance circuit-break service-register service-discover request-route

polaris-cpp's Introduction

polaris-cpp

Polaris is an operation centre that supports multiple programming languages, with high compatibility to different application framework. Polaris-cpp is C++ SDK for Polaris.

Overview

Polaris-cpp provides features listed as below:

  • Service instance registration, and health check

    Provides API on/offline registration instance information, with regular report to inform caller server's healthy status.

  • Service discovery

    Provides multiple API, for users to get a full list of server instance, or get one server instance after route rule filtering and loadbalancing, which can be applied to srevice invocation soon.

  • Service circuitbreaking

    Provide API to report the invocation result, and conduct circuit breaker instance/group insolation based on collected data, eventually recover when the system allows.

  • Service ratelimiting

    Provides API for applications to conduct quota check and deduction, supports rate limit policies that are based on server level and port.

Quick Start

Further operation details, please refer to Polaris iWiKi space

How to join

We are looking forward to working with you, for instructions regarding code contribution, please refer to CONTRIBUTING.md

License

The polaris-cpp is licensed under the BSD 3-Clause License. Copyright and license information can be found in the file LICENSE

polaris-cpp's People

Contributors

andrewshan avatar chuntaojun avatar jobop avatar lambdaliu avatar movebean avatar polaris-admin avatar wssgyyg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

polaris-cpp's Issues

使用c++sdk接入,在北极星服务端发版时,会产生core dump

c++ sdk版本:1.1.2
服务端版本:1.13
北极星节点连接拓扑: c++ sdk -> vip ->后端北极星服务

问题产生过程:发布北极星服务端时,重启了一批节点,更换了一些节点ip。客户端此时发送core dump。

客户端报错信息:

warning: Ignoring non-absolute filename: <./lib64_release/libiomp5.so>
Missing separate debuginfo for ./lib64_release/libiomp5.so
Try: yum --enablerepo='debug' install /usr/lib/debug/.build-id/9d/fa23ad70f3f8f50699aac84586f3ba832b7034.debug
Core was generated by `bin/recall_server --flagfile=conf/theme.gflags'.
Program terminated with signal 11, Segmentation fault.
#0 _M_get (this=) at thirdparty/polaris-cpp/polaris/model/instance.cpp:43
43 thirdparty/polaris-cpp/polaris/model/instance.cpp: No such file or directory.
Missing separate debuginfos, use: debuginfo-install blas-3.4.2-8.el7.x86_64 glibc-2.17-292.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-37.el7_7.2.x86_64 lapack-3.4.2-8.el7.x86_64 libcom_err-1.42.9-16.el7.x86_64 libgcc-4.8.5-39.el7.x86_64 libgfortran-4.8.5-39.el7.x86_64 libgomp-4.8.5-39.el7.x86_64 libquadmath-4.8.5-39.el7.x86_64 libselinux-2.5-14.1.el7.x86_64 libstdc++-4.8.5-36.el7.x86_64 pcre-8.32-17.el7.x86_64
(gdb) bt
#0 _M_get (this=) at thirdparty/polaris-cpp/polaris/model/instance.cpp:43
#1 operator-> (this=) at /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/shared_ptr_base.h:1013
#2 polaris::Instance::GetPort (this=0x0) at thirdparty/polaris-cpp/polaris/model/instance.cpp:43
#3 0x00000000007eb727 in polaris::BlockRequest::OnFailure(std::string const&) ()
at thirdparty/polaris-cpp/polaris/plugin/server_connector/grpc_server_connector.cpp:937
#4 0x00000000007b6b54 in polaris::grpc::Http2Client::ResetAllStream (this=this@entry=0x7f9ba9f0e100,
status=status@entry=polaris::grpc::kGrpcStatusAborted, message="read from socket fd failed")
at thirdparty/polaris-cpp/polaris/network/grpc/http2.cpp:934
#5 0x00000000007b76dd in polaris::grpc::Http2Client::ReadHandler() () at thirdparty/polaris-cpp/polaris/network/grpc/http2.cpp:654
#6 0x000000000078978c in polaris::Reactor::RunEpollTask (this=this@entry=0x7fa780a0bd40, timeout=)
at thirdparty/polaris-cpp/polaris/reactor/reactor.cpp:180
#7 0x0000000000789973 in polaris::Reactor::Run (this=this@entry=0x7fa780a0bd40) at thirdparty/polaris-cpp/polaris/reactor/reactor.cpp:207
#8 0x00000000007edd7a in polaris::GrpcServerConnector::ThreadFunction (arg=0x7fa780a0bd00)
at thirdparty/polaris-cpp/polaris/plugin/server_connector/grpc_server_connector.cpp:250
#9 0x00007fa7ce674e65 in start_thread () from /lib64/libpthread.so.0
#10 0x00007fa7832d688d in clone () from /lib64/libc.so.6

feat: support standalone server access

What is the feature you want to add?
sdk can use the inputed server address to do all operations, no need to relay on the polaris.discover and polaris.healthcheck

Why do you want to add this feature?
when user use sdk with the standalone server, it won't register the polaris.discover and polaris.healthcheck

How to implement this feature?
in sdk side, when user not input the service address, it won't connect to the service

Additional context
Add any other context or screenshots about the feature request here.

Provide a quickstart example to guide user to run quickly

consumer: listen http port, accept http message , then getoneinstance to get an address, send message to provider, after message received, updateservicecallresult
provider:listen to TCP/HTTP port,register instance on startup, and do heartbeat by interval, and deregister when quit signal received.

缺少文件

Windows编译时提示缺少
trpcapi.proto
trpc.proto
dynamicweight.proto

支持polaris的配置中心能力

预期希望支持的能力

  • 根据命名空间、配置分组、配置名称获取配置
  • 支持根据命名空间、配置分组、配置名称监听配置
    • 允许用户已注册函数回调的形式

ubuntu 20.04 下编译报错

1、执行make
2、报错如下
polaris/plugin/load_balancer/locality_aware/locality_aware.cpp: In member function ‘virtual polaris::ReturnCode polaris::LocalityAwareLoadBalancer::ChooseInstance(polaris::ServiceInstances*, const polaris::Criteria&, polaris::Instance*&)’: polaris/logger.h:39:78: error: format not a string literal and no format arguments [-Werror=format-security] 39 | #define POLARIS_LOG(LOG_LEVEL, ...) GetLogger()->Log(LOG_LEVEL, ##__VA_ARGS__) | ^ polaris/plugin/load_balancer/locality_aware/locality_aware.cpp:192:7: note: in expansion of macro ‘POLARIS_LOG’ 192 | POLARIS_LOG(LOG_INFO, la_info.c_str()); | ^~~~~~~~~~~ cc1plus: all warnings being treated as errors make: *** [Makefile:231:build64/objs/plugin/load_balancer/locality_aware/locality_aware.o] 错误 1

限流、路由支持xxArgument新规则

1、参考PR:polarismesh/polaris-java#218
2、针对 ConsumerAPI 的 GetInstances、GetOneInstance 入参数信息 新增 Argument 参数列表,支持构造对应流量标签的请求参数
3、针对 LimitAPI 的 GetQuota 入参信息,新增 Argument 参数列表,支持构造对应的流量标签请求参数
4、调整 RuleRoute 以及限流中的标签匹配计算,支持 EQUALS/NOT_EQUALS/IN/NOT_IN/REGEX 五种匹配规则

运行 examples/provider/echo_server 会出现 segmentation fault

运行 examples/provider/echo_server 会出现 segmentation fault

./build64/examples/provider/echo_provider default echo token 127.0.0.1 8111

堆栈信息如下:
43 int Instance::GetPort() const { return impl_->remote_value_->port_; }
Missing separate debuginfos, use: debuginfo-install bash-4.2.46-34.tl2.3.x86_64 glibc-2.17-323.tl2.x86_64 libgcc-4.8.5-44.tl2.1.x86_64 libstdc++-4.8.5-44.tl2.1.x86_64 zlib-1.2.7-20.tl2.x86_64
(gdb) bt
#0 polaris::Instance::GetPort (this=0x0) at polaris/model/instance.cpp:43
#1 0x000000000048c06e in polaris::BlockRequest::OnSuccess (this=0xadf2b0, response=0x7ffff000a140) at polaris/plugin/server_connector/grpc_server_connector.cpp:921
#2 0x0000000000491355 in polaris::grpc::RequestCallbackv1::Response::OnResponse (this=0xadf2b0, response=0x7ffff000a080) at polaris/network/grpc/client.h:67
#3 0x000000000046c83e in polaris::grpc::GrpcRequest::OnReceiveResponse (this=, response=0x7ffff000a080) at polaris/network/grpc/client.cpp:164
#4 0x000000000046cced in polaris::grpc::GrpcStream::OnData (this=0x7ffff0008260, data=..., end_stream=) at polaris/network/grpc/client.cpp:120
#5 0x000000000046fe8c in polaris::grpc::Http2Client::OnFrameReceived (this=0xa9c700, frame=0xab0c80) at polaris/network/grpc/http2.cpp:846
#6 0x0000000000501758 in session_call_on_frame_received ()
#7 0x0000000000504663 in nghttp2_session_on_data_received ()
#8 0x00000000005046f9 in session_process_data_frame ()
#9 0x000000000050729f in nghttp2_session_mem_recv ()
#10 0x000000000046f5b4 in polaris::grpc::Http2Client::OnRecvData (this=this@entry=0xa9c700, data=data@entry=0x7ffff5fa6d30) at polaris/network/grpc/http2.cpp:550
#11 0x00000000004709e0 in polaris::grpc::Http2Client::ReadHandler (this=0xa9c700) at polaris/network/grpc/http2.cpp:664
#12 0x0000000000462d51 in polaris::Reactor::RunEpollTask (this=this@entry=0xa99580, timeout=) at polaris/reactor/reactor.cpp:180
#13 0x000000000046318b in polaris::Reactor::Run (this=this@entry=0xa99580) at polaris/reactor/reactor.cpp:207
#14 0x000000000048f302 in polaris::GrpcServerConnector::ThreadFunction (arg=0xa99540) at polaris/plugin/server_connector/grpc_server_connector.cpp:250
#15 0x00007ffff6d82ea5 in start_thread () from /lib64/libpthread.so.0
#16 0x00007ffff6aab9fd in clone () from /lib64/libc.so.6

多provider情况下Heartbeat会core在inet_ntoa

我们创建了多个ProviderApi来将实例注册到多个不同的名字服务上。但在运行中,会随机出现core在心跳时解析host上。
看到TryLookup 中使用了非线程安全的inet_ntoa。为什么不适用线程安全的inet_ntop了?
std::string target_address = inet_ntoa(*(struct in_addr*)host->h_addr_list[0]);

(gdb) bt
#0 0x0000000001e08b8c in polaris::grpc::TryLookup (address=...) at polaris/network/grpc/http2.cpp:425
#1 polaris::grpc::Http2Client::ConnectTo(std::string const&, int) () at polaris/network/grpc/http2.cpp:455
#2 0x0000000001dbbe54 in polaris::grpc::GrpcClient::ConnectTo (port=, host=..., this=0x7fa36a607c80) at polaris/network/grpc/client.h:192
#3 polaris::BlockRequest::PrepareClient() () at polaris/plugin/server_connector/grpc_server_connector.cpp:972
#4 0x0000000001dbcdde in polaris::GrpcServerConnector::InstanceHeartbeat (this=, req=..., timeout_ms=)
at polaris/plugin/server_connector/grpc_server_connector.cpp:762
#5 0x0000000001e0367b in polaris::ProviderApi::Heartbeat(polaris::InstanceHeartbeatRequest const&) () at polaris/provider/api.cpp:196
#6 0x0000000001d84e90 in gxl_utils::PolarisWrapper::KeepHealth() () at gxl-utils/polaris/polaris_wrapper.cc:199
#7 0x00000000020f65af in execute_native_thread_routine ()
#8 0x00007fc0de8e2e65 in ?? ()
#9 0x0000000000000000 in ?? ()

feat: system service discovery should get ride of route-rule

What is the feature you want to add?
sdk discover polaris.discover, polaris.healthcheck, polaris.monitor, should not rely on route-rule

Why do you want to add this feature?
user install standalone version, he won't add the routerule to service

How to implement this feature?
use metadata routing instead of rulebase routing

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.