-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: overhaul KVS interfaces #76
Comments
This is not a fully formed idea but it seems useful for
Could we just use a
|
Watch could just be a variant of The RPC calls would need to be modified to support multiple responses (and multiple gets) as described in #271 |
In order for
|
Hm, the It does seem to me like you are on to something here though. It would be really nice to be able to extend the generic Oh and your proposal to have simple rpcs |
Yeah sorry, the naming above is definitely poor. For the moment I'm kind of stumped on finding good names though - it seems like if we are wrapping the |
Is this a slight improvement or still "meh..."? flux_rpc_t *kvs_request (flux_t h, const char *key);
int kvs_get_json (flux_rpc_t *rpc, const char **json_str);
int kvs_get_int (flux_rpc_t *rpc, int *val);
etc A synchronous get would look like: flux_rpc_t *rpc;
const char *json_str;
if (!(rpc = kvs_request (h, "foo.bar.baz"))
err_exit ("kvs_request");
if (kvs_get_json (rpc, &json_str) < 0)
err_exit ("kvs_get_json");
flux_rpc_destroy (rpc); /* invalidates json_str */ I do like the fact that the rpc "owns" the storage associated with the response. In the current KVS api, some returned values have to be freed, others not. That aspect at least would be an improvement. And of course this makes async programming possible should you want to issue the get and do other things before the result arrives. |
I agree that the rpc object ownership of storage is a great improvement. I think this is a really nice development. What you have above is a huge usability improvement, if you want my opinion. If you call error ("kvs_get_json() called on rpc object of type %s\n", flux_rpc_type (rpc)) I dunno, maybe that isn't particularly useful, but I like this idea of lightweight extensible type system for rpc objects.... |
OK, thanks for the encouragement. I'll think a bit more along these lines then. Good idea giving |
Revisiting the API rework, building on futures and jansson style varargs interfaces. Consider this a straw man proposal for put and get interfaces, feedback welcome. put for single key (commit implied): flux_future_t *flux_kvs_put (flux_t *h, const char *key, const char *json_str);
flux_future_t *flux_kvs_putf (flux_t *h, const char *key, const char *fmt, ...);
// finish with flux_future_get (f, NULL) or if commit sequence number needed:
int flux_kvs_get_seq (flux_future_t *f, int *seq); put for one or more keys (atomic transaction, with fence capability): flux_future_t *flux_kvs_txopen (flux_t *h);
int flux_kvs_txput (flux_future_t *f, const char *key, const char *json_str);
int flux_kvs_txputf (flux_future_t *f, const char *key, const char *fmt, ...);
int flux_kvs_txcommit (flux_future_t *f, int flags);
int flux_kvs_txfence (flux_future_t *f, const char *name, int nprocs);
// finish with flux_future_get (f, NULL) or if commit sequence number needed
// use flux_kvs_get_seq() above get: flux_future_t *flux_kvs_lookup (flux_t *h, const char *key, int flags);
int flux_kvs_get (flux_future_t *f, const char *key, const char **json_str);
int flux_kvs_getf (flux_future_t *f, const char *key, const char *fmt, ...); For the get I was thinking of flags that would allow a recursive get in one RPC and then accessors to retrieve individual key/values from the result. Would need interfaces to walk the returned key space also, but I didn't get that far. |
For the atomic transactions, I wonder if this is a case where a new type would work better than overloading the future_t. It is a bit strange to be calling put, commit, and fence on a future, which is a container for a deferred result. If you had the txopen return a flux_kvs_txn_t, then you could put, commit, and fence on this object, and finally close it. Under the covers it would presumably be built on flux_future_t? |
That might be a good idea. It would mean |
I like @grondo's use of "txn" rather than "tx", and I think that would be good to use in the function names as well. I would like to see an underscore between "txn" in the function name and the following term (e.g. flux_kvs_txn_commit()). I am not sure that I understand the semantics of doing a fence on an atomic transaction though. Could you elaborate on what you have in mind there? Also, I assume that other forms of put, such as "_put_int", "_put_double" will also exist? In that case, shouldn't "flux_kvs_put" be named "flux_kvs_put_json"? |
Regarding
The fence essentially combines
No I think flux_kvs_txn_putf (txn, "foo", "i", 42);
// or
flux_kvs_putf (h, "foo", "i", 42); |
Is there anything else left from this discussion to complete? Or can this issue be closed? |
I think we can close it. |
etc: install config file for signing
The primary KVS interfaces should operate on valid JSON strings, not json-c specific json_object types, like the redesigned message functions.
The text was updated successfully, but these errors were encountered: