-
Notifications
You must be signed in to change notification settings - Fork 117
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
[ADDED] Subscription.Close() allows closing durable #115
Conversation
Changes Unknown when pulling 77819a9 on add_subscription_close into * on master*. |
@sfrooster If/when that is merged, I would need to vendor the protobuf into the server and implement the server side (fast since code is already done, just need to vendor it). |
@kozlovic This looks good to me. Erroring when the server doesn't support the protocol/operation avoids the implicit error, so that's good. Is there anyway for a client to know (on connect) what version the server is, or what protocol version or operations it supports? If not, that may be a good future item. Either way, this seems good to me. |
@sfrooster Yes, the client sends its protocol version on connect and receives the server protocol version in the connect response. Are you asking to expose that? The client API can then return an error when The question was, should I simply always fail if connecting to an older server, regardless if it is a durable or not (although non-durable don't really care). |
By the way, I first coded the protocol as a feature bitmask, with even a Features() connect option that could make the client behave a certain way, and would have done the same for the server, but the interest for that for me was for testing, but I am afraid that it could open door to bad behavior, so decided to fallback to simple incremental protocol version. |
Ah, you were asking about failing on connect. No, I don't think you should do that because it makes a mismatch too painful. I thought you were asking about erroring if close is called with a client that doesn't support it, which I think does make sense. Exposing the protocol/server version to the client would be a nice way for the client to tailor the calls it makes for different servers. |
@sfrooster No, there is a misunderstanding. I am not saying that client should error out on connect. A new client can connect to an older server without any difference in behavior than it was connecting to a new server expect for the |
@kozlovic I think it seems reasonable enough as you have it. |
Was experimenting with bitmask again and exposing the server's "features" as we discussed. Then I realized that client does not really connect to a server, so if server of different versions are stopped and restarted, client would get the server's features/proto only from the original connect response. Something to think about... |
77819a9
to
7219ce2
Compare
Changes Unknown when pulling 7219ce2 on add_subscription_close into * on master*. |
@sfrooster Here is a new take. It does not use protocol version, but adds a new |
@ColinSullivan1 @aricart @mcqueary Guys, please have a look since if this is accepted, it will have to be ported in your respective streaming clients. |
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.
@@ -271,25 +290,47 @@ func (sub *subscription) Unsubscribe() error { | |||
return ErrConnectionClosed | |||
} | |||
|
|||
delete(sc.subMap, inbox) | |||
delete(sc.subMap, sub.inbox) |
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.
Sub is guaranteed to valid at this point?
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, I started to modify current code to make copies (also for connection), but at this point these values are immutable and both sub and sc are available when used there.
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
Resolves #114 Will require nats-io/nats-streaming-server#182 to be implemented.
7219ce2
to
0d48ba8
Compare
This is related to PR #115 and server side [PR](nats-io/nats-streaming-server#203) Noticed that we could have used UnsubscribeRequest since content of that one and SubscriptionCloseRequest were same. Also, the server was actually implemented with UnsubscribeRequest and works fine. What matters is the subject the protocol is sent to.
Resolves #114
Will require nats-io/nats-streaming-server#182
to be implemented.