All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_policy.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 #pragma once
18 
19 /**
20  * @defgroup client_policies Client Policies
21  *
22  * Policies define the behavior of database operations.
23  *
24  * Policies fall into two groups: policy values and operation policies.
25  * A policy value is a single value which defines how the client behaves. An
26  * operation policy is a group of policy values which affect an operation.
27  *
28  * ## Policy Values
29  *
30  * The following are the policy values. For details, please see the documentation
31  * for each policy value
32  *
33  * - as_policy_key
34  * - as_policy_gen
35  * - as_policy_exists
36  * - as_policy_replica
37  * - as_policy_consistency_level
38  * - as_policy_commit_level
39  *
40  * ## Operation Policies
41  *
42  * The following are the operation policies. Operation policies are groups of
43  * policy values for a type of operation.
44  *
45  * - as_policy_batch
46  * - as_policy_info
47  * - as_policy_operate
48  * - as_policy_read
49  * - as_policy_remove
50  * - as_policy_query
51  * - as_policy_scan
52  * - as_policy_write
53  */
54 
55 #include <stdbool.h>
56 #include <stdint.h>
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /******************************************************************************
63  * MACROS
64  *****************************************************************************/
65 
66 /**
67  * Default timeout value
68  *
69  * @ingroup client_policies
70  */
71 #define AS_POLICY_TIMEOUT_DEFAULT 1000
72 
73 /**
74  * Default number of retries when a transaction fails due to a network error.
75  *
76  * @ingroup client_policies
77  */
78 #define AS_POLICY_RETRY_DEFAULT 1
79 
80 /**
81  * Default as_policy_gen value
82  *
83  * @ingroup client_policies
84  */
85 #define AS_POLICY_GEN_DEFAULT AS_POLICY_GEN_IGNORE
86 
87 /**
88  * Default as_policy_key value
89  *
90  * @ingroup client_policies
91  */
92 #define AS_POLICY_KEY_DEFAULT AS_POLICY_KEY_DIGEST
93 
94 /**
95  * Default as_policy_exists value
96  *
97  * @ingroup client_policies
98  */
99 #define AS_POLICY_EXISTS_DEFAULT AS_POLICY_EXISTS_IGNORE
100 
101 /**
102  * Default as_policy_replica value
103  *
104  * @ingroup client_policies
105  */
106 #define AS_POLICY_REPLICA_DEFAULT AS_POLICY_REPLICA_MASTER
107 
108 /**
109  * Default as_policy_consistency_level value for read
110  *
111  * @ingroup client_policies
112  */
113 #define AS_POLICY_CONSISTENCY_LEVEL_DEFAULT AS_POLICY_CONSISTENCY_LEVEL_ONE
114 
115 /**
116  * Default as_policy_commit_level value for write
117  *
118  * @ingroup client_policies
119  */
120 #define AS_POLICY_COMMIT_LEVEL_DEFAULT AS_POLICY_COMMIT_LEVEL_ALL
121 
122 /******************************************************************************
123  * TYPES
124  *****************************************************************************/
125 
126 /**
127  * Retry Policy
128  *
129  * Specifies the behavior of failed operations.
130  *
131  * @ingroup client_policies
132  */
133 typedef enum as_policy_retry_e {
134 
135  /**
136  * Only attempt an operation once.
137  */
139 
140  /**
141  * If an operation fails, attempt the operation
142  * one more time.
143  */
145 
147 
148 /**
149  * Generation Policy
150  *
151  * Specifies the behavior of record modifications with regard to the
152  * generation value.
153  *
154  * @ingroup client_policies
155  */
156 typedef enum as_policy_gen_e {
157 
158  /**
159  * Write a record, regardless of generation.
160  */
162 
163  /**
164  * Write a record, ONLY if generations are equal
165  */
167 
168  /**
169  * Write a record, ONLY if local generation is
170  * greater-than remote generation
171  */
173 
174 } as_policy_gen;
175 
176 /**
177  * Key Policy
178  *
179  * Specifies the behavior for whether keys or digests
180  * should be sent to the cluster.
181  *
182  * @ingroup client_policies
183  */
184 typedef enum as_policy_key_e {
185 
186  /**
187  * Send the digest value of the key.
188  *
189  * This is the recommended mode of operation. This calculates the digest
190  * and send the digest to the server. The digest is only calculated on
191  * the client, and not on the server.
192  */
194 
195  /**
196  * Send the key, in addition to the digest value.
197  *
198  * If you want keys to be returned when scanning or querying, the keys must
199  * be stored on the server. This policy causes a write operation to store
200  * the key. Once a key is stored, the server will keep it - there is no
201  * need to use this policy on subsequent updates of the record.
202  *
203  * If this policy is used on read or delete operations, or on subsequent
204  * updates of a record with a stored key, the key sent will be compared
205  * with the key stored on the server. A mismatch will cause
206  * AEROSPIKE_ERR_RECORD_KEY_MISMATCH to be returned.
207  */
209 
210 } as_policy_key;
211 
212 /**
213  * Existence Policy
214  *
215  * Specifies the behavior for writing the record
216  * depending whether or not it exists.
217  *
218  * @ingroup client_policies
219  */
220 typedef enum as_policy_exists_e {
221 
222  /**
223  * Write the record, regardless of existence. (i.e. create or update.)
224  */
226 
227  /**
228  * Create a record, ONLY if it doesn't exist.
229  */
231 
232  /**
233  * Update a record, ONLY if it exists.
234  */
236 
237  /**
238  * Completely replace a record, ONLY if it exists.
239  */
241 
242  /**
243  * Completely replace a record if it exists, otherwise create it.
244  */
246 
248 
249 /**
250  * Replica Policy
251  *
252  * Specifies which partition replica to read from.
253  *
254  * @ingroup client_policies
255  */
256 typedef enum as_policy_replica_e {
257 
258  /**
259  * Read from the partition master replica node.
260  */
262 
263  /**
264  * Read from an unspecified replica node.
265  */
267 
269 
270 /**
271  * Consistency Level
272  *
273  * Specifies the number of replicas to be consulted
274  * in a read operation to provide the desired
275  * consistency guarantee.
276  *
277  * @ingroup client_policies
278  */
279 typedef enum as_policy_consistency_level_e {
280 
281  /**
282  * Involve a single replica in the operation.
283  */
285 
286  /**
287  * Involve all replicas in the operation.
288  */
290 
292 
293 /**
294  * Commit Level
295  *
296  * Specifies the number of replicas required to be successfully
297  * committed before returning success in a write operation
298  * to provide the desired consistency guarantee.
299  *
300  * @ingroup client_policies
301  */
302 typedef enum as_policy_commit_level_e {
303 
304  /**
305  * Return succcess only after successfully committing all replicas.
306  */
308 
309  /**
310  * Return succcess after successfully committing the master replica.
311  */
313 
315 
316 /**
317  * Write Policy
318  *
319  * @ingroup client_policies
320  */
321 typedef struct as_policy_write_s {
322 
323  /**
324  * Maximum time in milliseconds to wait for
325  * the operation to complete.
326  */
327  uint32_t timeout;
328 
329  /**
330  * Maximum number of retries when a transaction fails due to a network error.
331  */
332  uint32_t retry;
333 
334  /**
335  * Specifies the behavior for the key.
336  */
338 
339  /**
340  * Specifies the behavior for the generation
341  * value.
342  */
344 
345  /**
346  * Specifies the behavior for the existence
347  * of the record.
348  */
350 
351  /**
352  * Specifies the number of replicas required
353  * to be committed successfully when writing
354  * before returning transaction succeeded.
355  */
357 
359 
360 /**
361  * Read Policy
362  *
363  * @ingroup client_policies
364  */
365 typedef struct as_policy_read_s {
366 
367  /**
368  * Maximum time in milliseconds to wait for
369  * the operation to complete.
370  */
371  uint32_t timeout;
372 
373  /**
374  * Maximum number of retries when a transaction fails due to a network error.
375  */
376  uint32_t retry;
377 
378  /**
379  * Specifies the behavior for the key.
380  */
382 
383  /**
384  * Specifies the replica to be consulted for the read.
385  */
387 
388  /**
389  * Specifies the number of replicas consulted
390  * when reading for the desired consistency guarantee.
391  */
393 
394  /**
395  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
396  * Set to false for backup programs that just need access to raw bytes.
397  * Default: true
398  */
400 
402 
403 /**
404  * Key Apply Policy
405  *
406  * @ingroup client_policies
407  */
408 typedef struct as_policy_apply_s {
409 
410  /**
411  * Maximum time in milliseconds to wait for
412  * the operation to complete.
413  */
414  uint32_t timeout;
415 
416  /**
417  * Specifies the behavior for the key.
418  */
420 
421  /**
422  * Specifies the number of replicas required
423  * to be committed successfully when writing
424  * before returning transaction succeeded.
425  */
427 
428  /**
429  * The time-to-live (expiration) of the record in seconds.
430  * There are two special values that can be set in the record TTL:
431  * (*) ZERO (defined as AS_RECORD_DEFAULT_TTL), which means that the
432  * record will adopt the default TTL value from the namespace.
433  * (*) 0xFFFFFFFF (also, -1 in a signed 32 bit int)
434  * (defined as AS_RECORD_NO_EXPIRE_TTL), which means that the record
435  * will get an internal "void_time" of zero, and thus will never expire.
436  *
437  * Note that the TTL value will be employed ONLY on write/update calls.
438  */
439  uint32_t ttl;
440 
442 
443 /**
444  * Operate Policy
445  *
446  * @ingroup client_policies
447  */
448 typedef struct as_policy_operate_s {
449 
450  /**
451  * Maximum time in milliseconds to wait for
452  * the operation to complete.
453  */
454  uint32_t timeout;
455 
456  /**
457  * Maximum number of retries when a transaction fails due to a network error.
458  */
459  uint32_t retry;
460 
461  /**
462  * Specifies the behavior for the key.
463  */
465 
466  /**
467  * Specifies the behavior for the generation
468  * value.
469  */
471 
472  /**
473  * Specifies the replica to be consulted for the read.
474  */
476 
477  /**
478  * Specifies the number of replicas consulted
479  * when reading for the desired consistency guarantee.
480  */
482 
483  /**
484  * Specifies the number of replicas required
485  * to be committed successfully when writing
486  * before returning transaction succeeded.
487  */
489 
490  /**
491  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
492  * Set to false for backup programs that just need access to raw bytes.
493  * Default: true
494  */
496 
498 
499 /**
500  * Remove Policy
501  *
502  * @ingroup client_policies
503  */
504 typedef struct as_policy_remove_s {
505 
506  /**
507  * Maximum time in milliseconds to wait for
508  * the operation to complete.
509  */
510  uint32_t timeout;
511 
512  /**
513  * The generation of the record.
514  */
515  uint16_t generation;
516 
517  /**
518  * Maximum number of retries when a transaction fails due to a network error.
519  */
520  uint32_t retry;
521 
522  /**
523  * Specifies the behavior for the key.
524  */
526 
527  /**
528  * Specifies the behavior for the generation
529  * value.
530  */
532 
533  /**
534  * Specifies the number of replicas required
535  * to be committed successfully when writing
536  * before returning transaction succeeded.
537  */
539 
541 
542 /**
543  * Query Policy
544  *
545  * @ingroup client_policies
546  */
547 typedef struct as_policy_query_s {
548 
549  /**
550  * Maximum time in milliseconds to wait for
551  * the operation to complete.
552  *
553  * The default (0) means do not timeout.
554  */
555  uint32_t timeout;
556 
557  /**
558  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
559  * Set to false for backup programs that just need access to raw bytes.
560  * Default: true
561  */
563 
565 
566 /**
567  * Scan Policy
568  *
569  * @ingroup client_policies
570  */
571 typedef struct as_policy_scan_s {
572 
573  /**
574  * Maximum time in milliseconds to wait for the operation to complete.
575  *
576  * The default (0) means do not timeout.
577  */
578  uint32_t timeout;
579 
580  /**
581  * Abort the scan if the cluster is not in a
582  * stable state.
583  */
585 
587 
588 /**
589  * Info Policy
590  *
591  * @ingroup client_policies
592  */
593 typedef struct as_policy_info_s {
594 
595  /**
596  * Maximum time in milliseconds to wait for
597  * the operation to complete.
598  */
599  uint32_t timeout;
600 
601  /**
602  * Send request without any further processing.
603  */
605 
606  /**
607  * Ensure the request is within allowable size limits.
608  */
610 
612 
613 /**
614  * Batch Policy
615  *
616  * @ingroup client_policies
617  */
618 typedef struct as_policy_batch_s {
619 
620  /**
621  * Maximum time in milliseconds to wait for
622  * the operation to complete.
623  */
624  uint32_t timeout;
625 
626  /**
627  * Determine if batch commands to each server are run in parallel threads.
628  * <p>
629  * Values:
630  * <ul>
631  * <li>
632  * false: Issue batch commands sequentially. This mode has a performance advantage for small
633  * to medium sized batch sizes because commands can be issued in the main transaction thread.
634  * This is the default.
635  * </li>
636  * <li>
637  * true: Issue batch commands in parallel threads. This mode has a performance
638  * advantage for large batch sizes because each node can process the command immediately.
639  * The downside is extra threads will need to be created (or taken from
640  * a thread pool).
641  * </li>
642  * </ul>
643  */
645 
646  /**
647  * Use old batch direct protocol where batch reads are handled by direct low-level batch server
648  * database routines. The batch direct protocol can be faster when there is a single namespace,
649  * but there is one important drawback. The batch direct protocol will not proxy to a different
650  * server node when the mapped node has migrated a record to another node (resulting in not
651  * found record).
652  * <p>
653  * This can happen after a node has been added/removed from the cluster and there is a lag
654  * between records being migrated and client partition map update (once per second).
655  * <p>
656  * The new batch index protocol will perform this record proxy when necessary.
657  * Default: false (use new batch index protocol if server supports it)
658  */
660 
661  /**
662  * Allow batch to be processed immediately in the server's receiving thread when the server
663  * deems it to be appropriate. If false, the batch will always be processed in separate
664  * transaction threads. This field is only relevant for the new batch index protocol.
665  * <p>
666  * For batch exists or batch reads of smaller sized records (<= 1K per record), inline
667  * processing will be significantly faster on "in memory" namespaces. The server disables
668  * inline processing on disk based namespaces regardless of this policy field.
669  * <p>
670  * Inline processing can introduce the possibility of unfairness because the server
671  * can process the entire batch before moving onto the next command.
672  * Default: true
673  */
675 
676  /**
677  * Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
678  * just need access to raw bytes.
679  * Default: true
680  */
682 
684 
685 /**
686  * Administration Policy
687  *
688  * @ingroup client_policies
689  */
690 typedef struct as_policy_admin_s {
691 
692  /**
693  * Maximum time in milliseconds to wait for
694  * the operation to complete.
695  */
696  uint32_t timeout;
697 
699 
700 /**
701  * Struct of all policy values and operation policies.
702  *
703  * This is utilizes by as_config, to define global and default values
704  * for policies.
705  *
706  * @ingroup as_config_t
707  */
708 typedef struct as_policies_s {
709 
710  /***************************************************************************
711  * DEFAULT VALUES, IF SPECIFIC POLICY IS UNDEFINED
712  **************************************************************************/
713 
714  /**
715  * Default timeout in milliseconds.
716  *
717  * Will be used if specific policies have a timeout of 0 (zero).
718  *
719  * The default value is `AS_POLICY_TIMEOUT_DEFAULT`.
720  */
721  uint32_t timeout;
722 
723  /**
724  * Maximum number of retries when a transaction fails due to a network error.
725  *
726  * The default value is `AS_POLICY_RETRY_DEFAULT`.
727  */
728  uint32_t retry;
729 
730  /**
731  * Specifies the behavior for the key.
732  *
733  * The default value is `AS_POLICY_KEY_DEFAULT`.
734  */
736 
737  /**
738  * Specifies the behavior for the generation
739  * value.
740  *
741  * The default value is `AS_POLICY_GEN_DEFAULT`.
742  */
744 
745  /**
746  * Specifies the behavior for the existence
747  * of the record.
748  *
749  * The default value is `AS_POLICY_EXISTS_DEFAULT`.
750  */
752 
753  /**
754  * Specifies which replica to read.
755  *
756  * The default value is `AS_POLICY_REPLICA_MASTER`.
757  */
759 
760  /**
761  * Specifies the consistency level for reading.
762  *
763  * The default value is `AS_POLICY_CONSISTENCY_LEVEL_ONE`.
764  */
766 
767  /**
768  * Specifies the commit level for writing.
769  *
770  * The default value is `AS_POLICY_COMMIT_LEVEL_ALL`.
771  */
773 
774  /***************************************************************************
775  * SPECIFIC POLICIES
776  **************************************************************************/
777 
778  /**
779  * The default read policy.
780  */
782 
783  /**
784  * The default write policy.
785  */
787 
788  /**
789  * The default operate policy.
790  */
792 
793  /**
794  * The default remove policy.
795  */
797 
798  /**
799  * The default apply policy.
800  */
802 
803  /**
804  * The default query policy.
805  */
807 
808  /**
809  * The default scan policy.
810  */
812 
813  /**
814  * The default info policy.
815  */
817 
818  /**
819  * The default batch policy.
820  */
822 
823  /**
824  * The default administration policy.
825  */
827 
828 } as_policies;
829 
830 /******************************************************************************
831  * FUNCTIONS
832  *****************************************************************************/
833 
834 /**
835  * Initialize as_policy_read to default values.
836  *
837  * @param p The policy to initialize.
838  * @return The initialized policy.
839  *
840  * @relates as_policy_read
841  */
842 static inline as_policy_read*
844 {
850  p->deserialize = true;
851  return p;
852 }
853 
854 /**
855  * Copy as_policy_read values.
856  *
857  * @param src The source policy.
858  * @param trg The target policy.
859  *
860  * @relates as_policy_read
861  */
862 static inline void
864 {
865  trg->timeout = src->timeout;
866  trg->retry = src->retry;
867  trg->key = src->key;
868  trg->replica = src->replica;
870  trg->deserialize = src->deserialize;
871 }
872 
873 /**
874  * Initialize as_policy_write to default values.
875  *
876  * @param p The policy to initialize.
877  * @return The initialized policy.
878  *
879  * @relates as_policy_write
880  */
881 static inline as_policy_write*
883 {
890  return p;
891 }
892 
893 /**
894  * Copy as_policy_write values.
895  *
896  * @param src The source policy.
897  * @param trg The target policy.
898  *
899  * @relates as_policy_write
900  */
901 static inline void
903 {
904  trg->timeout = src->timeout;
905  trg->retry = src->retry;
906  trg->key = src->key;
907  trg->gen = src->gen;
908  trg->exists = src->exists;
909  trg->commit_level = src->commit_level;
910 }
911 
912 /**
913  * Initialize as_policy_operate to default values.
914  *
915  * @param p The policy to initialize.
916  * @return The initialized policy.
917  *
918  * @relates as_policy_operate
919  */
920 static inline as_policy_operate*
922 {
930  p->deserialize = true;
931  return p;
932 }
933 
934 /**
935  * Copy as_policy_operate values.
936  *
937  * @param src The source policy.
938  * @param trg The target policy.
939  *
940  * @relates as_policy_operate
941  */
942 static inline void
944 {
945  trg->timeout = src->timeout;
946  trg->retry = src->retry;
947  trg->key = src->key;
948  trg->gen = src->gen;
949  trg->replica = src->replica;
951  trg->commit_level = src->commit_level;
952  trg->deserialize = src->deserialize;
953 }
954 
955 /**
956  * Initialize as_policy_remove to default values.
957  *
958  * @param p The policy to initialize.
959  * @return The initialized policy.
960  *
961  * @relates as_policy_remove
962  */
963 static inline as_policy_remove*
965 {
970  p->generation = 0;
972  return p;
973 }
974 
975 /**
976  * Copy as_policy_remove values.
977  *
978  * @param src The source policy.
979  * @param trg The target policy.
980  *
981  * @relates as_policy_remove
982  */
983 static inline void
985 {
986  trg->timeout = src->timeout;
987  trg->retry = src->retry;
988  trg->key = src->key;
989  trg->gen = src->gen;
990  trg->generation = src->generation;
991  trg->commit_level = src->commit_level;
992 }
993 
994 /**
995  * Initialize as_policy_apply to default values.
996  *
997  * @param p The policy to initialize.
998  * @return The initialized policy.
999  *
1000  * @relates as_policy_apply
1001  */
1002 static inline as_policy_apply*
1004 {
1008  p->ttl = 0; // AS_RECORD_DEFAULT_TTL
1009  return p;
1010 }
1011 
1012 /**
1013  * Copy as_policy_apply values.
1014  *
1015  * @param src The source policy.
1016  * @param trg The target policy.
1017  *
1018  * @relates as_policy_apply
1019  */
1020 static inline void
1022 {
1023  trg->timeout = src->timeout;
1024  trg->key = src->key;
1025  trg->commit_level = src->commit_level;
1026  trg->ttl = src->ttl;
1027 }
1028 
1029 /**
1030  * Initialize as_policy_info to default values.
1031  *
1032  * @param p The policy to initialize.
1033  * @return The initialized policy.
1034  *
1035  * @relates as_policy_info
1036  */
1037 static inline as_policy_info*
1039 {
1041  p->send_as_is = true;
1042  p->check_bounds = true;
1043  return p;
1044 }
1045 
1046 /**
1047  * Copy as_policy_info values.
1048  *
1049  * @param src The source policy.
1050  * @param trg The target policy.
1051  *
1052  * @relates as_policy_info
1053  */
1054 static inline void
1056 {
1057  trg->timeout = src->timeout;
1058  trg->send_as_is = src->send_as_is;
1059  trg->check_bounds = src->check_bounds;
1060 }
1061 
1062 /**
1063  * Initialize as_policy_batch to default values.
1064  *
1065  * @param p The policy to initialize.
1066  * @return The initialized policy.
1067  *
1068  * @relates as_policy_batch
1069  */
1070 static inline as_policy_batch*
1072 {
1074  p->concurrent = false;
1075  p->use_batch_direct = false;
1076  p->allow_inline = true;
1077  p->deserialize = true;
1078  return p;
1079 }
1080 
1081 /**
1082  * Copy as_policy_batch values.
1083  *
1084  * @param src The source policy.
1085  * @param trg The target policy.
1086  *
1087  * @relates as_policy_batch
1088  */
1089 static inline void
1091 {
1092  trg->timeout = src->timeout;
1093  trg->concurrent = src->concurrent;
1094  trg->use_batch_direct = src->use_batch_direct;
1095  trg->allow_inline = src->allow_inline;
1096  trg->deserialize = src->deserialize;
1097 }
1098 
1099 /**
1100  * Initialize as_policy_admin to default values.
1101  *
1102  * @param p The policy to initialize.
1103  * @return The initialized policy.
1104  *
1105  * @relates as_policy_admin
1106  */
1107 static inline as_policy_admin*
1109 {
1111  return p;
1112 }
1113 
1114 /**
1115  * Copy as_policy_admin values.
1116  *
1117  * @param src The source policy.
1118  * @param trg The target policy.
1119  *
1120  * @relates as_policy_admin
1121  */
1122 static inline void
1124 {
1125  trg->timeout = src->timeout;
1126 }
1127 
1128 /**
1129  * Initialize as_policy_scan to default values.
1130  *
1131  * @param p The policy to initialize.
1132  * @return The initialized policy.
1133  *
1134  * @relates as_policy_scan
1135  */
1136 static inline as_policy_scan*
1138 {
1139  p->timeout = 0;
1140  p->fail_on_cluster_change = false;
1141  return p;
1142 }
1143 
1144 /**
1145  * Copy as_policy_scan values.
1146  *
1147  * @param src The source policy.
1148  * @param trg The target policy.
1149  *
1150  * @relates as_policy_scan
1151  */
1152 static inline void
1154 {
1155  trg->timeout = src->timeout;
1157 }
1158 
1159 /**
1160  * Initialize as_policy_query to default values.
1161  *
1162  * @param p The policy to initialize.
1163  * @return The initialized policy.
1164  *
1165  * @relates as_policy_query
1166  */
1167 static inline as_policy_query*
1169 {
1170  p->timeout = 0;
1171  p->deserialize = true;
1172  return p;
1173 }
1174 
1175 /**
1176  * Copy as_policy_query values.
1177  *
1178  * @param src The source policy.
1179  * @param trg The target policy.
1180  *
1181  * @relates as_policy_query
1182  */
1183 static inline void
1185 {
1186  trg->timeout = src->timeout;
1187  trg->deserialize = src->deserialize;
1188 }
1189 
1190 /**
1191  * Initialize as_policies to undefined values.
1192  * as_policies_resolve() will later be called resolve undefined values to global defaults.
1193  *
1194  * @param p The policies to undefine
1195  * @return The undefined policies.
1196  *
1197  * @relates as_policies
1198  */
1199 as_policies*
1201 
1202 /**
1203  * Resolve global policies (like timeout) with operational policies (like as_policy_read).
1204  *
1205  * @param p The policies to resolve
1206  *
1207  * @relates as_policies
1208  */
1209 void
1211 
1212 #ifdef __cplusplus
1213 } // end extern "C"
1214 #endif