Skip to content

refactor(queue): unify Queue::new() to return Result - #208

Merged
Centaurus99 merged 6 commits into
stack-rs:mainfrom
CepheusC:interface
Jul 20, 2026
Merged

refactor(queue): unify Queue::new() to return Result#208
Centaurus99 merged 6 commits into
stack-rs:mainfrom
CepheusC:interface

Conversation

@CepheusC

@CepheusC CepheusC commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

This pr makes two changes to the bandwidth queue system:

  1. Unify Queue::new() signature — Change all queue implementations (InfiniteQueue, DropTailQueue, DropHeadQueue, CoDelQueue) to return Result<Self, Error> instead of a direct instance.
  2. Update all interfaces related to Queue::new().

@BobAnkh
BobAnkh requested a review from Centaurus99 July 19, 2026 05:07
@BobAnkh

BobAnkh commented Jul 19, 2026

Copy link
Copy Markdown
Member

@CepheusC Do not include pie and red in this PR.

@CepheusC CepheusC changed the title refactor(queue): unify Queue::new() to return Result and register RED/PIE in config enums refactor(queue): unify Queue::new() to return Result Jul 19, 2026

@Centaurus99 Centaurus99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. Move new into PacketQueue trait since impl_bw_cell_into_factory! macros already assume a fixed new(config) -> Result<Self, _> signature per queue.
  2. Replace the per-type From<XxxQueueConfig> impls with a single impl TryFrom on PacketQueue trait.
  3. @BobAnkh Is .expect() in impl Default for XxxQueue (e.g. droptail.rs:71) fine to keep, given all four queues actually never fail here?

@Centaurus99 Centaurus99 reopened this Jul 20, 2026
@BobAnkh

BobAnkh commented Jul 20, 2026

Copy link
Copy Markdown
Member
  1. Move new into PacketQueue trait since impl_bw_cell_into_factory! macros already assume a fixed new(config) -> Result<Self, _> signature per queue.
  2. Replace the per-type From<XxxQueueConfig> impls with a single impl TryFrom on PacketQueue trait.
  3. @BobAnkh Is .expect() in impl Default for XxxQueue (e.g. droptail.rs:71) fine to keep, given all four queues actually never fail here?

Yes, it is fine to keep except for never-fail condition.

@Centaurus99 Centaurus99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@Centaurus99
Centaurus99 merged commit b0e3a3f into stack-rs:main Jul 20, 2026
13 checks passed
@BobAnkh BobAnkh mentioned this pull request Jul 16, 2026
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.

3 participants