cetcd
cetcd copied to clipboard
can we handle the value contain `\0`?
We try to write key-value pair but the value is binary, contain \0
. It can not store all value into etcd.
cetcd use redis's sds to handle string. It is supported to write binary. Do you have more details?
all the function parameter is char*
, like cetcd_set(cetcd_client *cli, const char *key, const char *value, uint64_t ttl)
, if we write binary, it will make \0 as end character.
value_escaped = curl_easy_escape(cli->curl, value, strlen(value));
strlen will end with \0
@YuleiXiao In fact, you can pass a cetcd_string as the parameter. It is actually a sds type.
Passing a cetcd_string to cetcd_set() will not solve the problem, since strlen is a libc string function and not a sds function. You have to adjust all string functions in cetcd to only use sds functions and nothing else. This would be a binary incompatible change breaking all existing applications.
@thkukuk Yeah, you are right. I will think about how to support binary safe string
Further more, you can't expect a JSON interface to support binary directly. Just take base64.