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

Feat for media server #165

Merged
merged 17 commits into from
Jul 18, 2024
Merged

Feat for media server #165

merged 17 commits into from
Jul 18, 2024

Conversation

giangndm
Copy link
Contributor

This PR updates and implement more features for working with media-server

Copy link

coderabbitai bot commented May 15, 2024

Walkthrough

Walkthrough

The recent modifications across multiple files introduce significant changes to type parameters, pattern matching, and data structures. These include updates to the SdnBuilder generic types, event handling in SdnExtOut, and the use of Buffer instead of Vec<u8>. Additionally, the ClusterLogic and WhipTask structures have been streamlined for better event and task management, and several imports and method signatures have been adjusted to improve code efficiency and maintainability.

Changes

File Change Summary
bin/src/main.rs Updated generic parameters for SdnBuilder and modified pattern matching in main function.
examples/quic-tunnel/src/sdn.rs Adjusted imports, SdnBuilder usage, and event handling in run_sdn function.
examples/quic-tunnel/src/vnet/mod.rs Imported Buffer and updated NetworkPkt struct to use Buffer.
examples/quic-tunnel/src/vnet/socket.rs Changed transmit.contents conversion to use into() instead of to_vec().
examples/whip-whep/src/main.rs Removed unused imports and updated IP addresses and service builder types.
examples/whip-whep/src/sfu/cluster.rs Removed on_tick and pop_output methods from ClusterLogic.
examples/whip-whep/src/sfu/mod.rs Updated imports, enums, and task group definitions.
examples/whip-whep/src/sfu/whep.rs Modified WhepInput, WhepOutput, and WhepTask struct and method signatures.
examples/whip-whep/src/sfu/whip.rs Updated WhipInput, WhipOutput, and WhipTask struct and method implementations.
examples/whip-whep/src/worker.rs Revised enum variants, struct fields, and method implementations in RunnerWorker.
packages/network/src/base/feature.rs Updated FeatureControlActor and related enums to include UserData as a generic parameter.
packages/network/src/base/mod.rs Removed import for BufferMut, retained Buffer import.
packages/network/src/base/msg.rs Changed TransportMsg to use Buffer instead of Vec<u8>.
packages/network/src/base/secure.rs Updated Encryptor and Decryptor traits to use Buffer.
packages/network/src/base/service.rs Updated ServiceControlActor and related enums to include UserData.

🐇
In the realm of code so bright,
Buffers replace vectors, a new sight.
Events and tasks, now streamlined,
With patterns and types, all aligned.
A rabbit's joy, in each byte,
Celebrating changes, day and night.
🌟


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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@giangndm giangndm marked this pull request as draft May 15, 2024 17:20
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

clippy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 76.46552% with 273 lines in your changes missing coverage. Please review.

Project coverage is 83.59%. Comparing base (be6191b) to head (db36709).

Files Patch % Lines
packages/network/src/data_plane.rs 67.36% 47 Missing ⚠️
bin/src/main.rs 0.00% 36 Missing ⚠️
...work/src/controller_plane/neighbours/connection.rs 40.42% 28 Missing ⚠️
packages/network/src/data_plane/features.rs 69.01% 22 Missing ⚠️
packages/network/src/features/socket.rs 58.49% 22 Missing ⚠️
packages/network/src/controller_plane/features.rs 69.49% 18 Missing ⚠️
packages/network/src/controller_plane.rs 84.26% 14 Missing ⚠️
packages/network/src/features/vpn.rs 31.57% 13 Missing ⚠️
packages/network/src/services/visualization.rs 84.21% 9 Missing ⚠️
packages/network/src/features/neighbours.rs 46.66% 8 Missing ⚠️
... and 16 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
- Coverage   83.62%   83.59%   -0.04%     
==========================================
  Files          68       68              
  Lines        8972     9019      +47     
==========================================
+ Hits         7503     7539      +36     
- Misses       1469     1480      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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: 49

Out of diff range and nitpick comments (4)
packages/network/src/data_plane/connection.rs (1)

Line range hint 29-37: Avoid magic numbers in buffer size calculations.

- buf.ensure_back(12 + 16); //TODO remove magic numbers
+ const HEADER_SIZE: usize = 12;
+ const ENCRYPTION_OVERHEAD: usize = 16;
+ buf.ensure_back(HEADER_SIZE + ENCRYPTION_OVERHEAD);

Using named constants instead of magic numbers improves code readability and maintainability.

packages/network/src/services/visualization.rs (1)

Line range hint 74-85: Consider adding a comment to explain the purpose of the VisualizationService implementation block.

+ // Implementation block for VisualizationService
impl<UserData: Copy, SC, SE, TC, TW> VisualizationService<UserData, SC, SE, TC, TW>
where
    SC: From<Control> + TryInto<Control>,
    SE: From<Event> + TryInto<Event>,
{
    pub fn new() -> Self {
        Self {
            broadcast_seq: 0,
            last_ping: 0,
            conns: BTreeMap::new(),
            network_nodes: BTreeMap::new(),
            queue: VecDeque::from([ServiceOutput::FeatureControl(FeaturesControl::Data(data::Control::DataListen(DATA_PORT)))]),
            subscribers: Vec::new(),
            _tmp: std::marker::PhantomData,
        }
    }

    fn fire_event(&mut self, event: Event) {
        for sub in self.subscribers.iter() {
            self.queue.push_back(ServiceOutput::Event(*sub, event.clone().into()));
        }
    }
}
packages/network/src/data_plane.rs (1)

Line range hint 129-149: The on_input method doesn't need a mutable reference for self.switcher.

- self.features.input(&mut self.switcher).on_input(&mut self.feature_ctx, feature, now_ms, FeatureWorkerInput::Control(actor, control));
+ self.features.input(&self.switcher).on_input(&mut self.feature_ctx, feature, now_ms, FeatureWorkerInput::Control(actor, control));
packages/network/src/features/pubsub/controller/source_hint.rs (1)

28-28: Consider adding a brief comment explaining the purpose of the derivative crate for better code readability.

use derivative::Derivative; // Used for deriving default implementations with custom bounds
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between be6191b and 9200a16.
Files ignored due to path filters (4)
  • Cargo.toml is excluded by !**/*.toml
  • examples/whip-whep/Cargo.toml is excluded by !**/*.toml
  • packages/network/Cargo.toml is excluded by !**/*.toml
  • packages/runner/Cargo.toml is excluded by !**/*.toml
Files selected for processing (57)
  • bin/src/main.rs (4 hunks)
  • examples/quic-tunnel/src/sdn.rs (4 hunks)
  • examples/quic-tunnel/src/vnet/mod.rs (2 hunks)
  • examples/quic-tunnel/src/vnet/socket.rs (1 hunks)
  • examples/whip-whep/src/main.rs (4 hunks)
  • examples/whip-whep/src/sfu/cluster.rs (2 hunks)
  • examples/whip-whep/src/sfu/mod.rs (6 hunks)
  • examples/whip-whep/src/sfu/whep.rs (9 hunks)
  • examples/whip-whep/src/sfu/whip.rs (8 hunks)
  • examples/whip-whep/src/worker.rs (9 hunks)
  • packages/network/src/base/feature.rs (4 hunks)
  • packages/network/src/base/mod.rs (1 hunks)
  • packages/network/src/base/msg.rs (9 hunks)
  • packages/network/src/base/secure.rs (3 hunks)
  • packages/network/src/base/service.rs (4 hunks)
  • packages/network/src/controller_plane.rs (3 hunks)
  • packages/network/src/controller_plane/features.rs (1 hunks)
  • packages/network/src/controller_plane/neighbours.rs (3 hunks)
  • packages/network/src/controller_plane/neighbours/connection.rs (14 hunks)
  • packages/network/src/controller_plane/services.rs (1 hunks)
  • packages/network/src/data_plane.rs (5 hunks)
  • packages/network/src/data_plane/connection.rs (3 hunks)
  • packages/network/src/data_plane/features.rs (1 hunks)
  • packages/network/src/data_plane/services.rs (2 hunks)
  • packages/network/src/features/alias.rs (17 hunks)
  • packages/network/src/features/data.rs (4 hunks)
  • packages/network/src/features/dht_kv/client.rs (4 hunks)
  • packages/network/src/features/dht_kv/client/map.rs (15 hunks)
  • packages/network/src/features/dht_kv/internal.rs (4 hunks)
  • packages/network/src/features/dht_kv/mod.rs (4 hunks)
  • packages/network/src/features/mod.rs (3 hunks)
  • packages/network/src/features/neighbours.rs (4 hunks)
  • packages/network/src/features/pubsub/controller.rs (9 hunks)
  • packages/network/src/features/pubsub/controller/consumers.rs (12 hunks)
  • packages/network/src/features/pubsub/controller/feedbacks.rs (8 hunks)
  • packages/network/src/features/pubsub/controller/local_relay.rs (3 hunks)
  • packages/network/src/features/pubsub/controller/remote_relay.rs (18 hunks)
  • packages/network/src/features/pubsub/controller/source_hint.rs (25 hunks)
  • packages/network/src/features/pubsub/mod.rs (5 hunks)
  • packages/network/src/features/pubsub/msg.rs (3 hunks)
  • packages/network/src/features/pubsub/worker.rs (9 hunks)
  • packages/network/src/features/router_sync.rs (7 hunks)
  • packages/network/src/features/socket.rs (4 hunks)
  • packages/network/src/features/vpn.rs (2 hunks)
  • packages/network/src/lib.rs (4 hunks)
  • packages/network/src/secure/encryption/x25519_dalek_aes.rs (6 hunks)
  • packages/network/src/services/manual_discovery.rs (11 hunks)
  • packages/network/src/services/visualization.rs (14 hunks)
  • packages/network/src/worker.rs (5 hunks)
  • packages/network/tests/feature_alias.rs (9 hunks)
  • packages/network/tests/feature_dht_kv.rs (1 hunks)
  • packages/network/tests/feature_neighbours.rs (2 hunks)
  • packages/network/tests/feature_pubsub.rs (1 hunks)
  • packages/network/tests/feature_router_sync.rs (7 hunks)
  • packages/network/tests/feature_socket.rs (3 hunks)
  • packages/network/tests/service_manual_discovery.rs (2 hunks)
  • packages/network/tests/service_visualization.rs (4 hunks)
Files not processed due to max files limit (7)
  • packages/network/tests/simulator.rs
  • packages/runner/examples/simple_kv.rs
  • packages/runner/examples/simple_node.rs
  • packages/runner/src/builder.rs
  • packages/runner/src/lib.rs
  • packages/runner/src/worker_inner.rs
  • packages/runner/tests/feature_dht_kv.rs
Files not reviewed due to errors (5)
  • examples/quic-tunnel/src/vnet/mod.rs (no review received)
  • examples/quic-tunnel/src/sdn.rs (no review received)
  • packages/network/src/lib.rs (no review received)
  • packages/network/src/controller_plane/services.rs (no review received)
  • packages/network/src/data_plane/services.rs (no review received)
Files skipped from review due to trivial changes (1)
  • packages/network/src/base/mod.rs
Additional Context Used
GitHub Check Runs (2)
codecov/patch failure (30)

bin/src/main.rs: [warning] 238-238: bin/src/main.rs#L238
Added line #L238 was not covered by tests


bin/src/main.rs: [warning] 261-261: bin/src/main.rs#L261
Added line #L261 was not covered by tests


bin/src/main.rs: [warning] 289-289: bin/src/main.rs#L289
Added line #L289 was not covered by tests


bin/src/main.rs: [warning] 303-303: bin/src/main.rs#L303
Added line #L303 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 113-113: packages/network/src/controller_plane.rs#L113
Added line #L113 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 137-137: packages/network/src/controller_plane.rs#L137
Added line #L137 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 148-148: packages/network/src/controller_plane.rs#L148
Added line #L148 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 151-153: packages/network/src/controller_plane.rs#L151-L153
Added lines #L151 - L153 were not covered by tests


packages/network/src/controller_plane.rs: [warning] 163-164: packages/network/src/controller_plane.rs#L163-L164
Added lines #L163 - L164 were not covered by tests


packages/network/src/controller_plane.rs: [warning] 167-167: packages/network/src/controller_plane.rs#L167
Added line #L167 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 186-186: packages/network/src/controller_plane.rs#L186
Added line #L186 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 189-189: packages/network/src/controller_plane.rs#L189
Added line #L189 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 220-220: packages/network/src/controller_plane.rs#L220
Added line #L220 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 235-235: packages/network/src/controller_plane.rs#L235
Added line #L235 was not covered by tests


packages/network/src/controller_plane.rs: [warning] 237-237: packages/network/src/controller_plane.rs#L237
Added line #L237 was not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 62-66: packages/network/src/controller_plane/features.rs#L62-L66
Added lines #L62 - L66 were not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 68-69: packages/network/src/controller_plane/features.rs#L68-L69
Added lines #L68 - L69 were not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 74-75: packages/network/src/controller_plane/features.rs#L74-L75
Added lines #L74 - L75 were not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 83-83: packages/network/src/controller_plane/features.rs#L83
Added line #L83 was not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 85-85: packages/network/src/controller_plane/features.rs#L85
Added line #L85 was not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 87-87: packages/network/src/controller_plane/features.rs#L87
Added line #L87 was not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 89-89: packages/network/src/controller_plane/features.rs#L89
Added line #L89 was not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 93-95: packages/network/src/controller_plane/features.rs#L93-L95
Added lines #L93 - L95 were not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 97-97: packages/network/src/controller_plane/features.rs#L97
Added line #L97 was not covered by tests


packages/network/src/controller_plane/features.rs: [warning] 99-99: packages/network/src/controller_plane/features.rs#L99
Added line #L99 was not covered by tests


packages/network/src/controller_plane/neighbours/connection.rs: [warning] 129-135: packages/network/src/controller_plane/neighbours/connection.rs#L129-L135
Added lines #L129 - L135 were not covered by tests


packages/network/src/controller_plane/neighbours/connection.rs: [warning] 153-160: packages/network/src/controller_plane/neighbours/connection.rs#L153-L160
Added lines #L153 - L160 were not covered by tests


packages/network/src/controller_plane/neighbours/connection.rs: [warning] 194-200: packages/network/src/controller_plane/neighbours/connection.rs#L194-L200
Added lines #L194 - L200 were not covered by tests


packages/network/src/controller_plane/neighbours/connection.rs: [warning] 353-353: packages/network/src/controller_plane/neighbours/connection.rs#L353
Added line #L353 was not covered by tests


packages/network/src/controller_plane/services.rs: [warning] 61-61: packages/network/src/controller_plane/services.rs#L61
Added line #L61 was not covered by tests

clippy success (30)

packages/network/src/base/feature.rs: [warning] 129-129:
this lifetime isn't used in the impl


packages/network/src/base/feature.rs: [warning] 154-154:
the following explicit lifetimes could be elided: 'a


packages/network/src/base/feature.rs: [warning] 154-154:
the following explicit lifetimes could be elided: 'a


packages/network/src/base/feature.rs: [warning] 187-187:
this lifetime isn't used in the impl


packages/network/src/base/secure.rs: [warning] 49-49:
this lifetime isn't used in the function definition


packages/network/src/base/secure.rs: [warning] 68-68:
this lifetime isn't used in the function definition


packages/network/src/controller_plane.rs: [warning] 48-48:
very complex type used. Consider factoring parts into type definitions


packages/network/src/controller_plane.rs: [warning] 60-60:
very complex type used. Consider factoring parts into type definitions


packages/network/src/controller_plane/features.rs: [warning] 59-59:
the following explicit lifetimes could be elided: 'a


packages/network/src/controller_plane/features.rs: [warning] 59-59:
the following explicit lifetimes could be elided: 'a


packages/network/src/controller_plane/neighbours.rs: [warning] 126-126:
unused variable: now


packages/network/src/controller_plane/services.rs: [warning] 13-18:
very complex type used. Consider factoring parts into type definitions


packages/network/src/controller_plane/services.rs: [warning] 23-23:
very complex type used. Consider factoring parts into type definitions


packages/network/src/data_plane.rs: [warning] 77-77:
very complex type used. Consider factoring parts into type definitions


packages/network/src/data_plane.rs: [warning] 87-87:
very complex type used. Consider factoring parts into type definitions


packages/network/src/data_plane.rs: [warning] 125-125:
the method on_tick doesn't need a mutable reference


packages/network/src/data_plane.rs: [warning] 149-149:
the method on_input doesn't need a mutable reference


packages/network/src/data_plane.rs: [warning] 179-179:
the method on_input doesn't need a mutable reference


packages/network/src/data_plane.rs: [warning] 199-199:
useless conversion to the same type: sans_io_runtime::Buffer


packages/network/src/data_plane.rs: [warning] 276-276:
useless conversion to the same type: sans_io_runtime::Buffer


packages/network/src/data_plane.rs: [warning] 325-325:
the method on_input doesn't need a mutable reference


packages/network/src/data_plane.rs: [warning] 334-334:
useless conversion to the same type: sans_io_runtime::Buffer


packages/network/src/data_plane/features.rs: [warning] 59-59:
this function has too many arguments (8/7)


packages/network/src/data_plane/services.rs: [warning] 13-18:
very complex type used. Consider factoring parts into type definitions


packages/network/src/data_plane/services.rs: [warning] 24-24:
very complex type used. Consider factoring parts into type definitions


packages/network/src/features/alias.rs: [warning] 259-259:
the following explicit lifetimes could be elided: 'a


packages/network/src/features/alias.rs: [warning] 259-259:
the following explicit lifetimes could be elided: 'a


packages/network/src/features/data.rs: [warning] 88-88:
the following explicit lifetimes could be elided: 'a


packages/network/src/features/data.rs: [warning] 88-88:
the following explicit lifetimes could be elided: 'a


packages/network/src/features/dht_kv/mod.rs: [warning] 106-106:
the following explicit lifetimes could be elided: 'a

Additional comments not posted (236)
packages/network/tests/feature_neighbours.rs (2)

20-21: Ensure type parameters are correctly used in ExtIn::FeaturesControl.

The addition of type parameters to ExtIn::FeaturesControl aligns with the updated type requirements.


40-47: Ensure type parameters are correctly used in ExtOut::FeaturesEvent.

The addition of type parameters to ExtOut::FeaturesEvent aligns with the updated type requirements.

packages/network/src/data_plane/connection.rs (2)

5-5: Ensure the Buffer type is correctly imported and used.

The import and usage of Buffer in the struct definition are correct.


Line range hint 44-52: Ensure consistency in encryption and decryption logic.

The decryption logic is consistent with the encryption logic and correctly uses the Buffer type.

packages/network/tests/service_manual_discovery.rs (3)

33-33: Ensure type parameters are correctly used in ExtIn::FeaturesControl.

The addition of type parameters to ExtIn::FeaturesControl aligns with the updated type requirements.


45-48: Ensure type parameters are correctly used in ExtOut::FeaturesEvent.

The addition of type parameters to ExtOut::FeaturesEvent aligns with the updated type requirements.


52-55: Ensure type parameters are correctly used in ExtOut::FeaturesEvent.

The addition of type parameters to ExtOut::FeaturesEvent aligns with the updated type requirements.

packages/network/src/features/dht_kv/internal.rs (6)

14-15: Ensure the UserData type parameter is correctly used in InternalOutput.

The addition of the UserData type parameter in InternalOutput is correct and aligns with the updated type requirements.


19-21: Ensure the UserData type parameter is correctly used in DhtKvInternal.

The addition of the UserData type parameter in DhtKvInternal is correct and aligns with the updated type requirements.


Line range hint 35-37: Ensure the on_tick method correctly updates local and remote storage.

The on_tick method correctly updates the local and remote storage.


39-41: Ensure the on_local method correctly handles local commands with UserData.

The on_local method correctly handles local commands with the UserData type parameter.


Line range hint 43-51: Ensure the on_remote method correctly handles remote commands.

The on_remote method correctly handles remote commands and logs the actions.


Line range hint 53-61: Ensure the pop_action method correctly pops actions from local and remote storage.

The pop_action method correctly pops actions from local and remote storage and logs the actions.

packages/network/src/features/pubsub/mod.rs (3)

Line range hint 46-56: Ensure the UserData type parameter is correctly used in RelayWorkerControl.

The addition of the UserData type parameter in RelayWorkerControl is correct and aligns with the updated type requirements.


75-76: Ensure the UserData type parameter is correctly used in ToWorker.

The addition of the UserData type parameter in ToWorker is correct and aligns with the updated type requirements.


87-88: Ensure the UserData type parameter is correctly used in Output and WorkerOutput.

The addition of the UserData type parameter in Output and WorkerOutput is correct and aligns with the updated type requirements.

packages/network/src/features/pubsub/controller/local_relay.rs (2)

14-17: The LocalRelay struct definition looks good with the new UserData type parameter.


Line range hint 20-72: The GenericRelay trait implementation for LocalRelay has been correctly updated to handle the UserData type parameter. The logic within each method is consistent with their intended functionality.

packages/network/tests/feature_socket.rs (3)

22-23: Changes are consistent with the new type parameter requirements.

Also applies to: 26-26, 31-34


54-55: Changes are consistent with the new type parameter requirements.

Also applies to: 59-59, 64-67


91-92: Changes are consistent with the new type parameter requirements.

Also applies to: 96-96, 101-104

packages/network/src/features/mod.rs (2)

95-103: Changes are consistent with the new type parameter requirements.


106-106: Changes are consistent with the new type parameter requirements.

packages/network/src/features/pubsub/msg.rs (1)

129-136: The Into<Buffer> implementation is consistent with the new type parameter requirements and correctly converts PubsubMessage into Buffer.

examples/quic-tunnel/src/vnet/socket.rs (1)

56-56: The conversion of transmit.contents to Buffer is consistent with the new type parameter requirements.

packages/network/src/features/vpn.rs (6)

32-36: Changes are consistent with the new type parameter requirements.


51-55: Changes are consistent with the new type parameter requirements.


38-42: Changes are consistent with the new type parameter requirements.


44-46: Changes are consistent with the new type parameter requirements.


87-94: Changes are consistent with the new type parameter requirements.


98-103: Changes are consistent with the new type parameter requirements.

packages/network/src/base/service.rs (8)

12-14: Changes are consistent with the new type parameter requirements.


24-25: Changes are consistent with the new type parameter requirements.


31-32: Changes are consistent with the new type parameter requirements.


62-63: Changes are consistent with the new type parameter requirements.


68-73: Changes are consistent with the new type parameter requirements.


42-49: Changes are consistent with the new type parameter requirements.


80-86: Changes are consistent with the new type parameter requirements.


98-105: Changes are consistent with the new type parameter requirements.

examples/whip-whep/src/main.rs (5)

11-17: Update import paths to reflect module changes.


70-70: Service initialization updated to include an additional type parameter ().


73-73: IP address updated in addr_builder.add_protocol.


81-81: sfu address updated in ICfg.

Also applies to: 104-104


124-125: Consider re-enabling signal handling for graceful shutdown.

Is there a specific reason for commenting out the signal handling code? Re-enabling it can ensure graceful shutdown on receiving SIGINT.

Also applies to: 131-133

packages/network/src/features/dht_kv/client.rs (3)

24-25: Added UserData type parameter to LocalStorageOutput enum.


29-33: Updated LocalStorage struct to include UserData type parameter.


Line range hint 37-127: Updated LocalStorage implementation to handle UserData type parameter.

packages/network/tests/feature_router_sync.rs (5)

Line range hint 19-32: Updated MockService implementation to include UserData type parameter.


39-54: Updated MockServiceWorker implementation to handle UserData type parameter.


Line range hint 59-72: Updated MockServiceBuilder implementation to handle UserData type parameter.


89-107: Updated feature_router_sync_single_node test case to handle UserData type parameter.


116-128: Updated feature_router_sync_two_nodes and feature_router_sync_three_nodes test cases to handle UserData type parameter.

Also applies to: 151-153

examples/whip-whep/src/sfu/cluster.rs (2)

Line range hint 37-37: Added Default derive to ClusterLogic struct.


Line range hint 41-41: Updated ClusterLogic::on_input method to handle new input and output types.

packages/network/src/features/neighbours.rs (5)

32-39: Updated NeighboursFeature struct to include UserData type parameter.


Line range hint 42-86: Updated NeighboursFeature implementation to handle UserData type parameter.


95-99: Updated NeighboursFeatureWorker struct to include UserData type parameter.


101-114: Updated NeighboursFeatureWorker implementation to handle UserData type parameter.


88-121: Updated TaskSwitcherChild implementation for NeighboursFeature and NeighboursFeatureWorker to handle UserData type parameter.

packages/network/tests/service_visualization.rs (8)

13-16: The addition of the type parameter () in the node_changed function is consistent with the new type parameter requirements. The function logic remains unchanged and correct.


41-41: The inclusion of the type parameter () in the ExtIn::ServicesControl variant is consistent with the new type parameter requirements. The test logic remains unchanged and correct.


48-52: The inclusion of the type parameter () in the ExtOut::ServicesEvent variant is consistent with the new type parameter requirements. The test logic remains unchanged and correct.


81-82: The inclusion of the type parameter () in the ExtIn::ServicesControl variant is consistent with the new type parameter requirements. The test logic remains unchanged and correct.


89-98: The inclusion of the type parameter () in the ExtOut::ServicesEvent variant is consistent with the new type parameter requirements. The test logic remains unchanged and correct.


121-123: The inclusion of the type parameter () in the ExtOut::ServicesEvent variant within the get_key lambda function is consistent with the new type parameter requirements. The function logic remains unchanged and correct.


121-123: The sorting of node1_events and node2_events using the updated get_key lambda function is consistent with the new type parameter requirements. The sorting logic remains unchanged and correct.


121-123: The inclusion of the type parameter () in the node_changed function calls within the assert_eq! statements is consistent with the new type parameter requirements. The assertions remain unchanged and correct.

examples/whip-whep/src/sfu/whip.rs (6)

3-3: The import of Buffer from atm0s_sdn::sans_io_runtime is appropriate and aligns with the changes in the rest of the codebase where Buffer is used instead of Vec<u8>. This change improves type safety and consistency.


20-21: The WhipInput enum now uses Buffer instead of Vec<u8> for the UdpPacket variant. This change is consistent with the overall shift to using Buffer for data handling, enhancing type safety and performance.


26-26: The WhipOutput enum now uses Buffer instead of Vec<u8> for the UdpPacket variant. This change is consistent with the overall shift to using Buffer for data handling, enhancing type safety and performance.


39-39: The addition of the queue field to the WhipTask struct is a good design choice. It allows for better management of output events, improving the modularity and maintainability of the code.


81-81: The conversion of send.contents to Buffer using .to_vec().into() is correct and aligns with the new data handling approach. This ensures that the data is properly encapsulated in the Buffer type.


117-117: The Task trait implementation for WhipTask has been updated to use the Buffer type. This change is consistent with the overall shift to using Buffer for data handling, enhancing type safety and performance.

packages/network/tests/feature_dht_kv.rs (4)

13-14: The control function now returns ExtIn<(), ()>, reflecting the addition of type parameters to the ExtIn enum. This change is consistent with the updated type handling in the codebase.


17-18: The event function now returns ExtOut<(), ()>, reflecting the addition of type parameters to the ExtOut enum. This change is consistent with the updated type handling in the codebase.


Line range hint 93-94: The feature_dht_kv_single_node test now uses ExtIn::FeaturesControl((), FeaturesControl::DhtKv(control)) and ExtIn::FeaturesControl((), FeaturesControl::DhtKv(control)), reflecting the addition of type parameters to the ExtIn enum. This change is consistent with the updated type handling in the codebase.


Line range hint 115-115: The feature_alias_timeout test now uses ExtIn::FeaturesControl((), FeaturesControl::Alias(alias::Control::Query { alias: alias_v, service, level })), reflecting the addition of type parameters to the ExtIn enum. This change is consistent with the updated type handling in the codebase.

packages/network/src/features/dht_kv/mod.rs (6)

9-10: The addition of Debug to the imports is appropriate, given that the UserData type parameter now requires the Debug trait. This change ensures that the code can properly handle and log UserData instances.


81-83: The Output and WorkerOutput type aliases now include the UserData type parameter. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly propagated through the system.


84-85: The DhtKvFeature struct now includes the UserData type parameter. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly encapsulated within the feature.


88-88: The DhtKvFeature implementation now includes the UserData type parameter and requires UserData to implement Eq, Copy, and Debug. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly managed within the feature.


146-150: The DhtKvFeatureWorker struct now includes the UserData type parameter and uses DynamicDeque for the queue field. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly managed within the worker.


152-163: The FeatureWorker trait implementation for DhtKvFeatureWorker now includes the UserData type parameter. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly managed within the worker.

packages/network/tests/feature_alias.rs (4)

19-19: The MockService implementation now includes the UserData type parameter. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly managed within the service.


39-39: The MockServiceWorker implementation now includes the UserData type parameter. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly managed within the service worker.


59-59: The MockServiceBuilder implementation now includes the UserData type parameter. This change is consistent with the updated type handling in the codebase and ensures that UserData is properly managed within the service builder.


93-94: The feature_alias_single_node test now uses ExtIn::FeaturesControl((), FeaturesControl::Alias(alias::Control::Register { alias, service, level })) and ExtIn::FeaturesControl((), FeaturesControl::Alias(alias::Control::Query { alias, service, level })), reflecting the addition of type parameters to the ExtIn enum. This change is consistent with the updated type handling in the codebase.

examples/whip-whep/src/sfu/whep.rs (6)

3-5: Imports updated to include Buffer and DynamicDeque.


24-24: WhepInput enum updated to use Buffer for the UdpPacket variant.


29-29: WhepOutput enum updated to use Buffer for the UdpPacket variant.


42-42: WhepTask struct updated to include a queue field.


Line range hint 75-85: pop_event_inner method updated to use Buffer instead of Vec<u8> for the data field in the UdpPacket variant.


Line range hint 121-185: Methods on_tick, on_event, pop_output, and on_shutdown updated to use the queue field and Buffer type.

packages/network/src/features/pubsub/controller/feedbacks.rs (6)

1-2: No significant changes to imports.


8-9: FeedbackSource enum updated to include a UserData type parameter.


14-16: SingleFeedbackKind struct updated to include a UserData type parameter.


70-73: FeedbacksAggerator struct updated to include a UserData type parameter.


Line range hint 77-114: Methods in FeedbacksAggerator updated to use the UserData type parameter.


Line range hint 140-207: Tests updated to use the UserData type parameter.

packages/network/src/features/data.rs (6)

1-4: Imports look good and appropriate for the changes.

Also applies to: 8-9, 12-14


22-24: The new variants in Control and Event enums are correctly added and follow the existing pattern.

Also applies to: 30-30


43-43: The updates to the DataMsg enum and the new type aliases are appropriate and consistent.

Also applies to: 46-47


49-54: The updates to the DataFeature struct and its implementation are correctly implemented and follow the existing pattern.

Also applies to: 56-64, 67-137, 145-145


154-172: The updates to the DataFeatureWorker struct and its implementation are correctly implemented and follow the existing pattern.


147-149: The updates to the TaskSwitcherChild implementations are correctly implemented and follow the existing pattern.

Also applies to: 175-179

packages/network/src/controller_plane/neighbours.rs (3)

8-8: The import of TaskSwitcherChild is appropriate and consistent with the rest of the code.


122-122: The updates to the NeighboursManager struct and its methods are correctly implemented and follow the existing pattern.


124-126: The updates to the TaskSwitcherChild implementation are correctly implemented and follow the existing pattern.

packages/network/src/worker.rs (5)

1-1: The updates to the imports and enum definitions are appropriate and consistent with the rest of the code.

Also applies to: 4-4, 13-16, 19-23, 28-32, 37-42


44-48: The updates to the SdnWorkerCfg struct are appropriate and consistent with the rest of the code.


51-70: The updates to the SdnWorker struct and its implementation are correctly implemented and follow the existing pattern.

Also applies to: 88-130


Line range hint 157-186: The updates to the process_controller_out and process_data_out methods are correctly implemented and follow the existing pattern.


201-209: The updates to the TaskSwitcherChild implementation are correctly implemented and follow the existing pattern.

packages/network/src/base/feature.rs (6)

85-87: The addition of the UserData type parameter to the FeatureControlActor enum looks good and aligns with the overall update to include additional type parameters.


91-102: The into2 method for converting between different UserData types in the FeatureControlActor impl block looks good and aligns with the overall update to include additional type parameters.


111-115: The addition of the UserData type parameter to the FeatureInput enum looks good and aligns with the overall update to include additional type parameters.


119-138: The addition of the UserData type parameter to the FeatureOutput enum looks good and aligns with the overall update to include additional type parameters.


160-167: The addition of the UserData type parameter to the FeatureWorkerInput enum looks good and aligns with the overall update to include additional type parameters.


171-184: The addition of the UserData type parameter to the FeatureWorkerOutput enum looks good and aligns with the overall update to include additional type parameters.

packages/network/src/secure/encryption/x25519_dalek_aes.rs (3)

96-96: The update to use BufferMut for encryption in the EncryptorXDA implementation looks good and aligns with the overall update to use BufferMut for data handling.


134-134: The update to use BufferMut for decryption in the DecryptorXDA implementation looks good and aligns with the overall update to use BufferMut for data handling.


Line range hint 157-184: The addition of the BufferMut2 implementation to adapt BufferMut for use with the AES-GCM library looks good and is necessary for integrating BufferMut with the AES-GCM library.

bin/src/main.rs (4)

238-238: The update to use SdnBuilder::<(), SC, SE, TC, TW>::new(...) for initialization looks good and aligns with the overall update to include additional type parameters.


261-261: The update to use controller.send_to(0, SdnExtIn::ServicesControl(...)) looks good and aligns with the overall update to use additional parameters.


289-289: The update to the pattern matching for SdnExtOut::ServicesEvent to include additional parameters looks good and aligns with the overall update to include additional parameters.


303-303: The update to the pattern matching for SdnExtOut::FeaturesEvent to include additional parameters looks good and aligns with the overall update to include additional parameters.

packages/network/src/features/router_sync.rs (7)

30-36: Ensure consistent usage of the new UserData type parameter.

Verify that the UserData type parameter is used consistently across the entire codebase, especially in the FeatureOutput and FeatureWorkerOutput types.


Line range hint 40-50: LGTM! The new method correctly initializes the RouterSyncFeature struct.


Line range hint 52-58: LGTM! The send_sync_to method correctly serializes the sync message and pushes it to the queue.


Line range hint 62-123: LGTM! The on_shared_input and on_input methods correctly handle their respective inputs and update the router state.


160-164: Ensure consistent usage of the new UserData type parameter.

Verify that the UserData type parameter is used consistently across the entire codebase, especially in the FeatureWorkerOutput type.


166-183: LGTM! The on_input method correctly handles its inputs and updates the router state.


186-191: LGTM! The pop_output method correctly returns the next output from the queue.

packages/network/tests/feature_pubsub.rs (7)

13-18: LGTM! The feature_pubsub_manual_single_node test function correctly simulates the scenario and verifies the expected outcomes.


20-20: LGTM! The feature_pubsub_auto_single_node test function correctly simulates the scenario and verifies the expected outcomes.


Line range hint 22-22: LGTM! The feature_pubsub_auto_single_node_worker test function correctly simulates the scenario and verifies the expected outcomes.


Line range hint 24-24: LGTM! The feature_pubsub_manual_two_nodes test function correctly simulates the scenario and verifies the expected outcomes.


Line range hint 26-26: LGTM! The feature_pubsub_auto_two_nodes test function correctly simulates the scenario and verifies the expected outcomes.


Line range hint 28-28: LGTM! The feature_pubsub_manual_three_nodes test function correctly simulates the scenario and verifies the expected outcomes.


Line range hint 30-30: LGTM! The feature_pubsub_auto_three_nodes test function correctly simulates the scenario and verifies the expected outcomes.

examples/whip-whep/src/sfu/mod.rs (8)

7-7: Import statement for Buffer looks good.


38-42: Changes to the Input enum to use Buffer instead of Vec<u8> are appropriate.


49-49: Changes to the Output enum to use Buffer instead of Vec<u8> are appropriate.


63-63: Updates to the SfuWorker struct to use TaskGroup and WhepTaskGroup are appropriate.


170-183: The process_cluster_output method is well-implemented and handles various cluster outputs appropriately.


189-208: The process_whip_out method is well-implemented and integrates WHIP task outputs with the cluster logic effectively.


214-235: The process_whep_out method is well-implemented and integrates WHEP task outputs with the cluster logic effectively.


261-328: Updates to the on_tick, on_event, pop_output, and on_shutdown methods are consistent with the new task management approach and are correctly implemented.

packages/network/src/features/pubsub/controller/consumers.rs (6)

7-8: Import statement for FeatureControlActor with a type parameter looks good.


21-26: Changes to the RelayConsumers struct to include a type parameter for UserData are appropriate.


Line range hint 29-113: Updates to the RelayConsumers implementation to use the new type parameter are consistent and correctly implemented.


132-142: Updates to the relay_local_should_work_single_sub test to use the new type parameter are appropriate.


152-167: Updates to the relay_local_should_work_multi_subs test to use the new type parameter are appropriate.


Line range hint 184-209: Updates to the relay_remote_should_work_single_sub and relay_remote_should_work_multi_subs tests to use the new type parameter are appropriate.

examples/whip-whep/src/worker.rs (8)

3-6: Update import statements to reflect changes in module paths and type names.

Also applies to: 14-14


40-40: The ExtIn enum now includes Sdn(SdnExtIn<(), SC>).


46-46: The ExtOut enum now includes Sdn(SdnExtOut<(), SE>).


58-58: The Event enum now includes Sdn(SdnEvent<(), SC, SE, TC, TW>).


73-73: The SdnInnerCfg struct now includes a new type parameter () for ServiceBuilder.


101-107: The RunnerWorker struct now includes a queue field of type VecDeque<WorkerInnerOutput<RunnerOwner, ExtOut, ChannelId, Event, SCfg>>.


138-138: The RunnerWorker implementation includes changes to the build, on_tick, on_event, pop_output, and on_shutdown methods.

Also applies to: 163-163, 167-171, 174-224, 230-243, 252-256


Line range hint 261-303: The process_sdn and process_sfu methods now include new type parameters and modified event handling logic.

Also applies to: 307-315

packages/network/src/features/pubsub/worker.rs (7)

1-5: Update import statements to reflect changes in module paths and type names.


14-20: The WorkerRelay struct now includes a new type parameter UserData.


27-29: The PubSubFeatureWorker struct now includes a new type parameter UserData.


32-36: The Default implementation for PubSubFeatureWorker now includes a new type parameter UserData.


Line range hint 41-227: The FeatureWorker implementation for PubSubFeatureWorker now includes a new type parameter UserData and modifies the event handling logic.


237-239: The TaskSwitcherChild implementation for PubSubFeatureWorker now includes a new type parameter UserData and modifies the task processing logic.


239-239: The pop_output method now includes a new type parameter UserData and modifies the output processing logic.

packages/network/src/controller_plane.rs (5)

79-92: The initialization of ControllerPlane looks good.


95-105: The implementation of on_tick looks good.


172-189: The implementation of pop_neighbours looks good.


193-223: The implementation of pop_features looks good.


242-262: The implementation of TaskSwitcherChild for ControllerPlane looks good.

packages/network/src/features/socket.rs (7)

57-60: The implementation of send_to looks good.


Line range hint 73-183: The implementation of on_input looks good.


186-191: The implementation of pop_output looks good.


199-213: The implementation of process_incoming looks good.


227-283: The implementation of on_input looks good.


288-291: The implementation of TaskSwitcherChild for SocketFeatureWorker looks good.


295-310: The implementation of embed_meta and extract_meta looks good.

packages/network/src/features/pubsub/controller.rs (8)

28-28: Ensure the TaskSwitcherChild import is necessary.

The TaskSwitcherChild trait is imported but not used until the end of the file. Ensure that this import is necessary and correctly used in the implementation.


31-34: Review the GenericRelayOutput enum for correctness.

The GenericRelayOutput enum is well-defined with appropriate variants for ToWorker, RouteChanged, and Feedback. Ensure that these variants are correctly used in the file.


37-48: Review the GenericRelay trait for correctness.

The GenericRelay trait is well-defined with appropriate methods for handling relay operations. Ensure that these methods are correctly implemented in the file.


51-54: Review the PubSubFeature struct for correctness.

The PubSubFeature struct is well-defined with appropriate fields for relays, source hints, and a queue. Ensure that these fields are correctly used in the file.


Line range hint 57-88: Review the PubSubFeature implementation for correctness.

The PubSubFeature implementation is well-defined with appropriate methods for handling relay and source hint operations. Ensure that these methods are correctly implemented and tested in the file.


Line range hint 216-233: Review the pop_single_relay method for correctness.

The pop_single_relay method is well-defined with appropriate logic for handling relay outputs. Ensure that this method is correctly used in the file.


Line range hint 235-256: Review the pop_single_source_hint method for correctness.

The pop_single_source_hint method is well-defined with appropriate logic for handling source hint outputs. Ensure that this method is correctly used in the file.


Line range hint 258-322: Review the Feature and TaskSwitcherChild trait implementations for correctness.

The Feature and TaskSwitcherChild trait implementations for PubSubFeature are well-defined with appropriate methods for handling feature inputs and task switching. Ensure that these methods are correctly implemented and tested in the file.

packages/network/src/base/msg.rs (6)

286-286: Replacing Vec<u8> with Buffer in the TransportMsg struct improves type safety and performance. Good change!


309-314: The use of Buffer in the build_raw method aligns with the updated TransportMsg struct and ensures consistent use of Buffer. Looks good!


335-338: Updating the build method to use Buffer instead of Vec<u8> is consistent with the previous changes and improves type safety. Good job!


392-398: The change to use Buffer in the from_payload_bincode method ensures consistency with the updated TransportMsg struct. Looks good!


412-412: Converting Vec<u8> to Buffer in the TryFrom<Vec<u8>> implementation maintains consistency with the updated TransportMsg struct. Good change!


424-424: Converting &[u8] to Buffer in the TryFrom<&[u8]> implementation ensures consistency with the updated TransportMsg struct. Looks good!

packages/network/src/data_plane.rs (7)

1-15: Imports and initial declarations look good and are consistent with the overall updates in the codebase.


26-35: The updates to the NetInput and CrossWorker enums are consistent with the overall changes in the codebase.


39-52: The updates to the Input and NetOutput enums are consistent with the overall changes in the codebase.


56-67: The updates to the Output enum are consistent with the overall changes in the codebase.


68-77: The updates to the TaskType enum and DataPlaneCfg struct are consistent with the overall changes in the codebase.


81-90: The updates to the DataPlane struct are consistent with the overall changes in the codebase.


Line range hint 94-113: The updates to the DataPlane implementation are consistent with the overall changes in the codebase.

packages/network/src/features/alias.rs (12)

1-4: Imports look good and necessary for the new functionality.


8-12: The new imports and type definitions are appropriate and align with the changes in the code.


61-62: The addition of the UserData type parameter to QuerySlot is correctly integrated and enhances the flexibility of the struct.


74-75: The updates to Output and WorkerOutput type definitions to include the UserData type parameter are correctly integrated.


77-83: The addition of the UserData type parameter to AliasFeature is correctly integrated and enhances the flexibility of the struct.


Line range hint 87-210: The new logic for handling various control and remote messages in AliasFeature is well-implemented and efficient. The use of the UserData type parameter is correctly integrated.


210-212: The send_to method is correctly implemented and efficiently handles message serialization and queueing.


Line range hint 222-275: The Feature trait implementation for AliasFeature is correctly updated to include the UserData type parameter and handle various inputs efficiently.


277-288: The addition of the UserData type parameter to AliasFeatureWorker is correctly integrated and enhances the flexibility of the struct.


290-302: The new logic for handling various inputs in AliasFeatureWorker is well-implemented and efficient. The use of the UserData type parameter is correctly integrated.


305-310: The TaskSwitcherChild trait implementation for AliasFeatureWorker is correctly updated to include the UserData type parameter and handle output efficiently.


Line range hint 315-574: The tests are correctly updated to include the UserData type parameter and cover the new logic comprehensively.

packages/network/src/features/pubsub/controller/remote_relay.rs (10)

18-22: Introduce UserData type parameter to RelayState enum.

The addition of the UserData type parameter to the RelayState enum is correctly implemented and enhances the flexibility of the state management.


37-40: Introduce UserData type parameter to RemoteRelay struct.

The addition of the UserData type parameter to the RemoteRelay struct is correctly implemented and enhances the flexibility of the relay logic.


Line range hint 43-58: Introduce UserData type parameter to RemoteRelay implementation.

The addition of the UserData type parameter to the RemoteRelay implementation is correctly implemented and enhances the flexibility of the relay logic.


Line range hint 65-141: Introduce UserData type parameter to GenericRelay trait implementation for RemoteRelay.

The addition of the UserData type parameter to the GenericRelay trait implementation for RemoteRelay is correctly implemented and enhances the flexibility of the relay logic.


141-145: Introduce UserData type parameter to on_pub_start and on_pub_stop methods.

The addition of the UserData type parameter to the on_pub_start and on_pub_stop methods is correctly implemented and enhances the flexibility of the relay logic.


Line range hint 151-180: Introduce UserData type parameter to on_local_sub method.

The addition of the UserData type parameter to the on_local_sub method is correctly implemented and enhances the flexibility of the relay logic.


Line range hint 180-195: Introduce UserData type parameter to on_local_feedback method.

The addition of the UserData type parameter to the on_local_feedback method is correctly implemented and enhances the flexibility of the relay logic.


Line range hint 195-343: Introduce UserData type parameter to on_local_unsub method.

The addition of the UserData type parameter to the on_local_unsub method is correctly implemented and enhances the flexibility of the relay logic.


343-347: Introduce UserData type parameter to pop_output and relay_dests methods.

The addition of the UserData type parameter to the pop_output and relay_dests methods is correctly implemented and enhances the flexibility of the relay logic.


Line range hint 374-599: Introduce UserData type parameter to test functions.

The addition of the UserData type parameter to the test functions is correctly implemented and ensures that the tests cover the new functionality.

packages/network/src/features/dht_kv/client/map.rs (5)

1-4: The addition of Debug to the use statements is appropriate and necessary for the LocalMap implementation.


209-211: The addition of the UserData type parameter to the LocalMapOutput enum enhances flexibility and type safety.


223-228: The addition of the UserData type parameter to the LocalMap struct improves flexibility and type safety.


Line range hint 231-509: The changes to the LocalMap implementation are consistent with the addition of the UserData type parameter and enhance the overall functionality.


Line range hint 684-904: The updates to the test cases ensure that the new functionality is properly tested.

packages/network/src/features/pubsub/controller/source_hint.rs (7)

43-46: The Output enum now includes a UserData type parameter. Ensure that all usages of this enum are updated accordingly throughout the codebase.

Verification successful

All usages of the Output enum have been updated with the new UserData type parameter throughout the codebase.

  • Verified instances in multiple files such as worker.rs, controller_plane.rs, vpn.rs, features.rs, socket.rs, router_sync.rs, neighbours.rs, data.rs, alias.rs, pubsub.rs, dht_kv.rs, services.rs, data_plane.rs, and visualization.rs.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all usages of the `Output` enum are updated with the new `UserData` type parameter.

# Test: Search for the `Output` enum usage. Expect: Only occurrences with the new type parameter.
rg --type rust $'Output<'

Length of output: 24289


49-59: The SourceHintLogic struct now includes local_sources and local_subscribers fields with the UserData type parameter. Ensure that these fields are correctly initialized and used throughout the code.

Verification successful

The local_sources and local_subscribers fields in the SourceHintLogic struct are correctly initialized and used throughout the code.

  • The SourceHintLogic struct is used with the UserData type parameter in multiple places.
  • The local_sources and local_subscribers fields are actively managed and manipulated in various methods within the SourceHintLogic implementation.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all usages of the `SourceHintLogic` struct are updated with the new `UserData` type parameter.

# Test: Search for the `SourceHintLogic` struct usage. Expect: Only occurrences with the new type parameter.
rg --type rust $'SourceHintLogic<'

Length of output: 577



Script:

#!/bin/bash
# Description: Verify initialization and usage of `local_sources` and `local_subscribers` fields in `SourceHintLogic`.

# Search for the initialization of `SourceHintLogic`.
rg --type rust 'SourceHintLogic<' --context 10

# Search for methods that interact with `local_sources` and `local_subscribers`.
rg --type rust 'local_sources'
rg --type rust 'local_subscribers'

Length of output: 13929


62-62: The SourceHintLogic implementation block now requires UserData to implement Eq, Copy, and Debug. Ensure that all UserData types used in this context satisfy these trait bounds.

Verification successful

All instances of UserData used in the context of SourceHintLogic and related structures consistently implement the required traits Eq, Copy, and Debug.

  • UserData is used in various contexts across multiple files, and in all instances, it implements the necessary traits.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all `UserData` types used in `SourceHintLogic` satisfy the required trait bounds.

# Test: Search for the `SourceHintLogic` struct instantiation. Expect: Only occurrences with `UserData` types implementing `Eq`, `Copy`, and `Debug`.
rg --type rust $'SourceHintLogic<'

Length of output: 577



Script:

#!/bin/bash
# Description: Verify the definition of `UserData` in the relevant files to ensure it implements `Eq`, `Copy`, and `Debug`.

# Test: Search for the definition or type alias of `UserData` in `controller.rs` and `source_hint.rs`.
rg --type rust 'type UserData' packages/network/src/features/pubsub/controller.rs packages/network/src/features/pubsub/controller/source_hint.rs
rg --type rust 'struct UserData' packages/network/src/features/pubsub/controller.rs packages/network/src/features/pubsub/controller/source_hint.rs
rg --type rust 'enum UserData' packages/network/src/features/pubsub/controller.rs packages/network/src/features/pubsub/controller/source_hint.rs

Length of output: 442



Script:

#!/bin/bash
# Description: Verify the definition of `UserData` in the entire repository to ensure it implements `Eq`, `Copy`, and `Debug`.

# Test: Search for the definition or type alias of `UserData` across the entire repository.
rg --type rust 'type UserData'
rg --type rust 'struct UserData'
rg --type rust 'enum UserData'

Length of output: 100



Script:

#!/bin/bash
# Description: Trace the origin of `UserData` by searching for its usage and imports in the relevant files.

# Test: Search for `UserData` usage and imports in `controller.rs` and `source_hint.rs`.
rg --type rust 'UserData' packages/network/src/features/pubsub/controller.rs packages/network/src/features/pubsub/controller/source_hint.rs

Length of output: 5105



Script:

#!/bin/bash
# Description: Trace the origin of `UserData` by searching for import statements in the relevant files.

# Test: Search for import statements in `controller.rs` and `source_hint.rs`.
rg --type rust 'use ' packages/network/src/features/pubsub/controller.rs packages/network/src/features/pubsub/controller/source_hint.rs

Length of output: 2851



Script:

#!/bin/bash
# Description: Trace the origin and context of `UserData` by searching for its usage in the entire repository.

# Test: Search for `UserData` usage in the entire repository.
rg --type rust 'UserData'

Length of output: 65866


351-351: The pop_output method now returns Output<UserData>. Ensure that all usages of this method handle the UserData type correctly.


375-375: The test case local_subscribe_should_send_event now uses FeatureControlActor<UserData>. Ensure that all test cases are updated to handle the UserData type correctly.


450-450: The test case remote_subscribe_should_send_event now uses FeatureControlActor<UserData>. Ensure that all test cases are updated to handle the UserData type correctly.

#!/bin/bash
# Description: Verify all test cases are updated to handle the `UserData` type correctly.

# Test: Search for the `FeatureControlActor` usage in test cases. Expect: Only occurrences with the correct `UserData` type.
rg --type rust --test $'FeatureControlActor<'

822-838: The test case reject_loop_register now uses FeatureControlActor<UserData>. Ensure that all test cases are updated to handle the UserData type correctly.

#!/bin/bash
# Description: Verify all test cases are updated to handle the `UserData` type correctly.

# Test: Search for the `FeatureControlActor` usage in test cases. Expect: Only occurrences with the correct `UserData` type.
rg --type rust --test $'FeatureControlActor<'

@@ -64,7 +64,7 @@
#[derive(Debug, PartialEq)]
pub enum Output {
Event(ConnectionEvent),
Net(SocketAddr, NeighboursControlCmds),
Net(u64, SocketAddr, NeighboursControlCmds),
Copy link

Choose a reason for hiding this comment

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

Add test coverage for the new Output::Net variant.

The new Output::Net variant should be covered by tests to ensure it works as expected. Would you like assistance in writing these tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes please

@@ -91,7 +91,7 @@
node,
remote,
state,
output: VecDeque::from([Output::Net(remote, NeighboursControlCmds::ConnectRequest { to: node, session, handshake })]),
output: VecDeque::from([Output::Net(now_ms, remote, NeighboursControlCmds::ConnectRequest { to: node, session, handshake })]),
Copy link

Choose a reason for hiding this comment

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

Add test coverage for the new_outgoing method's initialization logic.

The new_outgoing method's initialization logic should be covered by tests to ensure it correctly initializes the output field with a ConnectRequest command. Would you like assistance in writing these tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes please

Comment on lines +129 to +135
self.output.push_back(self.generate_control(
now_ms,
NeighboursControlCmds::DisconnectRequest {
session: self.conn.session(),
reason: NeighboursDisconnectReason::Other,
},
));
Copy link

Choose a reason for hiding this comment

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

Add test coverage for the disconnect method.

The disconnect method should be covered by tests to ensure it correctly pushes a DisconnectRequest command to the output queue. Would you like assistance in writing these tests?

Comment on lines +153 to +160
self.output.push_back(self.generate_control(
now_ms,
NeighboursControlCmds::ConnectRequest {
to: self.node,
session: self.conn.session(),
handshake: request_buf,
},
));
Copy link

Choose a reason for hiding this comment

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

Add test coverage for the on_tick method's ConnectRequest resending logic.

The on_tick method's logic for resending ConnectRequest commands should be covered by tests to ensure it works as expected. Would you like assistance in writing these tests?

Comment on lines +194 to +200
self.output.push_back(self.generate_control(
now_ms,
NeighboursControlCmds::DisconnectRequest {
session: self.conn.session(),
reason: NeighboursDisconnectReason::Other,
},
));
Copy link

Choose a reason for hiding this comment

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

Add test coverage for the on_tick method's DisconnectRequest resending logic.

The on_tick method's logic for resending DisconnectRequest commands should be covered by tests to ensure it works as expected. Would you like assistance in writing these tests?

@@ -20,10 +20,12 @@

use std::{
collections::{BTreeMap, VecDeque},
fmt::Debug,
Copy link

Choose a reason for hiding this comment

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

Consider removing the redundant import of fmt::Debug since it is already included in the impl block.

-    fmt::Debug,

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
fmt::Debug,

@@ -119,7 +122,7 @@
}
}

pub fn on_local(&mut self, _now_ms: u64, actor: FeatureControlActor, cmd: LocalCmd) {
pub fn on_local(&mut self, _now_ms: u64, actor: FeatureControlActor<UserData>, cmd: LocalCmd) {
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Several files in the codebase still use the old function signature.

The on_local method calls in various files, such as source_hint.rs, controller.rs, and others, use FeatureControlActor::Controller(()) and FeatureControlActor::Worker(1, ()). These instances need to be reviewed to ensure they pass the correct UserData type.

  • packages/network/src/features/pubsub/controller/source_hint.rs
  • packages/network/src/features/pubsub/controller.rs
  • packages/network/src/features/dht_kv/mod.rs
  • packages/network/src/features/dht_kv/internal.rs
  • packages/network/src/features/alias.rs
  • packages/network/src/features/pubsub/controller/remote_relay.rs
  • packages/network/src/features/pubsub/controller/feedbacks.rs
  • packages/network/src/features/pubsub/controller/consumers.rs
  • packages/network/src/features/dht_kv/client/map.rs

Please review these instances to ensure they are updated to use the correct UserData type.

Analysis chain

The on_local method now handles FeatureControlActor<UserData> correctly. Ensure that all calls to this method pass the correct UserData type.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all calls to the `on_local` method pass the correct `UserData` type.

# Test: Search for the `on_local` method calls. Expect: Only occurrences with the correct `UserData` type.
rg --type rust $'.on_local('

Length of output: 100



Script:

#!/bin/bash
# Description: Verify all calls to the `on_local` method pass the correct `UserData` type.

# Test: Search for the `on_local` method calls. Expect: Only occurrences with the correct `UserData` type.
rg --type rust '\.on_local\('

Length of output: 3635



Script:

#!/bin/bash
# Description: Verify the `FeatureControlActor` type definitions to ensure they align with the expected `UserData` type.

# Test: Search for the `FeatureControlActor` type definition.
rg --type rust 'enum FeatureControlActor'

Length of output: 121



Script:

#!/bin/bash
# Description: Verify the `UserData` type used in `FeatureControlActor` instances.

# Test: Search for the `UserData` type definition.
rg --type rust 'type UserData'

Length of output: 32



Script:

#!/bin/bash
# Description: Verify the `FeatureControlActor` enum definition to understand the usage of `UserData`.

# Test: Search for the `FeatureControlActor` enum definition.
rg --type rust 'pub enum FeatureControlActor'

Length of output: 125



Script:

#!/bin/bash
# Description: Verify the instantiations of `FeatureControlActor` to check the `UserData` types.

# Test: Search for instantiations of `FeatureControlActor`.
rg --type rust 'FeatureControlActor::'

Length of output: 17335

Comment on lines +214 to +218
// We dont accept register from local source, this ocurs when subscribe and next-hop reply with all sources include it self
if source == self.node_id {
return;
}

Copy link

Choose a reason for hiding this comment

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

Typographical error: "ocurs" should be "occurs".

-                // We dont accept register from local source, this ocurs when subscribe and next-hop reply with all sources include it self
+                // We don't accept register from local source, this occurs when subscribe and next-hop reply with all sources include itself

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// We dont accept register from local source, this ocurs when subscribe and next-hop reply with all sources include it self
if source == self.node_id {
return;
}
// We don't accept register from local source, this occurs when subscribe and next-hop reply with all sources include itself
if source == self.node_id {
return;
}

Comment on lines +250 to +254
// We dont accept unregister from local source, this ocurs when subscribe and next-hop reply with all sources include it self
if source == self.node_id {
return;
}

Copy link

Choose a reason for hiding this comment

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

Typographical error: "ocurs" should be "occurs".

-                // We dont accept unregister from local source, this ocurs when subscribe and next-hop reply with all sources include it self
+                // We don't accept unregister from local source, this occurs when subscribe and next-hop reply with all sources include itself

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// We dont accept unregister from local source, this ocurs when subscribe and next-hop reply with all sources include it self
if source == self.node_id {
return;
}
// We don't accept unregister from local source, this occurs when subscribe and next-hop reply with all sources include itself
if source == self.node_id {
return;
}

Comment on lines +334 to +335
// We dont accept register from local source, this ocurs when subscribe and next-hop reply with all sources include it self
if source != self.node_id && self.remote_sources.insert(source, now_ms).is_none() {
Copy link

Choose a reason for hiding this comment

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

Typographical error: "ocurs" should be "occurs".

-                    // We dont accept register from local source, this ocurs when subscribe and next-hop reply with all sources include it self
+                    // We don't accept register from local source, this occurs when subscribe and next-hop reply with all sources include itself

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// We dont accept register from local source, this ocurs when subscribe and next-hop reply with all sources include it self
if source != self.node_id && self.remote_sources.insert(source, now_ms).is_none() {
// We don't accept register from local source, this occurs when subscribe and next-hop reply with all sources include itself
if source != self.node_id && self.remote_sources.insert(source, now_ms).is_none() {

@giangndm giangndm marked this pull request as ready for review July 18, 2024 17:59
@giangndm giangndm merged commit 05954a4 into 8xFF:master Jul 18, 2024
3 of 6 checks passed
@github-actions github-actions bot mentioned this pull request Jul 18, 2024
dhilipsiva added a commit to dhilipsiva/atm0s-sdn that referenced this pull request Jul 19, 2024
* master:
  chore: disable publish of bin sub-project (8xFF#170)
  chore: update version (8xFF#168)
  refactor: update for media server (8xFF#165)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant