[discussion/feature request] adding match guards to `group_names/1`
flaviogrossi opened this issue · comments
Hi, this is mainly a discussion before trying to implement a new feature.
In my current use case, a number of process groups is created, using a name like {:group_x, :subgroup_y}
, (for example the names are {:group_1, :subgroup_1}
, {:group_1, :subgroup_2}
, {:group_2, :subgroup_1}
, ...)
Then, for example, i need to retrieve all existing subgroups for a given group, with something like :syn.group_names(scope) |> Enum.filter(fn {group_name, _} -> group_name == :group_1 end)
.
Since this is becoming quite inefficient, due to the filter call, i was wondering if it was desired to add a new api, group_names_match/2
which mimics the match function in the elixir registry.
The implementation would simply be something like adding a new parameter to group_name_ordset
which is then used here as a guard on the ets select, and then expose a new function group_names_match
which will be called like group_names_match(scope, [{:==, :"$1", {:group_1, :_}}])
.
What do you think? I can work on a pull request if this seems interesting.
Or should i simply use a different scope for every group_x
(which is fixed) in my use case?