|
| 1 | +#ifndef OBJECT_TABLE_H |
| 2 | +#define OBJECT_TABLE_H |
| 3 | + |
1 | 4 | #include "common.h" |
| 5 | +#include "table.h" |
2 | 6 | #include "db.h" |
3 | 7 |
|
4 | | -/* The callback that is called when the result of a lookup |
5 | | - * in the object table comes back. The callback should free |
6 | | - * the manager_vector array, but NOT the strings they are pointing to. */ |
7 | | -typedef void (*lookup_callback)(object_id object_id, |
8 | | - int manager_count, |
9 | | - const char *manager_vector[], |
10 | | - void *context); |
| 8 | +/* |
| 9 | + * ==== Lookup call and callback ==== |
| 10 | + */ |
11 | 11 |
|
12 | | -/* Register a new object with the directory. */ |
13 | | -/* TODO(pcm): Retry, print for each attempt. */ |
14 | | -void object_table_add(db_handle *db, object_id object_id); |
| 12 | +/* Callback called when the lookup completes. The callback should free |
| 13 | + * the manager_vector array, but NOT the strings they are pointing to. |
| 14 | + */ |
| 15 | +typedef void (*object_table_lookup_done_callback)( |
| 16 | + object_id object_id, |
| 17 | + int manager_count, |
| 18 | + OWNER const char *manager_vector[], |
| 19 | + void *user_context); |
15 | 20 |
|
16 | | -/* Remove object from the directory. */ |
17 | | -void object_table_remove(db_handle *db, |
| 21 | +/** |
| 22 | + * Return the list of nodes storing object_id in their plasma stores. |
| 23 | + * |
| 24 | + * @param db_handle Handle to object_table database. |
| 25 | + * @param object_id ID of the object being looked up. |
| 26 | + * @param retry Information about retrying the request to the database. |
| 27 | + * @param done_callback Function to be called when database returns result. |
| 28 | + * @param user_context Context passed by the caller. |
| 29 | + * @return Void. |
| 30 | + */ |
| 31 | +void object_table_lookup(db_handle *db_handle, |
18 | 32 | object_id object_id, |
19 | | - const char *manager); |
| 33 | + retry_info *retry, |
| 34 | + object_table_lookup_done_callback done_callback, |
| 35 | + void *user_context); |
| 36 | + |
| 37 | +/* |
| 38 | + * ==== Add object call and callback ==== |
| 39 | + */ |
| 40 | + |
| 41 | +/* Callback called when the object add/remove operation completes. */ |
| 42 | +typedef void (*object_table_done_callback)(object_id object_id, |
| 43 | + void *user_context); |
20 | 44 |
|
21 | | -/* Look up entry from the directory */ |
22 | | -void object_table_lookup(db_handle *db, |
| 45 | +/** |
| 46 | + * Add the plasma manager that created the db_handle to the |
| 47 | + * list of plasma managers that have the object_id. |
| 48 | + * |
| 49 | + * @param db_handle Handle to db. |
| 50 | + * @param object_id Object unique identifier. |
| 51 | + * @param retry Information about retrying the request to the database. |
| 52 | + * @param done_callback Callback to be called when lookup completes. |
| 53 | + * @param user_context User context to be passed in the callbacks. |
| 54 | + * @return Void. |
| 55 | + */ |
| 56 | +void object_table_add(db_handle *db_handle, |
| 57 | + object_id object_id, |
| 58 | + retry_info *retry, |
| 59 | + object_table_done_callback done_callback, |
| 60 | + void *user_context); |
| 61 | + |
| 62 | +/* |
| 63 | + * ==== Remove object call and callback ==== |
| 64 | + */ |
| 65 | + |
| 66 | +/** |
| 67 | + * Object remove function. |
| 68 | + * |
| 69 | + * @param db_handle Handle to db. |
| 70 | + * @param object_id Object unique identifier. |
| 71 | + * @param retry Information about retrying the request to the database. |
| 72 | + * @param done_callback Callback to be called when lookup completes. |
| 73 | + * @param user_context User context to be passed in the callbacks. |
| 74 | + * @return Void. |
| 75 | + */ |
| 76 | +/* |
| 77 | +void object_table_remove(db_handle *db, |
23 | 78 | object_id object_id, |
24 | 79 | lookup_callback callback, |
25 | 80 | void *context); |
| 81 | + retry_info *retry, |
| 82 | + object_table_done_callback done_callback, |
| 83 | + void *user_context); |
| 84 | +*/ |
| 85 | + |
| 86 | +/* |
| 87 | + * ==== Subscribe to be announced when new object available ==== |
| 88 | + */ |
| 89 | + |
| 90 | +/* Callback called when object object_id is available. */ |
| 91 | +typedef void (*object_table_object_available_callback)(object_id object_id, |
| 92 | + void *user_context); |
| 93 | + |
| 94 | +/** |
| 95 | + * Subcribing to new object available function. |
| 96 | + * |
| 97 | + * @param db_handle Handle to db. |
| 98 | + * @param object_id Object unique identifier. |
| 99 | + * @param object_available_callback callback to be called when new object |
| 100 | + * becomes |
| 101 | + * available. |
| 102 | + * @param subscribe_context caller context which will be passed back in the |
| 103 | + * object_available_callback. |
| 104 | + * @param retry Information about retrying the request to the database. |
| 105 | + * @param done_callback Callback to be called when subscription is installed. |
| 106 | + * @param user_context User context to be passed in the callbacks. |
| 107 | + * @return Void. |
| 108 | + */ |
| 109 | + |
| 110 | +void object_table_subscribe( |
| 111 | + db_handle *db, |
| 112 | + object_id object_id, |
| 113 | + object_table_object_available_callback object_available_callback, |
| 114 | + void *subscribe_context, |
| 115 | + retry_info *retry, |
| 116 | + object_table_done_callback done_callback, |
| 117 | + void *user_context); |
| 118 | + |
| 119 | +/* Data that is needed to register new object available callbacks with the state |
| 120 | + * database. */ |
| 121 | +typedef struct { |
| 122 | + object_table_object_available_callback object_available_callback; |
| 123 | + void *subscribe_context; |
| 124 | +} object_table_subscribe_data; |
| 125 | + |
| 126 | +#endif /* OBJECT_TABLE_H */ |
0 commit comments