Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
libflux: add flux_event_encode_raw(), flux_event_decode_raw() #1486
This PR fills in some gaps noted in #1474, adding:
Functions for encoding/decoding events with raw payloads:
/* Encode an event message with optional raw payload. */ flux_msg_t *flux_event_encode_raw (const char *topic, const void *data, int len); /* Decode an event message, with optional raw payload. * If topic is non-NULL, assign the event topic string. * Data and len must be non-NULL and will be assigned the payload and length. * If there is no payload, they will be assigned NULL and zero. * Returns 0 on success, or -1 on failure with errno set. */ int flux_event_decode_raw (const flux_msg_t *msg, const char **topic, const void **data, int *len);
Functions for encoding and sending events in one go:
/* Send an event message with no confirmation of acceptance by broker. * Flags may include FLUX_MSGFLAG_PRIVATE to restrict access to instance owner. * If json_str is non-NULL, it is copied to the message payload. * Returns 0 on success, or -1 on failure with errno set. */ int flux_publish (flux_t *h, int flags, const char *topic, const char *json_str); /* Same as flux_publish() except payload is encoded using jansson pack * style variable arguments. */ int flux_publish_pack (flux_t *h, int flags, const char *topic, const char *fmt, ...); /* Same as flux_publish() except payload is raw. */ int flux_publish_raw (flux_t *h, int flags, const char *topic, const void *data, int len);
Man pages and unit tests are updated accordingly.
Some users are converted.
It does not address the need for API function(s) for the
I still need to add some tests for publishing raw events.
@@ Coverage Diff @@ ## master #1486 +/- ## ========================================== + Coverage 78.69% 78.76% +0.06% ========================================== Files 164 164 Lines 30405 30468 +63 ========================================== + Hits 23928 23998 +70 + Misses 6477 6470 -7
I added some cleanup to the
Note that the bindings may need some work to support raw event payloads (or raw payloads for other message types for that matter). I did note that lua
In that particular instance, it seems like a lua binding for a new
I'm not sure what kind of support raw payloads could get from higher level bindings in general. Any service that encodes messages or events with raw payloads would probably need to be specifically wrapped for the bindings in order to have a hope of accessing the payload.
In the case of
That being said the bindings do need to all be regenerated anyway, so at that time we could revisit the need for interfaces to the raw msg types.