2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/gnunet-service-fs_drq.h
23 * @brief queueing of requests to the datastore service
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_FS_DRQ_H
27 #define GNUNET_SERVICE_FS_DRQ_H
29 #include "gnunet_datastore_service.h"
30 #include "gnunet_util_lib.h"
34 * Handle for pending, abortable requests for the datastore.
36 struct DatastoreRequestQueue;
40 * Iterate over the results for a particular key
41 * in the datastore. The iterator will only be called
42 * once initially; if the first call did contain a
43 * result, further results can be obtained by calling
44 * "GNUNET_DATASTORE_get_next" with the given argument.
46 * @param key maybe NULL (to match all entries)
47 * @param type desired type, 0 for any
48 * @param iter function to call on each matching value;
49 * will be called once with a NULL value at the end
50 * @param iter_cls closure for iter
51 * @param timeout how long to wait at most for a response
52 * @param immediate should this be queued immediately at
53 * the head of the queue (irrespecitive of the timeout)?
55 struct DatastoreRequestQueue *
56 GNUNET_FS_drq_get (const GNUNET_HashCode * key,
58 GNUNET_DATASTORE_Iterator iter,
60 struct GNUNET_TIME_Relative timeout,
66 GNUNET_FS_drq_get_cancel (struct DatastoreRequestQueue *drq);
70 * Function called to trigger obtaining the next result
71 * from the datastore. Must be called (directly or indirectly)
72 * from the 'iter' callback given to 'GNUNET_FS_drq_get'.
73 * Not calling 'get_next' means no other datastore
74 * interactions (other than remove) will happen.
76 * @param more GNUNET_YES to get more results, GNUNET_NO to abort
77 * iteration (with a final call to "iter" with key/data == NULL).
80 GNUNET_FS_drq_get_next (int more);
84 * Explicitly remove some content from the database.
85 * The "cont"inuation will be called with status
86 * "GNUNET_OK" if content was removed, "GNUNET_NO"
87 * if no matching entry was found and "GNUNET_SYSERR"
88 * on all other types of errors.
90 * @param key key for the value
91 * @param size number of bytes in data
92 * @param data content stored
93 * @param cont continuation to call when done
94 * @param cont_cls closure for cont
95 * @param timeout how long to wait at most for a response
98 GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
99 uint32_t size, const void *data,
100 GNUNET_DATASTORE_ContinuationWithStatus cont,
102 struct GNUNET_TIME_Relative timeout);
107 * Explicitly remove some content from the database.
108 * The "cont"inuation will be called with status
109 * "GNUNET_OK" if content was removed, "GNUNET_NO"
110 * if no matching entry was found and "GNUNET_SYSERR"
111 * on all other types of errors.
113 * @param key key for the value
114 * @param size number of bytes in data
115 * @param data content stored
116 * @param cont continuation to call when done
117 * @param cont_cls closure for cont
118 * @param timeout how long to wait at most for a response
121 GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
122 uint32_t size, const void *data,
123 GNUNET_DATASTORE_ContinuationWithStatus cont,
125 struct GNUNET_TIME_Relative timeout);
127 * Setup datastore request queues.
129 * @param s scheduler to use
130 * @param c configuration to use
131 * @return GNUNET_OK on success
134 GNUNET_FS_drq_init (struct GNUNET_SCHEDULER_Handle *s,
135 const struct GNUNET_CONFIGURATION_Handle *c);
139 /* end of gnunet-service-fs_drq.h */