CPG_I..._NEXT(3)

πŸ’– CPG_I..._NEXT(3) πŸ’–

okay bestie, so this is a page from the Corosync Cluster Engine Programmer's Manual and honestly? it's giving "tiny function, big personality." let's get into it πŸ¦‹


✨ NAME ✨

cpg_iteration_next β€” return next item in iteration of CPG πŸ‘‘


🌸 SYNOPSIS 🌸

#include <corosync/cpg.h>

cs_error_t cpg_iteration_next (cpg_iteration_handle_t handle, struct
       cpg_iteration_description_t *description);

like, two args, one struct, no cap πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so the cpg_iter_next function is literally there to grab the next value in the iteration. it's the "and then??" of the whole operation.

the handle argument is the iterator handle you got from the cpg_iteration_initalize(3) function β€” yes that's the actual spelling, we don't fix it, we respect it 🫢

and description is a pointer to a structure with this exact definition:

struct cpg_iteration_description_t {
    struct cpg_name group;
    uint32_t nodeid;
    uint32_t pid;
};

where:

  • group is the name of the group 🌈
  • nodeid is the ID of the connected node
  • pid is the pid of the connected process
and listen β€” if the iteration was initialized with the CPG_ITERATION_NAME_ONLY iteration type, then both nodeid and pid are 0. that's just how it is, no drama πŸ’€

⭐ RETURN VALUE ⭐

this call returns the CS_OK value if it's successful β€” slay ✨

but if there are no more items to iterate, the CS_NO_SECTION error code comes back. so like, that's the "we're done here, nothing left to see" signal πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

and here's the little error-code roster that comes along with all of this, so you know exactly what vibe each failure is giving:

  • 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

and that's the whole page, bestie β€” go iterate something iconic πŸ§šπŸ’œ

this little love letter to iterators came out of the corosync Man Page, dated 05/03/2012, and it lives under CPG_I..._NEXT(3). bye bye, drink water πŸ“

πŸ“¦ where this page comes from