-
-
Notifications
You must be signed in to change notification settings - Fork 52
Support http lookup authentication(oauth2 and token) #300
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
Conversation
07b5325
to
fe664cd
Compare
authenticationDataProvider.GetHttpHeaders() |> Seq.iter ( | ||
fun headerProperty -> request.Headers.Add(headerProperty.Key, headerProperty.Value) | ||
) | ||
let! response = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead) |> Async.AwaitTask |
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.
Async.AwaitTask is not needed here
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.
Also, why is it HttpCompletionOption.ResponseHeadersRead
?
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.
Async.AwaitTask is not needed here
Fixed
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.
Also, why is it
HttpCompletionOption.ResponseHeadersRead
?
I changed HttpCompletionOption.ResponseHeadersRead
to HttpCompletionOption.ResponseContentRead
in my latest commit.
I found that GetStreamAsync()
cannot pass custom header, so I searched StackOverflow and refer this answer.
However I think maybe there is no big difference between HttpCompletionOption.ResponseContentRead
and HttpCompletionOption.ResponseHeadersRead
in small size http response, because these two options are only determining when to read the response:
Indicates if HttpClient operations should be considered completed either as soon as a response is available, or after reading the entire response message including the content.
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcompletionoption?view=net-9.0
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.
ResponseContentRead
is default, so I think it can just be omitted
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.
Actually, I've just realized, that we don't have to have this function return stream. We can make it generic, just like in Java and leverage GetFromJsonAsync built-in method inside
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.
Actually, I've just realized, that we don't have to have this function return stream. We can make it generic, just like in Java and leverage GetFromJsonAsync built-in method inside
@Lanayx
Fixed, please review again. And I change GetStreamAsync()
name to Get()
to make consistent with Java client.
27bff25
to
04b849d
Compare
BrokerUrlTls: string; | ||
HttpUrl: string; | ||
HttpUrlTls: string |}> | ||
|> Async.AwaitTask |
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 this method is not recursive/retriable, we don't need async here, Async.AwaitTask as well, and GetBrokerInner
is not needed, this code can be moved to just GetBroker
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 removed async and Async.AwaitTask in GetBrokerInner()
, and migrate this code to GetBroker()
with background{}
wrapper.
randomServiceUri.AbsoluteUri + $"admin/v2/namespaces/%s{ns.ToString()}/topics?mode=%s{mode}" | ||
|> httpClient.GetStreamAsync | ||
|> pulsarHttpClient.Get<string seq> |
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.
Can you please change seq to array (in the interface 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.
I change HttpLookupService.fs
ILookupService
and BinaryLookupService
GetTopicsUnderNamespace()
return type. I think this function only used in PulsarClient.fs.GetTopicsByPattern()
so that we don't need to change caller strategy.
04b849d
to
b46cc1e
Compare
b46cc1e
to
c1b9588
Compare
support #299
Changes
HasDataForHttp()
andGetHttpHeaders()
in AuthenticationDataProvider type to generate http headers authentication propertiesGetStreamAsync()
functionhttpClient.GetStreamAsync()
withpulsarHttpClient.GetStreamAsync()
in HttpLookupService to enable authentication