-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat: Support for the DAPR_HTTP_ENDPOINT
and DAPR_GRPC_ENDPOINT
environment variables. Adds support for DAPR_API_TOKEN to gRPC client
#519
Conversation
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
DAPR_HTTP_ENDPOINT
environment variableDAPR_HTTP_ENDPOINT
environment variable
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
DAPR_HTTP_ENDPOINT
environment variableDAPR_HTTP_ENDPOINT
and DAPR_GRPC_ENDPOINT
environment variable
DAPR_HTTP_ENDPOINT
and DAPR_GRPC_ENDPOINT
environment variableDAPR_HTTP_ENDPOINT
and DAPR_GRPC_ENDPOINT
environment variables. Adds support for DAPR_API_TOKEN to gRPC client
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #519 +/- ##
==========================================
+ Coverage 35.23% 35.34% +0.11%
==========================================
Files 90 90
Lines 10143 10187 +44
Branches 415 429 +14
==========================================
+ Hits 3574 3601 +27
- Misses 6503 6516 +13
- Partials 66 70 +4
☔ View full report in Codecov by Sentry. |
Signed-off-by: Elena Kolevska <[email protected]>
tsconfig.json
Outdated
@@ -12,7 +12,7 @@ | |||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ | |||
"declaration": true /* Generates corresponding '.d.ts' file. */, | |||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ | |||
// "sourceMap": true, /* Generates corresponding '.map' file. */ | |||
"sourceMap": true /* Generates corresponding '.map' file. */, |
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.
Do we need this?
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.
@shubham1172 I enabled this so I could debug the code. I'm not a typescript person though, so if you think it's better not to have it in a release, that's totally ok for me, I'll just enable it for my local development.
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.
Since we use the same tsconfig for dev and prod, the production build size will also increase. We could add support to conditionally generate sourceMap for development only, but for now we should turn this off.
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.
Has this been resolved meanwhile?
Co-authored-by: Shubham Sharma <[email protected]> Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Shubham Sharma <[email protected]> Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
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.
@elena-kolevska LGTM overall! I wish this was two PRs instead of one but it's ok for now since we are very close to release and both of them are affecting the DaprClient.
Great work with adding the test to check for Dapr API token and fixing the proxy to include interceptors from gRPC client!
tsconfig.json
Outdated
@@ -12,7 +12,7 @@ | |||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ | |||
"declaration": true /* Generates corresponding '.d.ts' file. */, | |||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ | |||
// "sourceMap": true, /* Generates corresponding '.map' file. */ | |||
"sourceMap": true /* Generates corresponding '.map' file. */, |
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.
Has this been resolved meanwhile?
Signed-off-by: Elena Kolevska <[email protected]>
@XavierGeerinck and @shubham1172 Thank you both for the review! I updated the PR and commented on some of your questions. |
…he docs Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
// Using HTTP, when DAPR_HTTP_ENDPOINT is set | ||
const client = new DaprClient({ daprHost, daprPort }); | ||
|
||
// Using gRPC, when DAPR_GRPC_ENDPOINT is set | ||
const client = new DaprClient({ communicationProtocol: CommunicationProtocol.GRPC }); |
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.
Are we showing here that this is the equivalent of setting the environment variable?
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.
Yes, this is how we can instantiate the client when we have DAPR_GRPC_ENDPOINT
set. I noticed I had a copy/paste error for the HTTP example above though, so I fixed that. Basically, we don't need to pass constructor arguments for host and port when we have the env variables set.
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.
I wonder if DAPR_GRPC_ENDPOINT
is set, should we also by-default use communication protocol GRPC. Also while instantiating the DaprClient
, should we clearly log if we used env var to figure out host/port/protocol.
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.
Good point! I can add a log.
Regarding the automatic setting of the protocol, I think we can't do it, because, as per the proposal we can have both DAPR_GRPC_ENDPOINT
and DAPR_HTTP_ENDPOINT
set at the same time.
DAPR_GRPC_ENDPOINT and DAPR_HTTP_ENDPOINT can be set at the same time since some SDKs (Java, as of now) supports both protocols at the same time and app can pick which one to use.
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.
Right (and maybe this can be added to the proposal to unify SDK implementations), so if
DAPR_GRPC_ENDPOINT
is set, set protocol to gRPCDAPR_HTTP_ENDPOINT
is set, set protocol to HTTP- Both are set, use HTTP
- Finally, if function param is specified, that overrides everything
- No function param or env var also means HTTP
PS, we can track this separately as well.
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.
LGTM! Thanks for updating the parseEndpoint
implementation, much better to delegate the parsing!
Signed-off-by: Elena Kolevska <[email protected]>
Thank you so much! Running the tests now and if they pass we can merge :) thanks again for sticking with us and fixing the URL lib usage |
Description
DAPR_API_TOKEN
to gRPC clientDAPR_GRPC_ENDPOINT
environment variableDAPR_HTTP_ENDPOINT
environment variableIssue reference
Issue this PR will close: #502 and #520
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: