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

[ECO-4933] Added readonly ARTChannelProperties object to the public interface #1965

Merged
merged 3 commits into from
Sep 3, 2024

Conversation

maratal
Copy link
Collaborator

@maratal maratal commented Aug 25, 2024

Added readonly ARTChannelProperties object to the public interface not touching existing internal properties attachSerial and channelSerial (from which it's being constructed with a private constructor for each call).

Closes #1960

Summary by CodeRabbit

  • New Features

    • Introduced new methods for accessing channel properties, including a synchronized method for thread-safe access.
    • Enhanced the ARTChannelProperties class with a dedicated initializer for improved encapsulation of channel properties.
    • Added a new properties property to ARTRealtimeChannel for better access to channel state.
  • Bug Fixes

    • Updated test cases to reflect changes in channel serial number references, ensuring assertions target the correct properties.

Copy link

coderabbitai bot commented Aug 25, 2024

Walkthrough

The changes introduce a new ARTChannelProperties class, enhancing the ARTRealtimeChannel by adding methods to retrieve channel properties, including a synchronized version for thread safety. A new initializer for ARTChannelProperties allows for setting attach and channel serials specifically. Modifications in tests reflect these updates by replacing internal state references with the new properties access methods.

Changes

Files Change Summary
Source/ARTRealtimeChannel.m Added methods for accessing channel properties, including a synchronized method and a new ARTChannelProperties class with an initializer.
Source/include/Ably/ARTRealtimeChannel.h Introduced the ARTChannelProperties class with properties for attachSerial and channelSerial, and added a property to ARTRealtimeChannel.
Test/Tests/RealtimeClientChannelTests.swift Updated test assertions to reference the new properties for channel serial numbers instead of internal state.

Assessment against linked issues

Objective Addressed Explanation
Implement RealtimeChannel#properties (RTL15)

🐇 In the realm of channels bright,
Properties gleam with newfound light,
With serials safe, in sync they play,
Enhancing chats in a joyful way!
🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot temporarily deployed to staging/pull/1965/features August 25, 2024 15:07 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 55ad795 and c727208.

Files selected for processing (4)
  • Source/ARTRealtimeChannel.m (3 hunks)
  • Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h (2 hunks)
  • Source/include/Ably/ARTRealtimeChannel.h (3 hunks)
  • Test/Tests/RealtimeClientChannelTests.swift (1 hunks)
Additional context used
SwiftLint
Test/Tests/RealtimeClientChannelTests.swift

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

Additional comments not posted (8)
Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h (2)

37-37: Approved addition of properties_nosync method.

This method provides a non-synchronized way to access channel properties, potentially improving performance in scenarios where thread safety is managed externally.


101-101: Approved the new initializer for ARTChannelProperties.

The initializer allows setting attachSerial and channelSerial directly, which is essential for managing channel state accurately.

Source/include/Ably/ARTRealtimeChannel.h (2)

14-14: Approved the introduction of ARTChannelProperties class and its properties.

The new class and its properties (attachSerial and channelSerial) encapsulate channel state information effectively, enhancing clarity and manageability of channel-related data.

Also applies to: 157-164


32-32: Approved the addition of properties in ARTRealtimeChannel.

This property provides a straightforward way to access channel properties, improving the API's usability and aligning with the objectives of enhancing channel management.

Source/ARTRealtimeChannel.m (3)

72-74: Approved the addition of synchronized and non-synchronized properties methods.

These methods provide both thread-safe and efficient access to channel properties, enhancing the API's flexibility and safety.

Also applies to: 1085-1091


1093-1095: Approved the properties_nosync method implementation.

This method correctly initializes ARTChannelProperties with attachSerial and channelSerial, aligning with the intended use of these properties for channel state management.


1142-1148: Approved the initializer for ARTChannelProperties.

This implementation correctly assigns attachSerial and channelSerial, ensuring that channel properties are initialized accurately.

Test/Tests/RealtimeClientChannelTests.swift (1)

4259-4266: Ensure proper handling of channel serial updates in message and presence actions.

The tests correctly verify that the channelSerial is updated whenever a protocol message with a message, presence, or attached action is received. This aligns with the specification [RTL15b]. Ensure that the implementation of message handling in the SDK properly updates the channelSerial to maintain state consistency.

Also applies to: 4274-4274

Tools
SwiftLint

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

@github-actions github-actions bot temporarily deployed to staging/pull/1965/jazzydoc August 25, 2024 15:12 Inactive
…not touching existing internal properties `attachSerial` and `channelSerial` (from which it's being constructed with a private constructor for each call).
@maratal maratal force-pushed the feature/1960-channel-properties branch from c727208 to fbe2e92 Compare August 25, 2024 15:46
@github-actions github-actions bot temporarily deployed to staging/pull/1965/features August 25, 2024 15:47 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c727208 and fbe2e92.

Files selected for processing (4)
  • Source/ARTRealtimeChannel.m (3 hunks)
  • Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h (2 hunks)
  • Source/include/Ably/ARTRealtimeChannel.h (3 hunks)
  • Test/Tests/RealtimeClientChannelTests.swift (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • Source/ARTRealtimeChannel.m
  • Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h
  • Source/include/Ably/ARTRealtimeChannel.h
Additional context used
SwiftLint
Test/Tests/RealtimeClientChannelTests.swift

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

Additional comments not posted (2)
Test/Tests/RealtimeClientChannelTests.swift (2)

4259-4266: Updated channelSerial references look good.

The changes correctly update the assertions to use channel.properties.channelSerial, aligning with the PR's objectives to shift from internal state references to properties access methods.

Tools
SwiftLint

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)


4274-4274: Consistent update for channelSerial access.

This change is consistent with the previous updates and correctly uses channel.properties.channelSerial for assertions.

@github-actions github-actions bot temporarily deployed to staging/pull/1965/jazzydoc August 25, 2024 15:51 Inactive
@maratal maratal changed the title [ECO-4933] Added readonly ARTChannelProperties object to the public interface [ECO-4933] Added readonly ARTChannelProperties object to the public interface Aug 27, 2024
@github-actions github-actions bot temporarily deployed to staging/pull/1965/features August 28, 2024 21:45 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1965/jazzydoc August 28, 2024 21:49 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fbe2e92 and 80180c3.

Files selected for processing (1)
  • Test/Tests/RealtimeClientChannelTests.swift (3 hunks)
Additional context used
SwiftLint
Test/Tests/RealtimeClientChannelTests.swift

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

Additional comments not posted (6)
Test/Tests/RealtimeClientChannelTests.swift (6)

4259-4266: Consider adding more comprehensive tests for channel serial updates.

While the current tests check the basic functionality, consider adding more scenarios that involve complex interactions or error conditions to ensure the channelSerial is robustly handled across different states and edge cases.

Would you like me to help create additional test cases or enhance the existing ones to cover more scenarios?

Tools
SwiftLint

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)


4259-4266: Add validation for the absence of channelSerial when not expected.

The tests currently check for the presence of channelSerial when expected. It would be beneficial to also explicitly validate cases where channelSerial should not be present to ensure that it is not incorrectly set in those scenarios.

I can help implement these additional checks if you agree it's beneficial.

Tools
SwiftLint

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)


4259-4266: Improve error handling in channel serial update tests.

Consider adding more robust error handling in the tests to catch and report errors related to channel serial updates. This could help in identifying issues during the testing phase before they affect production environments.

Let me know if you need assistance in implementing enhanced error handling for these tests.

Tools
SwiftLint

[Warning] 4263-4263: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)


4274-4274: Consider adding more comprehensive tests for channel serial updates.

While the current tests check the basic functionality, consider adding more scenarios that involve complex interactions or error conditions to ensure the channelSerial is robustly handled across different states and edge cases.

Would you like me to help create additional test cases or enhance the existing ones to cover more scenarios?


4274-4274: Add validation for the absence of channelSerial when not expected.

The tests currently check for the presence of channelSerial when expected. It would be beneficial to also explicitly validate cases where channelSerial should not be present to ensure that it is not incorrectly set in those scenarios.

I can help implement these additional checks if you agree it's beneficial.


4274-4274: Improve error handling in channel serial update tests.

Consider adding more robust error handling in the tests to catch and report errors related to channel serial updates. This could help in identifying issues during the testing phase before they affect production environments.

Let me know if you need assistance in implementing enhanced error handling for these tests.

Test/Tests/RealtimeClientChannelTests.swift Outdated Show resolved Hide resolved
@maratal maratal force-pushed the feature/1960-channel-properties branch from 80180c3 to fee7703 Compare August 29, 2024 13:17
@github-actions github-actions bot temporarily deployed to staging/pull/1965/features August 29, 2024 13:18 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
Test/Tests/RealtimeClientChannelTests.swift (1)

4264-4264: Replace unused closure parameter with _.

The closure parameter presenceMessage is not used and should be replaced with _ to avoid warnings.

Apply this diff to fix the issue:

- channel.presence.subscribe { presenceMessage in
+ channel.presence.subscribe { _ in
Tools
SwiftLint

[Warning] 4264-4264: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 80180c3 and fee7703.

Files selected for processing (2)
  • Source/ARTRealtimeChannel.m (4 hunks)
  • Test/Tests/RealtimeClientChannelTests.swift (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Source/ARTRealtimeChannel.m
Additional context used
SwiftLint
Test/Tests/RealtimeClientChannelTests.swift

[Warning] 4264-4264: Unused parameter in a closure should be replaced with _

(unused_closure_parameter)

Additional comments not posted (1)
Test/Tests/RealtimeClientChannelTests.swift (1)

Line range hint 4281-4281: LGTM!

The code changes are approved.

@github-actions github-actions bot temporarily deployed to staging/pull/1965/jazzydoc August 29, 2024 13:21 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fee7703 and 9d213e4.

Files selected for processing (1)
  • Source/include/Ably/ARTRealtimeChannel.h (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Source/include/Ably/ARTRealtimeChannel.h

Copy link
Contributor

@umair-ably umair-ably left a comment

Choose a reason for hiding this comment

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

LGTM once @lawrence-forooghian is happy with the open conversations

@maratal maratal merged commit 64967f7 into main Sep 3, 2024
7 checks passed
@maratal maratal deleted the feature/1960-channel-properties branch September 3, 2024 14:44
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.

Implement RealtimeChannel#properties (RTL15)
3 participants