Is "nodelist" (corosync.conf) represented better as an object instead of a list? #132
-
I had a discussion with @pirat013 about the representation of
The nodes are represented as a list of objects. Fetching a specific node would mean iterate over the list until you have found the correct Example: |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Thanks @scmschmidt for the details written down. |
Beta Was this translation helpful? Give feedback.
-
Hi @scmschmidt, thanks for the feedback! Would you kindly provide a working implementation using what we have at the moment and a concurrent potential implementation using a dictionary-shaped return value? Keep in mind anyway that gatherer return values are anemic in logic by design, because it's easier to embed some additional logic in a check in a second moment than tying gatherer results to specific implementations. |
Beta Was this translation helpful? Give feedback.
-
@scmschmidt thanks for the feedback. At this moment we prefer not to alter the corosync configuration structure by adding custom parsing only for certain fields. The By using the rhai expression language, it is very easy to get an element by a property (in this case nodeid), which is basically the same as getting a value by knowing the key. For instance: nodelist[nodelist.index_of(|x| x.nodeid == 1)]
Yes it's possible. We are thinking to add a Not sure about converting this to a dict though. |
Beta Was this translation helpful? Give feedback.
-
@scmschmidt @pirat013 we've added nodelist[nodelist.index_of(|x| x.nodeid == 1)] becomes nodelist.find(|x| x.nodeid == 1) |
Beta Was this translation helpful? Give feedback.
@scmschmidt @pirat013 we've added
Array.find
to the expectation language. See here: https://rhai.rs/book/language/arrays.html?highlight=array#built-in-functionsbecomes