- 
                Notifications
    You must be signed in to change notification settings 
- Fork 26
RSDK-10435: Dial direct #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a56574f
              d86eac7
              4d5f8aa
              6eb0fdd
              d247cc8
              4b7e4c2
              c41325b
              c549c07
              a21c424
              41e6960
              d0c3f21
              1f41cad
              a53494a
              bbc0adf
              a3add02
              1ae3732
              c3ff877
              7d8175b
              26c2225
              0cd8723
              d3cdb58
              c0e2197
              beab7d2
              89104c9
              8d68fd2
              29cfd35
              fde961c
              44d8601
              c7d8b4c
              afa6c70
              8ba5efa
              95dc5f8
              f86011f
              4a82a6d
              8e99746
              a8b858d
              2e2b2ec
              67aec53
              5a3d47c
              350f0ff
              fa1f598
              cb7ec67
              ed6bfed
              2c7a942
              5f9d3b1
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -5,6 +5,7 @@ | |
| #include <grpcpp/client_context.h> | ||
| #include <grpcpp/support/status.h> | ||
|  | ||
| #include <viam/sdk/common/private/instance.hpp> | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still needed? | ||
| #include <viam/sdk/common/private/version_metadata.hpp> | ||
| #include <viam/sdk/log/logging.hpp> | ||
|  | ||
|  | @@ -32,6 +33,12 @@ ClientContext::ClientContext() : wrapped_context_(std::make_unique<GrpcClientCon | |
| add_viam_client_version_(); | ||
| } | ||
|  | ||
| ClientContext::ClientContext(const ViamChannel& channel) : ClientContext() { | ||
| if (channel.auth_token().has_value()) { | ||
| wrapped_context_->AddMetadata("authorization", "Bearer " + *channel.auth_token()); | ||
| } | ||
| } | ||
|  | ||
| ClientContext::~ClientContext() = default; | ||
|  | ||
| ClientContext::operator const GrpcClientContext*() const { | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -4,6 +4,7 @@ | |
| #include <viam/sdk/common/grpc_fwd.hpp> | ||
| #include <viam/sdk/common/private/utils.hpp> | ||
| #include <viam/sdk/common/proto_value.hpp> | ||
| #include <viam/sdk/rpc/dial.hpp> | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the dial header actually required here? | ||
|  | ||
| namespace viam { | ||
| namespace sdk { | ||
|  | @@ -38,6 +39,8 @@ void set_name(...); | |
| class ClientContext { | ||
| public: | ||
| ClientContext(); | ||
| ClientContext(const ViamChannel& channel); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe  | ||
|  | ||
| ~ClientContext(); | ||
|  | ||
| void try_cancel(); | ||
|  | @@ -110,7 +113,7 @@ class ClientHelper { | |
| template <typename ResponseHandlerCallable, typename ErrorHandlerCallable> | ||
| auto invoke(ResponseHandlerCallable&& rhc, ErrorHandlerCallable&& ehc) { | ||
| client_helper_details::set_name(&request_, client_); | ||
| ClientContext ctx; | ||
| ClientContext ctx(client_->channel()); | ||
|  | ||
| if (debug_key_ != "") { | ||
| ctx.set_debug_key(debug_key_); | ||
|  | @@ -132,7 +135,7 @@ class ClientHelper { | |
| typename ErrorHandlerCallable = decltype(default_ehc_)> | ||
| auto invoke_stream(ResponseHandlerCallable rhc, ErrorHandlerCallable&& ehc = default_ehc_) { | ||
| *request_.mutable_name() = client_->name(); | ||
| ClientContext ctx; | ||
| ClientContext ctx(client_->channel()); | ||
|  | ||
| auto reader = (stub_->*pfn_)(ctx, request_); | ||
|  | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we haven't already, I think it is time to file a ticket to introduce substituted config headers, along with prelude/postlude headers to ensure macro hygiene.