GError * gridd_client_exec_and_concat_string (const gchar *to, gdouble seconds, GByteArray *req, gchar **out) { GByteArray *tmp = NULL; GError *err = gridd_client_exec_and_concat (to, seconds, req, out ? &tmp : NULL); if (err) { if (tmp) g_byte_array_unref (tmp); return err; } if (out) { g_byte_array_append (tmp, (guint8*)"", 1); *out = (gchar*) g_byte_array_free (tmp, FALSE); } return NULL; }
GError * conscience_remote_get_namespace (const char *cs, namespace_info_t **out) { MESSAGE req = metautils_message_create_named(NAME_MSGNAME_CS_GET_NSINFO); GByteArray *gba = NULL; GError *err = gridd_client_exec_and_concat (cs, CS_CLIENT_TIMEOUT, message_marshall_gba_and_clean(req), &gba); if (err) { g_assert (gba == NULL); g_prefix_error(&err, "request: "); return err; } *out = namespace_info_unmarshall(gba->data, gba->len, &err); g_byte_array_unref (gba); if (*out) return NULL; GSETERROR(&err, "Decoding error"); return err; }
namespace_info_t * gcluster_get_namespace_info_full(addr_info_t * addr, long timeout, GError ** error) { EXTRA_ASSERT (addr != NULL); gchar str[STRLEN_ADDRINFO]; addr_info_to_string(addr, str, sizeof(str)); GByteArray *out = NULL; GError *err = gridd_client_exec_and_concat (str, ((gdouble)timeout)/1000.0, message_marshall_gba_and_clean(metautils_message_create_named( NAME_MSGNAME_CS_GET_NSINFO)), &out); if (err) { g_prefix_error(&err, "request: "); g_error_transmit(error, err); return NULL; } namespace_info_t *ns_info = namespace_info_unmarshall(out->data, out->len, error); if (!ns_info) GSETERROR(error, "Decoding error"); return ns_info; }