Skip to content

Commit 83e4130

Browse files
committed
Registry fast path for stop_process/start_process.
1 parent 77170b4 commit 83e4130

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
### Fixed
88

9+
# 0.1.34
10+
11+
### Changed
12+
- Registry `stop_process`/`start_process` now has a fast path to check if a local registry has/doesn't have the process.
13+
914
# 0.1.33
1015

1116
### Added

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ tracing = { version = "0.1", default-features = false, features = ["std"] }
3333
tracing-subscriber = "0.3"
3434
dashmap = "6.0.1"
3535

36-
hydra-macros = { version = "0.1.33", path = "./hydra-macros" }
37-
hydra = { version = "0.1.33", path = "./hydra", default-features = false }
36+
hydra-macros = { version = "0.1.34", path = "./hydra-macros" }
37+
hydra = { version = "0.1.34", path = "./hydra", default-features = false }
3838

3939
[profile.release]
4040
lto = "fat"

hydra-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hydra-macros"
3-
version = "0.1.33"
3+
version = "0.1.34"
44
edition = "2021"
55
license.workspace = true
66
repository.workspace = true

hydra-websockets/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hydra-websockets"
3-
version = "0.1.33"
3+
version = "0.1.34"
44
edition = "2021"
55
readme = "./README.md"
66
license.workspace = true

hydra/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hydra"
3-
version = "0.1.33"
3+
version = "0.1.34"
44
edition = "2021"
55
readme.workspace = true
66
license.workspace = true

hydra/src/registry.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,16 @@ impl Registry {
197197
) -> Result<Pid, RegistryError> {
198198
use RegistryMessage::*;
199199

200-
match Registry::call(registry, Start(key.into()), None).await? {
200+
let registry = registry.into();
201+
let key = key.into();
202+
203+
if let Dest::Named(registry, Node::Local) = &registry {
204+
if let Some(pid) = lookup_process(registry, &key) {
205+
return Err(RegistryError::AlreadyStarted(pid));
206+
}
207+
}
208+
209+
match Registry::call(registry, Start(key), None).await? {
201210
StartSuccess(pid) => Ok(pid),
202211
StartError(error) => Err(error),
203212
_ => unreachable!(),
@@ -215,7 +224,16 @@ impl Registry {
215224
) -> Result<(), RegistryError> {
216225
use RegistryMessage::*;
217226

218-
match Registry::call(registry, Stop(key.into()), None).await? {
227+
let registry = registry.into();
228+
let key = key.into();
229+
230+
if let Dest::Named(registry, Node::Local) = &registry {
231+
if lookup_process(registry, &key).is_none() {
232+
return Err(RegistryError::NotFound);
233+
}
234+
}
235+
236+
match Registry::call(registry, Stop(key), None).await? {
219237
StopSuccess => Ok(()),
220238
StopError(error) => Err(error),
221239
_ => unreachable!(),

0 commit comments

Comments
 (0)