Skip to content

Commit

Permalink
setname api
Browse files Browse the repository at this point in the history
  • Loading branch information
attdona committed Jul 26, 2024
1 parent 3c4a9ca commit 8080d41
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.7.0 (26 July, 2024)

- New api setname(process, new_name) for changing process id

## 0.7.0 (9 July, 2024)

- MacOS support [#7](https://github.com/cardo-org/Visor.jl/pull/7)
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Visor"
uuid = "cf786855-3531-4b86-ba6e-3e33dce7dcdb"
authors = ["Attilio Donà"]
version = "0.7.0"
version = "0.7.1"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
23 changes: 23 additions & 0 deletions src/Visor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export procs
export receive
export reply
export setphase
export setname
export shutdown
export startup
export supervise
Expand Down Expand Up @@ -207,6 +208,28 @@ clear_hold(::Supervisor) = nothing
hold(process::Process) = process.onhold = true
hold(::Supervisor) = nothing

"""
setname(process::Process, new_name::AbstractString)
Change the process name
"""
function setname(process::Process, new_name::AbstractString)
sv = process.supervisor
if sv !== nothing
# maintain the order
child = OrderedDict{String,Supervised}()
for pname in keys(sv.processes)
if pname != process.id
child[pname] = sv.processes[pname]
else
child[new_name] = process
end
end
process.supervisor.processes = child
end
return process.id = new_name
end

Base.show(io::IO, process::Supervised) = print(io, process.id)

function dump(node::Supervisor)
Expand Down

2 comments on commit 8080d41

@attdona
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/111837

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.1 -m "<description of version>" 8080d41eec371a5017149f24b7afeb3c82e2a803
git push origin v0.7.1

Please sign in to comment.