Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_function_journal.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * afw_function_execute_* functions for journal
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 
18 /*
19  * Adaptive function: journal_advance_cursor_for_consumer
20  *
21  * afw_function_execute_journal_advance_cursor_for_consumer
22  *
23  * See afw_function_bindings.h for more information.
24  *
25  * Update the advance cursor for a consumer referenced by the consumerId
26  * parameter. The limit parameter specifies the maximum number of entries to
27  * scan for an applicable entry for consumer before returning. NULL is always
28  * returned.
29  *
30  * There are no response properties set by this function.
31  *
32  * The properties of the _AdaptiveProvisioningPeer_ object associated with the
33  * consumer_id are used in the following way:
34  *
35  * The consumerFilter expression is used to determine if an entry is
36  * applicable.
37  *
38  * Journal entries are scanned beginning at the entry at the cursor in the
39  * advanceCursor property. If the advanceCursor property is not present, the
40  * scan begins after the cursor in currentCursor. If neither are present, the
41  * scan begins at the start of the journal.
42  *
43  * If an new applicable entry is found or if the limit is met, the
44  * advanceCursor property is set to the currently scanned entry's cursor.
45  *
46  * This function is not pure, so it may return a different result
47  * given exactly the same parameters and has side effects.
48  *
49  * Declaration:
50  *
51  * ```
52  * function journal_advance_cursor_for_consumer(
53  * adaptorId: string,
54  * consumerId: string,
55  * limit?: integer
56  * ): object;
57  * ```
58  *
59  * Parameters:
60  *
61  * adaptorId - (string) Id of adaptor.
62  *
63  * consumerId - (string) The consumerId property value of the associated
64  * _AdaptiveProvisioningPeer_ object.
65  *
66  * limit - (optional integer) The maximum number of entries that will be
67  * scanned for an entry where the consumerFilter expression in the
68  * associated _AdaptiveProvisioningPeer_ object evaluates to true.
69  *
70  * Returns:
71  *
72  * (object) Response object.
73  */
74 const afw_value_t *
77 {
78  const afw_value_string_t *adaptorId;
79  const afw_value_string_t *consumerId;
80  const afw_value_integer_t *limit_arg;
81  afw_size_t limit;
82  const afw_object_t *result;
83 
86  limit = 0;
89  limit = (afw_size_t)limit_arg->internal;
90  }
91 
93  &adaptorId->internal, &consumerId->internal, limit, x->p, x->xctx);
94  return afw_value_create_object(result, x->p, x->xctx);
95 }
96 
97 
98 
99 /*
100  * Adaptive function: journal_get_by_cursor
101  *
102  * afw_function_execute_journal_get_by_cursor
103  *
104  * See afw_function_bindings.h for more information.
105  *
106  * Get journal entry specified by entry_cursor parameter.
107  *
108  * This option will set response properties "entry" and "cursor" if there is an
109  * entry to retrieve. If an entry with the supplied cursor does not exist, a
110  * not_found error is thrown.
111  *
112  * This function is not pure, so it may return a different result
113  * given exactly the same parameters.
114  *
115  * Declaration:
116  *
117  * ```
118  * function journal_get_by_cursor(
119  * adaptorId: string,
120  * cursor: string
121  * ): object;
122  * ```
123  *
124  * Parameters:
125  *
126  * adaptorId - (string) Id of adaptor.
127  *
128  * cursor - (string) Journal entry cursor.
129  *
130  * Returns:
131  *
132  * (object) Response object.
133  */
134 const afw_value_t *
137 {
138  const afw_value_string_t *adaptorId;
139  const afw_value_string_t *cursor;
140  const afw_object_t *result;
141 
144 
146  &adaptorId->internal, &cursor->internal, x->p, x->xctx);
147  return afw_value_create_object(result, x->p, x->xctx);
148 }
149 
150 
151 
152 /*
153  * Adaptive function: journal_get_first
154  *
155  * afw_function_execute_journal_get_first
156  *
157  * See afw_function_bindings.h for more information.
158  *
159  * Get first journal entry.
160  *
161  * This option will set response properties "entry" and "cursor" if there is a
162  * first entry to return.
163  *
164  * This function is not pure, so it may return a different result
165  * given exactly the same parameters.
166  *
167  * Declaration:
168  *
169  * ```
170  * function journal_get_first(
171  * adaptorId: string
172  * ): object;
173  * ```
174  *
175  * Parameters:
176  *
177  * adaptorId - (string) Id of adaptor.
178  *
179  * Returns:
180  *
181  * (object) Response object.
182  */
183 const afw_value_t *
186 {
187  const afw_value_string_t *adaptorId;
188  const afw_object_t *result;
189 
191 
193  &adaptorId->internal, x->p, x->xctx);
194  return afw_value_create_object(result, x->p, x->xctx);
195 }
196 
197 
198 
199 /*
200  * Adaptive function: journal_get_next_after_cursor
201  *
202  * afw_function_execute_journal_get_next_after_cursor
203  *
204  * See afw_function_bindings.h for more information.
205  *
206  * Get the next journal entry after the one specified by the entry_cursor
207  * parameter.
208  *
209  * This option will set response properties "entry" and "cursor" if there is a
210  * next entry to retrieve.
211  *
212  * This function is not pure, so it may return a different result
213  * given exactly the same parameters.
214  *
215  * Declaration:
216  *
217  * ```
218  * function journal_get_next_after_cursor(
219  * adaptorId: string,
220  * cursor: string
221  * ): object;
222  * ```
223  *
224  * Parameters:
225  *
226  * adaptorId - (string) Id of adaptor.
227  *
228  * cursor - (string) Journal entry cursor.
229  *
230  * Returns:
231  *
232  * (object) Response object.
233  */
234 const afw_value_t *
237 {
238  const afw_value_string_t *adaptorId;
239  const afw_value_string_t *cursor;
240  const afw_object_t *result;
241 
244 
246  &adaptorId->internal, &cursor->internal, x->p, x->xctx);
247  return afw_value_create_object(result, x->p, x->xctx);
248 }
249 
250 
251 
252 /*
253  * Adaptive function: journal_get_next_for_consumer
254  *
255  * afw_function_execute_journal_get_next_for_consumer
256  *
257  * See afw_function_bindings.h for more information.
258  *
259  * Get the next journal entry for a consumer referenced by the consumer_id
260  * parameter. The entry_cursor parameter is ignored. The limit parameter
261  * specifies the maximum number of entries to scan for an applicable entry for
262  * consumer before returning.
263  *
264  * This option will set response properties "entry" and "entryCursor" if an
265  * applicable entry is retrieved. Property "reissue" will be set as described
266  * below.
267  *
268  * The properties of the _AdaptiveProvisioningPeer_ object associated with the
269  * consumer_id are used in the following way:
270  *
271  * The consumerFilter expression is used to determine if an entry is
272  * applicable.
273  *
274  * If consumeCursor property exists, return that entry at that cursor again
275  * immediately with a "reissue" property added and set to true.
276  *
277  * Journal entries are scanned beginning at the entry at the cursor in the
278  * advanceCursor property. If the advanceCursor property is not present, the
279  * scan begins after the cursor in currentCursor. If neither are present, the
280  * scan begins at the start of the journal.
281  *
282  * If an applicable entry is found, properties consumeStart and consumeCursor
283  * are set, advanceCursor is removed, and the entry is returned. Method
284  * mark_entry_consumed() will remove these properties.
285  *
286  * If no applicable entry is found, advanceCursor is set to the last entry
287  * scanned.
288  *
289  * This function is not pure, so it may return a different result
290  * given exactly the same parameters.
291  *
292  * Declaration:
293  *
294  * ```
295  * function journal_get_next_for_consumer(
296  * adaptorId: string,
297  * consumerId: string,
298  * limit?: integer
299  * ): object;
300  * ```
301  *
302  * Parameters:
303  *
304  * adaptorId - (string) Id of adaptor.
305  *
306  * consumerId - (string) The consumerId property value of the associated
307  * _AdaptiveProvisioningPeer_ object.
308  *
309  * limit - (optional integer) The maximum number of entries that will be
310  * scanned for an entry where the consumerFilter expression in the
311  * associated _AdaptiveProvisioningPeer_ object evaluates to true.
312  *
313  * Returns:
314  *
315  * (object) Response object.
316  */
317 const afw_value_t *
320 {
321  const afw_value_string_t *adaptorId;
322  const afw_value_string_t *consumerId;
323  const afw_value_integer_t *limit_arg;
324  afw_size_t limit;
325  const afw_object_t *result;
326 
329  limit = 0;
332  limit = (afw_size_t)limit_arg->internal;
333  }
334 
336  &adaptorId->internal, &consumerId->internal, limit, x->p, x->xctx);
337  return afw_value_create_object(result, x->p, x->xctx);
338 }
339 
340 
341 
342 /*
343  * Adaptive function: journal_get_next_for_consumer_after_cursor
344  *
345  * afw_function_execute_journal_get_next_for_consumer_after_cursor
346  *
347  * See afw_function_bindings.h for more information.
348  *
349  * Get the next journal entry for a consumer referenced by the consumer_id
350  * after the one specified by the entry_cursor parameter. The limit parameter
351  * specifies the maximum number of entries to scan for an applicable entry for
352  * consumer before returning.
353  *
354  * This option will set response properties "entry" and "cursor" if an
355  * applicable entry is retrieved.
356  *
357  * The properties of the _AdaptiveProvisioningPeer_ object associated with the
358  * consumer_id are used in the following way:
359  *
360  * The consumerFilter expression is used to determine if an entry is
361  * applicable.
362  *
363  * Unlike option get_next_for_consumer, no other properties are referenced or
364  * modified.
365  *
366  * This function is not pure, so it may return a different result
367  * given exactly the same parameters.
368  *
369  * Declaration:
370  *
371  * ```
372  * function journal_get_next_for_consumer_after_cursor(
373  * adaptorId: string,
374  * consumerId: string,
375  * cursor: string,
376  * limit?: integer
377  * ): object;
378  * ```
379  *
380  * Parameters:
381  *
382  * adaptorId - (string) Id of adaptor.
383  *
384  * consumerId - (string) The consumerId property value of the associated
385  * _AdaptiveProvisioningPeer_ object.
386  *
387  * cursor - (string) Journal entry cursor.
388  *
389  * limit - (optional integer) The maximum number of entries that will be
390  * scanned for an entry where the consumerFilter expression in the
391  * associated _AdaptiveProvisioningPeer_ object evaluates to true.
392  *
393  * Returns:
394  *
395  * (object) Response object.
396  */
397 const afw_value_t *
400 {
401  const afw_value_string_t *adaptorId;
402  const afw_value_string_t *consumerId;
403  const afw_value_string_t *cursor;
404  const afw_value_integer_t *limit_arg;
405  afw_size_t limit;
406  const afw_object_t *result;
407 
411  limit = 0;
414  limit = (afw_size_t)limit_arg->internal;
415  }
416 
418  &adaptorId->internal, &consumerId->internal, &cursor->internal,
419  limit, x->p, x->xctx);
420  return afw_value_create_object(result, x->p, x->xctx);
421 }
422 
423 
424 
425 /*
426  * Adaptive function: journal_mark_consumed
427  *
428  * afw_function_execute_journal_mark_consumed
429  *
430  * See afw_function_bindings.h for more information.
431  *
432  * Mark a journal entry returned by get_next_for_consumer() as consumed.
433  *
434  * This function is not pure, so it may return a different result
435  * given exactly the same parameters and has side effects.
436  *
437  * Declaration:
438  *
439  * ```
440  * function journal_mark_consumed(
441  * adaptorId: string,
442  * consumerId: string,
443  * cursor: string
444  * ): null;
445  * ```
446  *
447  * Parameters:
448  *
449  * adaptorId - (string) Id of adaptor.
450  *
451  * consumerId - (string) The consumerId property value of the associated
452  * _AdaptiveProvisioningPeer_ object.
453  *
454  * cursor - (string) Journal entry cursor.
455  *
456  * Returns:
457  *
458  * (null)
459  */
460 const afw_value_t *
463 {
464  const afw_value_string_t *adaptorId;
465  const afw_value_string_t *consumerId;
466  const afw_value_string_t *cursor;
467 
471 
473  &adaptorId->internal, &consumerId->internal, &cursor->internal,
474  x->p, x->xctx);
475  return afw_value_null;
476 }
Adaptive Framework Core Internal.
afw_adaptor_journal_get_by_cursor(const afw_utf8_t *adaptor_id, const afw_utf8_t *cursor, const afw_pool_t *p, afw_xctx_t *xctx)
Journal - get entry at cursor.
afw_adaptor_journal_get_first(const afw_utf8_t *adaptor_id, const afw_pool_t *p, afw_xctx_t *xctx)
Journal - get first entry.
afw_adaptor_journal_get_next_for_consumer_after_cursor(const afw_utf8_t *adaptor_id, const afw_utf8_t *consumer_id, const afw_utf8_t *cursor, afw_size_t limit, const afw_pool_t *p, afw_xctx_t *xctx)
Journal - get next entry after cursor for consumer.
afw_adaptor_journal_mark_consumed(const afw_utf8_t *adaptor_id, const afw_utf8_t *consumer_id, const afw_utf8_t *cursor, const afw_pool_t *p, afw_xctx_t *xctx)
Journal - mark entry consumed by consumer.
afw_adaptor_journal_get_next_for_consumer(const afw_utf8_t *adaptor_id, const afw_utf8_t *consumer_id, afw_size_t limit, const afw_pool_t *p, afw_xctx_t *xctx)
Journal - get next entry for consumer.
afw_adaptor_journal_advance_cursor_for_consumer(const afw_utf8_t *adaptor_id, const afw_utf8_t *consumer_id, afw_size_t limit, const afw_pool_t *p, afw_xctx_t *xctx)
Journal - advance cursor for consumer.
afw_adaptor_journal_get_next_after_cursor(const afw_utf8_t *adaptor_id, const afw_utf8_t *cursor, const afw_pool_t *p, afw_xctx_t *xctx)
Journal - get next entry after cursor.
afw_value_create_object(const afw_object_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type object value.
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
#define AFW_FUNCTION_EVALUATE_REQUIRED_DATA_TYPE_PARAMETER(A_RESULT, A_N, A_TYPE)
Evaluate an arg for a particular data type.
Definition: afw_function.h:328
#define AFW_FUNCTION_PARAMETER_IS_PRESENT(A_N)
Determine if a specific parameter value is present.
Definition: afw_function.h:242
const afw_value_t * afw_function_execute_journal_get_first(afw_function_execute_t *x)
Adaptive Function journal_get_first
const afw_value_t * afw_function_execute_journal_mark_consumed(afw_function_execute_t *x)
Adaptive Function journal_mark_consumed
const afw_value_t * afw_function_execute_journal_get_next_for_consumer(afw_function_execute_t *x)
Adaptive Function journal_get_next_for_consumer
const afw_value_t * afw_function_execute_journal_get_by_cursor(afw_function_execute_t *x)
Adaptive Function journal_get_by_cursor
const afw_value_t * afw_function_execute_journal_get_next_after_cursor(afw_function_execute_t *x)
Adaptive Function journal_get_next_after_cursor
const afw_value_t * afw_function_execute_journal_get_next_for_consumer_after_cursor(afw_function_execute_t *x)
Adaptive Function journal_get_next_for_consumer_after_cursor
const afw_value_t * afw_function_execute_journal_advance_cursor_for_consumer(afw_function_execute_t *x)
Adaptive Function journal_advance_cursor_for_consumer
afw_value_null
Adaptive value null.
Definition: afw_value.h:320
Function execute parameter.
Definition: afw_function.h:53
afw_xctx_t * xctx
The execution context (xctx) of caller.
Definition: afw_function.h:62
const afw_pool_t * p
Pool for result.
Definition: afw_function.h:59
Interface afw_object public struct.
struct for data type integer values.
Interface afw_value public struct.
struct for data type string values.