88 * SPDX-License-Identifier: LGPL-3.0
99\************************************************************/
1010
11- /* publisher.c - event publishing service on rank 0 */
11+ /* publisher.c - event publishing service on rank 0
12+ *
13+ * There are two methods for publishing an event:
14+ *
15+ * 1) Call one of the following API functions:
16+ * flux_event_publish(3)
17+ * flux_event_publish_pack(3)
18+ * flux_event_publish_raw(3)
19+ * These send an RPC to rank 0 (handled below). The RPC response contains
20+ * the published event's sequence number. The event message payload, if any,
21+ * must be base64-encoded to be included in the RPC payload.
22+ *
23+ * 2) Call one of the following functions
24+ * flux_event_encode(3)
25+ * flux_event_pack(3)
26+ * flux_event_encode_raw(3)
27+ * then
28+ * flux_send(3)
29+ * flux_send_new(3)
30+ * This puts the RFC 3 event message right on the wire without base64 encoding.
31+ * However, it is "fire and forget" from the sender's perspective.
32+ */
1233
1334#if HAVE_CONFIG_H
1435#include "config.h"
@@ -83,7 +104,10 @@ static flux_msg_t *encode_event (const char *topic,
83104 return NULL ;
84105}
85106
86- /* Broadcast event using all senders.
107+ /* Call the callback registered with publisher_create() to publish 'msg',
108+ * an RFC 3 event message. The broker registers its handle_event() function
109+ * here, which sends the message to downstream overlay peers, local modules,
110+ * and in-broker subscribers.
87111 * Log failure, but don't abort the event at this point.
88112 */
89113static void send_event (struct publisher * pub , const flux_msg_t * msg )
@@ -92,6 +116,8 @@ static void send_event (struct publisher *pub, const flux_msg_t *msg)
92116 flux_log_error (pub -> ctx -> h , "error publishing event message" );
93117}
94118
119+ /* Publish a message from a "publish request" (method 1 above).
120+ */
95121static void publish_cb (flux_t * h ,
96122 flux_msg_handler_t * mh ,
97123 const flux_msg_t * msg ,
@@ -138,6 +164,15 @@ static void publish_cb (flux_t *h,
138164 flux_msg_destroy (event );
139165}
140166
167+ /* Publish a raw RFC 3 event message (method 2 above).
168+ * This is a bit confusing: this function is called from broker.c, then
169+ * it calls a callback registered from broker.c. In short:
170+ *
171+ * broker_event_sendmsg_new() => publisher_send() =>
172+ * send_event() => handle_event()
173+ *
174+ * The goal was to assign event sequence numbers in one place only.
175+ */
141176int publisher_send (struct publisher * pub , const flux_msg_t * msg )
142177{
143178 flux_msg_t * cpy ;
0 commit comments