Skip to content

Conversation

@markg-github
Copy link
Contributor

@markg-github markg-github commented Nov 3, 2025

This PR has been updated twice. Description of current version:

Add 16-bit random suffix to Avahi service name to avoid collisions.
Add rand crate as a dependency of dispatch in a way that doesn't add new deps.

Resolves: #4

@markg-github markg-github force-pushed the multi-dispatch-fix-pr branch from 1567d5a to 9e4efee Compare November 6, 2025 22:12
@markg-github
Copy link
Contributor Author

markg-github commented Nov 6, 2025

Outdated

Note that, even with this patch, if you use the same dispatch command line that you've been using, you may still encounter the issue. The idea is to use one of the new command line options, --avahi-random or --avahi-suffix.

@markg-github
Copy link
Contributor Author

markg-github commented Nov 7, 2025

Outdated

This PR adds and uses the rand crate but does not include changes to Cargo.lock. What's our convention for picking the version that goes into Cargo.lock?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables multiple dispatch instances to run simultaneously by preventing Avahi service name collisions. The implementation adds a random hexadecimal suffix to service names, though the PR description mentions command-line options (--avahi-random and --avahi-suffix) that are not present in the code changes.

Key Changes:

  • Automatic generation of random 4-digit hex suffix for Avahi service names
  • Addition of rand crate dependency to support random suffix generation

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/avahi.rs Implements random suffix generation and appends it to service names during registration
Cargo.toml Adds rand crate as a dependency with minimal features enabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add 16-bit random suffix to Avahi service name.
Add rand crate as a dependency of dispatch in a way that doesn't add new deps.

Resolves: AMDEPYC#4
Comment on lines +75 to +76
let random_suffix: u16 = rand::random();
let service_name = format!("{name}-{random_suffix:04x}");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let random_suffix: u16 = rand::random();
let service_name = format!("{name}-{random_suffix:04x}");
let service_name = format!("{name}-{:04x}", rand::random::<u16>());

http-body-util = { version = "0.1", default-features = false }
serde_json = { version = "1.0", default-features = false }
anyhow = { version = "1.0", default-features = false }
rand = { version = "0.9", default-features = false, features = ["std", "std_rng", "thread_rng"] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are all those features really required? I suspect maybe "thread_rng" is the only required feature.

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.

Inconsistent behavior when multiple dispatch running in the same network

2 participants