NatsOpts.ConfigureWebSocketOpts callback handler
As discussed in #305 this PR is adding support for manipulating the ClientWebSocketOptions used for WebSocket connections. Among other things, this allows setting an authorization header.
I left this in draft state to see if it'll pass all tests within the pipeline first. If a maintainer could approve running the pipeline I'd appreciate. @mtmk
@wolfman42 done.
@galvesribeiro I think (hope) the issues are fixed now.
@wolfman42 convert it out of draft when you feel ready and others can review it.
Thanks @wolfman42. Could you also sing your commits please? it's a CNCF requirement we need to follow.
I checked but don't think my changes could affect this failing unit test: NATS.Client.JetStream.Tests.ConsumerConsumeTest.Consume_dispose_test
Perhaps run the tests again?
I checked but don't think my changes could affect this failing unit test:
NATS.Client.JetStream.Tests.ConsumerConsumeTest.Consume_dispose_testPerhaps run the tests again?
it's a flapper. I'm rerunning it now.
Thanks @wolfman42. Could you also sing your commits please? it's a CNCF requirement we need to follow.
sorry @wolfman42 could you sign all your commits please? (you will have to force push, which should be fine) we set github checks, unfortunately can't merge with unsigned commits. thanks.
Thanks @wolfman42. Could you also sing your commits please? it's a CNCF requirement we need to follow.
sorry @wolfman42 could you sign all your commits please? (you will have to force push, which should be fine) we set github checks, unfortunately can't merge with unsigned commits. thanks.
Done. I went ahead and squashed the 3 commits as well.
A couple more ideas, which could be done in a follow-up before releasing:
- Do we want to nest this option under
NatsWebSocketOptsinstead of setting it directly inNatsOpts? This could make it easier to offer a shortcuts for popular options such as adding headers:
public sealed record NatsWebSocketOpts
{
public Dictionary<string, StringValues>? RequestHeaders { get; init; }
public Func<Uri, ClientWebSocketOptions, CancellationToken, ValueTask>? ConfigureWebSocketOptions { get; init; }
}
- We probably want to invoke
NatsTlsOpts.AuthenticateAsClientOptionsAsyncand copy bothClientCertificatesandRemoteCertificateValidationCallbacktoClientWebSocketOptionsprior to passing it to the callback
A couple more ideas, which could be done in a follow-up before releasing:
Great ideas @caleblloyd created #610 so we don't forget ;) let us know if you want more changes to this PR? We might release a preview with this PR but we'll make sure #610 is resolved before a stable release.
merging so @Ivandemidov00 can have a look with #610