CPG_I...ALIZE(3)

πŸ’– CPG_ITERATION_INITIALIZE β€” the Corosync Cluster Engine Programmer's Manual, bestie edition πŸŽ€

okay so you're here for cpg_iteration_initialize(3), and honestly? iconic of you. this is the Corosync Cluster Engine Programmer's Manual page and we're gonna get through it together, no cap. ✨


🌸 NAME 🌸

cpg_iteration_initialize β€” Initialize iterator for members of CPG


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <corosync/cpg.h>

cs_error_t cpg_iteration_initialize (cpg_handle_t handle,
cpg_iteration_type_t iteration_type, const struct cpg_name *group,
cpg_iteration_handle_t *cpg_iteration_handle);

πŸ’… DESCRIPTION πŸ’…

so the cpg_iteration_initialize function is literally the thing that sets up your iteration over CPG members. like, it's the "get ready to scroll through the list" moment. 🫢

the handle argument is your connection to the CPG database β€” you get it by calling cpg_initialize(3). yes, that's the vibe, you need it first.

iteration_type is what limits how many items get returned, and it can be one of these three besties:

  • CPG_ITERATION_NAME_ONLY β€” only the name of used groups are returned
  • CPG_ITERATION_ONE_GROUP β€” only members group with name group are returned
  • CPG_ITERATION_ALL β€” all members are returned

the group parameter? it's used only with CPG_ITERATION_ONE_GROUP, and it's the name of the group whose members you want to iterate. for any other iteration_type, this parameter must be NULL. no exceptions, bestie, it's giving strict. πŸ’€

cpg_iteration_initialize is used only for initialize context for future cpg_iteration_next(3) calls, and the handle that function needs is returned in the cpg_iteration_handle variable. so like, it's the pre-game, not the party itself.

when you have finished iteration over objects, call cpg_iteration_finalize(3) to free up the memory associated with the iteration. clean up after yourself, queen. πŸ‘‘


✨ RETURN VALUE ✨

this call returns the CS_OK value if successful. slay.

if cpg_iteration_handle is NULL, CS_ERR_INVALID_PARAM error is returned. same error is returned when iteration_type is CPG_ITERATION_ONE_GROUP but group is NULL, or when group is not NULL and iteration_type is not CPG_ITERATION_ONE_GROUP. yes, it's checking both directions, it's thorough like that. πŸ™ˆ

if there is not enough memory for internal store of data, CS_ERR_NO_MEMORY is returned.

CS_ERR_BAD_HANDLE can be returned if handle is not a valid handle.


πŸ”₯ COMMON IPC ERRORS πŸ”₯

  • CS_ERR_TRY_AGAIN β€” Resource temporarily unavailable
  • CS_ERR_INVALID_PARAM β€” Invalid argument
  • CS_ERR_ACCESS β€” Permission denied
  • CS_ERR_LIBRARY β€” The connection failed
  • CS_ERR_INTERRUPT β€” System call interrupted by a signal
  • CS_ERR_NOT_SUPPORTED β€” The requested protocol/functionality not supported
  • CS_ERR_MESSAGE_ERROR β€” Incorrect auth message received
  • CS_ERR_NO_MEMORY β€” Not enough memory to complete the requested task

🌈 SEE ALSO 🌈

cpg_iteration_next(3), cpg_iteration_finalize(3), cpg_initialize(3), cpg_overview(3)


and that's the whole page, bestie!! πŸ’œ this was the corosync Man Page, dated 05/03/2012, and if you got this far you're genuinely built different. go forth and iterate responsibly. mwah. πŸ’–βœ¨

πŸ“¦ where this page comes from