Skip to content
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

[go] wrpcnats async parameter write indexing #80

Open
rvolosatovs opened this issue May 21, 2024 · 1 comment
Open

[go] wrpcnats async parameter write indexing #80

rvolosatovs opened this issue May 21, 2024 · 1 comment
Labels
go wRPC Go support good first issue Good for newcomers

Comments

@rvolosatovs
Copy link
Member

rvolosatovs commented May 21, 2024

Currently Index method is not implemented in wrpcnats.paramWriter, because as part of the root subject write it may lazily perform the handshake.
The implementation should be updated in such a way that the indexed parameter writers would not be able to write until the root writer performs the handshake. The transmission subject would then need to be communicated to the indexed writers.

Perhaps a possible way to handle this would be to use a RWMutex, which is locked on the root writer creation and unlocked once the handshake is complete. Indexed parameter writers Writes would then start with RLocking that shared mutex and block until the handshake is complete. We could also change init field to atomic.Bool here perhaps, which would let the indexed writers first check the atomic and only then attempt to RLock is they loaded false

https://github.com/wrpc/wrpc/blob/a75b04391524217058fb4c5284aee224ee8e4464/go/nats/client.go#L193

@rvolosatovs
Copy link
Member Author

Rust implementation of this looks like this:
https://github.com/rvolosatovs/wrpc/blob/85b043b84bd70fa2994cde8ced129d05b6739284/crates/transport-nats-next/src/lib.rs#L444-L467
https://github.com/rvolosatovs/wrpc/blob/85b043b84bd70fa2994cde8ced129d05b6739284/crates/transport-nats-next/src/lib.rs#L514-L533

So on successful handshake, the negotiated subject is sent to all indexed parameter writers and the error writer.

@rvolosatovs rvolosatovs changed the title [golang] wrpcnats async parameter write indexing [go] wrpcnats async parameter write indexing May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go wRPC Go support good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant