CPG_JOIN(3)

๐Ÿ’– CPG_JOIN(3) ๐Ÿ’–

okay bestie, welcome to cpg_join from the Corosync Cluster Engine Programmer's Manual ๐ŸŒธ this is the part of the CPG library where you literally slide into a group's DMs and become a member. it's giving โœจnetworkingโœจ, it's giving โœจbelongingโœจ.


โœจ NAME โœจ

cpg_join โ€” joins one or more groups in the CPG library ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <corosync/cpg.h>

int cpg_join(cpg_handle_t handle, struct cpg_name *group);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so like, the cpg_join function is the one you call to join one group. periodt. ๐Ÿซถ

when a group is joined, cpg_mcast_joined(3) gets called internally to multicast to the groups that were joined in the argument handle. no cap. and your process will also get notifications of other processes joining and leaving the group โ€” the group chat is live, you're in it, you see everyone coming and going ๐Ÿ‘€

messages sent to any of the groups joined to the parameter handle will be delivered by cpg_dispatch(3). yes queen, that's your delivery service ๐Ÿšš

โš ๏ธ okay this one matters: this function may only be called once for each handle. one shot, one opportunity, one handle, one join. not me stressing about it ๐Ÿ˜ญ

once a group has been joined, the process will start receiving callbacks relating to messages sent from members of the group, plus notifications of processes joining or leaving the group. your phone is now on, notifications enabled, do not disturb OFF ๐Ÿ’€

also โ€” and this is lowkey iconic โ€” more than one process on each node can join a CPG group, and each one will receive its own copy of any messages sent using cpg_mcast_joined(), and its own confchg callback. everybody gets their own lil treat ๐Ÿ“ no sharing, no fighting, fr fr.

the argument group is used to specify the group to join. it's how you tell the library which group chat you're sliding into ๐Ÿ’Œ

the group argument is of the type struct cpg_name, which is defined by the structure:

struct cpg_name {
        int length;
        char value[128];
};

look at her. length and a value array of 128 chars. simple. elegant. main character energy ๐Ÿ‘‘


๐ŸŒˆ RETURN VALUE ๐ŸŒˆ

this call returns the CS_OK value if it was successful ๐ŸŽ‰ and returns CS_ERR_INVALID_PARAM if the handle is already joined to a group โ€” like bestie you're already in this group chat, why are you knocking again ๐Ÿ™ˆ


๐Ÿ’€ ERRORS ๐Ÿ’€

ngl, not all errors are documented. the devs said "iykyk" and moved on. but here's what we DO know:

  • 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 ๐Ÿ‘‘

go read these next, bestie, they're all part of the same lil universe โœจ


and that's the whole page, you ate that ๐Ÿ’… this was the corosync Man Page from 2004-08-31, filed under CPG_JOIN(3) โ€” mwah, go join a group, you got this ๐ŸŽ€๐Ÿ’–

๐Ÿ“ฆ where this page comes from