laforge has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/41102?usp=email )
Change subject: enb_registry: fetch_enb_list/0: return sorted list ......................................................................
enb_registry: fetch_enb_list/0: return sorted list
Change-Id: I51cc55982dda5f88e967b63433fb7e5be292aca1 --- M src/enb_registry.erl 1 file changed, 9 insertions(+), 4 deletions(-)
Approvals: pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/enb_registry.erl b/src/enb_registry.erl index f2be559..0217836 100644 --- a/src/enb_registry.erl +++ b/src/enb_registry.erl @@ -215,15 +215,15 @@ handle_call(fetch_enb_list, _From, #state{enbs = ENBs} = S) -> - Reply = maps:values(ENBs), - {reply, Reply, S}; + EnbList = lists:sort(fun enb_list_sort/2, maps:values(ENBs)), + {reply, EnbList, S};
handle_call({fetch_enb_list, Filter}, _From, #state{enbs = ENBs} = S) -> Filtered = maps:filter(enb_filter(Filter), ENBs), - Reply = maps:values(Filtered), - {reply, Reply, S}; + EnbList = lists:sort(fun enb_list_sort/2, maps:values(Filtered)), + {reply, EnbList, S};
handle_call(Info, From, S) -> ?LOG_ERROR("unknown ~p() from ~p: ~p", [?FUNCTION_NAME, From, Info]), @@ -315,6 +315,11 @@ EnbInfo.
+-spec enb_list_sort(enb_info(), enb_info()) -> boolean(). +enb_list_sort(#{handle := H0}, + #{handle := H1}) -> H0 =< H1. + + -spec enb_filter(enb_filter()) -> fun((enb_handle(), enb_info()) -> boolean()). enb_filter({genb_id_str, GlobalENBId}) -> fun(_, Item) -> enb_filter_by_field({genb_id_str, GlobalENBId}, Item) end;