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

RTL10b: Implement untilAttach for RealtimeChannel.history. #246

Merged
merged 1 commit into from
Feb 24, 2016

Conversation

tcard
Copy link
Contributor

@tcard tcard commented Feb 23, 2016

Fixes #234.

@@ -16,4 +17,10 @@ ART_ASSUME_NONNULL_BEGIN

@end

@interface ARTRealtimeHistoryQuery ()

@property (strong, readwrite) ARTRealtimeChannel *realtimeChannel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to be weak.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why? realtimeChannel doesn't hold references to the ARTRealtimeHistoryQuery. There's no cycle here as far as I can see.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query can retain the channel if you create the ARTRealtimeHistoryQuery in other part of the main code and the client tries to release the channel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but as soon as the query is gone (ie. as soon as the call site returns) the channel will lose its only reference left and all will be good. How can that leak?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can hold the query anyway and with weak you will have the guarantee.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really can't see and scenario in which this changes anything in practice, because the only way this property will be set is by ARTRealtimeChannel.history itself, and if you're calling that method obviously you have the channel, and even if you drop the channel and hold to the query you can't do anything with the query but reuse it, which will change its realtimeChannel. But anyway, done at 547e39c.

@ricardopereira
Copy link
Contributor

Beside a small comment, LGTM

if (self.realtimeChannel.state != ARTRealtimeChannelAttached) {
@throw [NSError errorWithDomain:ARTAblyErrorDomain code:ARTRealtimeHistoryErrorNotAttached userInfo:nil];
}
[items addObject:[NSURLQueryItem queryItemWithName:@"from_serial" value:self.realtimeChannel.attachSerial]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be fromSerial as we changed all of our query params to use camelCase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it working then? It is from_serial in the spec.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we support the old format as well for backwards compatibility :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, OK. Fixed at 7532c73.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricardopereira That's done at 7532c73.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@mattheworiordan
Copy link
Member

Looks good other than small comment

@tcard tcard force-pushed the history-until-attach branch from 7532c73 to 44e90f4 Compare February 24, 2016 17:58
tcard added a commit that referenced this pull request Feb 24, 2016
RTL10b: Implement untilAttach for RealtimeChannel.history.
@tcard tcard merged commit 03a7d16 into master Feb 24, 2016
@tcard tcard deleted the history-until-attach branch February 24, 2016 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants