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-2017 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 socket idle timeout value
68  *
69  * @ingroup client_policies
70  */
71 #define AS_POLICY_SOCKET_TIMEOUT_DEFAULT 0
72 
73 /**
74  * Default total timeout value
75  *
76  * @ingroup client_policies
77  */
78 #define AS_POLICY_TOTAL_TIMEOUT_DEFAULT 1000
79 
80 /**
81  * Default number of retries when a transaction fails due to a network error.
82  *
83  * @ingroup client_policies
84  */
85 #define AS_POLICY_MAX_RETRIES_DEFAULT 2
86 
87 /**
88  * Default milliseconds to sleep before a command retry.
89  *
90  * @ingroup client_policies
91  */
92 #define AS_POLICY_SLEEP_BETWEEN_RETRIES_DEFAULT 0
93 
94 /**
95  * Default value for compression threshold
96  *
97  * @ingroup client_policies
98  */
99 #define AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT 0
100 
101 /**
102  * Default as_policy_gen value
103  *
104  * @ingroup client_policies
105  */
106 #define AS_POLICY_GEN_DEFAULT AS_POLICY_GEN_IGNORE
107 
108 /**
109  * Default as_policy_key value
110  *
111  * @ingroup client_policies
112  */
113 #define AS_POLICY_KEY_DEFAULT AS_POLICY_KEY_DIGEST
114 
115 /**
116  * Default as_policy_exists value
117  *
118  * @ingroup client_policies
119  */
120 #define AS_POLICY_EXISTS_DEFAULT AS_POLICY_EXISTS_IGNORE
121 
122 /**
123  * Default as_policy_replica value
124  *
125  * @ingroup client_policies
126  */
127 #define AS_POLICY_REPLICA_DEFAULT AS_POLICY_REPLICA_SEQUENCE
128 
129 /**
130  * Default as_policy_consistency_level value for read
131  *
132  * @ingroup client_policies
133  */
134 #define AS_POLICY_CONSISTENCY_LEVEL_DEFAULT AS_POLICY_CONSISTENCY_LEVEL_ONE
135 
136 /**
137  * Default as_policy_commit_level value for write
138  *
139  * @ingroup client_policies
140  */
141 #define AS_POLICY_COMMIT_LEVEL_DEFAULT AS_POLICY_COMMIT_LEVEL_ALL
142 
143 /******************************************************************************
144  * TYPES
145  *****************************************************************************/
146 
147 /**
148  * Retry Policy
149  *
150  * Specifies the behavior of failed operations.
151  *
152  * @ingroup client_policies
153  */
154 typedef enum as_policy_retry_e {
155 
156  /**
157  * Only attempt an operation once.
158  */
160 
161  /**
162  * If an operation fails, attempt the operation
163  * one more time.
164  */
166 
168 
169 /**
170  * Generation Policy
171  *
172  * Specifies the behavior of record modifications with regard to the
173  * generation value.
174  *
175  * @ingroup client_policies
176  */
177 typedef enum as_policy_gen_e {
178 
179  /**
180  * Write a record, regardless of generation.
181  */
183 
184  /**
185  * Write a record, ONLY if generations are equal
186  */
188 
189  /**
190  * Write a record, ONLY if local generation is
191  * greater-than remote generation
192  */
194 
195 } as_policy_gen;
196 
197 /**
198  * Key Policy
199  *
200  * Specifies the behavior for whether keys or digests
201  * should be sent to the cluster.
202  *
203  * @ingroup client_policies
204  */
205 typedef enum as_policy_key_e {
206 
207  /**
208  * Send the digest value of the key.
209  *
210  * This is the recommended mode of operation. This calculates the digest
211  * and send the digest to the server. The digest is only calculated on
212  * the client, and not on the server.
213  */
215 
216  /**
217  * Send the key, in addition to the digest value.
218  *
219  * If you want keys to be returned when scanning or querying, the keys must
220  * be stored on the server. This policy causes a write operation to store
221  * the key. Once a key is stored, the server will keep it - there is no
222  * need to use this policy on subsequent updates of the record.
223  *
224  * If this policy is used on read or delete operations, or on subsequent
225  * updates of a record with a stored key, the key sent will be compared
226  * with the key stored on the server. A mismatch will cause
227  * AEROSPIKE_ERR_RECORD_KEY_MISMATCH to be returned.
228  */
230 
231 } as_policy_key;
232 
233 /**
234  * Existence Policy
235  *
236  * Specifies the behavior for writing the record
237  * depending whether or not it exists.
238  *
239  * @ingroup client_policies
240  */
241 typedef enum as_policy_exists_e {
242 
243  /**
244  * Write the record, regardless of existence. (i.e. create or update.)
245  */
247 
248  /**
249  * Create a record, ONLY if it doesn't exist.
250  */
252 
253  /**
254  * Update a record, ONLY if it exists.
255  */
257 
258  /**
259  * Completely replace a record, ONLY if it exists.
260  */
262 
263  /**
264  * Completely replace a record if it exists, otherwise create it.
265  */
267 
269 
270 /**
271  * Replica Policy
272  *
273  * Specifies which partition replica to read from.
274  *
275  * @ingroup client_policies
276  */
277 typedef enum as_policy_replica_e {
278 
279  /**
280  * Read from the partition master replica node.
281  */
283 
284  /**
285  * Distribute reads across nodes containing key's master and replicated partition
286  * in round-robin fashion. Currently restricted to master and one prole.
287  */
289 
290  /**
291  * Always try node containing master partition first. If connection fails and
292  * `retry_on_timeout` is true, try node containing prole partition.
293  * Currently restricted to master and one prole.
294  */
296 
298 
299 /**
300  * Consistency Level
301  *
302  * Specifies the number of replicas to be consulted
303  * in a read operation to provide the desired
304  * consistency guarantee.
305  *
306  * @ingroup client_policies
307  */
308 typedef enum as_policy_consistency_level_e {
309 
310  /**
311  * Involve a single replica in the operation.
312  */
314 
315  /**
316  * Involve all replicas in the operation.
317  */
319 
321 
322 /**
323  * Commit Level
324  *
325  * Specifies the number of replicas required to be successfully
326  * committed before returning success in a write operation
327  * to provide the desired consistency guarantee.
328  *
329  * @ingroup client_policies
330  */
331 typedef enum as_policy_commit_level_e {
332 
333  /**
334  * Return succcess only after successfully committing all replicas.
335  */
337 
338  /**
339  * Return succcess after successfully committing the master replica.
340  */
342 
344 
345 /**
346  * Generic policy fields shared among all policies.
347  *
348  * @ingroup client_policies
349  */
350 typedef struct as_policy_base_s {
351 
352  /**
353  * Socket idle timeout in milliseconds when processing a database command.
354  *
355  * If socket_timeout is not zero and the socket has been idle for at least socket_timeout,
356  * both max_retries and total_timeout are checked. If max_retries and total_timeout are not
357  * exceeded, the transaction is retried.
358  *
359  * If both socket_timeout and total_timeout are non-zero and socket_timeout > total_timeout,
360  * then socket_timeout will be set to total_timeout. If socket_timeout is zero, there will be
361  * no socket idle limit.
362  *
363  * Default: 0 (no socket idle time limit).
364  */
365  uint32_t socket_timeout;
366 
367  /**
368  * Total transaction timeout in milliseconds.
369  *
370  * The total_timeout is tracked on the client and sent to the server along with
371  * the transaction in the wire protocol. The client will most likely timeout
372  * first, but the server also has the capability to timeout the transaction.
373  *
374  * If total_timeout is not zero and total_timeout is reached before the transaction
375  * completes, the transaction will return error AEROSPIKE_ERR_TIMEOUT.
376  * If totalTimeout is zero, there will be no total time limit.
377  *
378  * Default: 1000
379  */
380  uint32_t total_timeout;
381 
382  /**
383  * Maximum number of retries before aborting the current transaction.
384  * The initial attempt is not counted as a retry.
385  *
386  * If max_retries is exceeded, the transaction will return error AEROSPIKE_ERR_TIMEOUT.
387  *
388  * WARNING: Database writes that are not idempotent (such as "add")
389  * should not be retried because the write operation may be performed
390  * multiple times if the client timed out previous transaction attempts.
391  * It's important to use a distinct write policy for non-idempotent
392  * writes which sets max_retries = 0;
393  *
394  * Default: 2 (initial attempt + 2 retries = 3 attempts)
395  */
396  uint32_t max_retries;
397 
398  /**
399  * Milliseconds to sleep between retries. Enter zero to skip sleep.
400  * This field is ignored in async mode.
401  *
402  * Reads do not have to sleep when a node goes down because the cluster
403  * does not shut out reads during cluster reformation. The default for
404  * reads is zero.
405  *
406  * Writes need to wait for the cluster to reform when a node goes down.
407  * Immediate write retries on node failure have been shown to consistently
408  * result in errors. The default for writes is 500ms.
409  */
411 
413 
414 /**
415  * Read Policy
416  *
417  * @ingroup client_policies
418  */
419 typedef struct as_policy_read_s {
420 
421  /**
422  * Generic policy fields.
423  */
425 
426  /**
427  * Specifies the behavior for the key.
428  */
430 
431  /**
432  * Specifies the replica to be consulted for the read.
433  */
435 
436  /**
437  * Specifies the number of replicas consulted when reading for the desired consistency guarantee.
438  */
440 
441  /**
442  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
443  * Set to false for backup programs that just need access to raw bytes.
444  * Default: true
445  */
447 
449 
450 /**
451  * Write Policy
452  *
453  * @ingroup client_policies
454  */
455 typedef struct as_policy_write_s {
456 
457  /**
458  * Generic policy fields.
459  */
461 
462  /**
463  * Specifies the behavior for the key.
464  */
466 
467  /**
468  * Specifies the replica to be consulted for the read.
469  */
471 
472  /**
473  * Specifies the number of replicas required to be committed successfully when writing
474  * before returning transaction succeeded.
475  */
477 
478  /**
479  * Specifies the behavior for the generation value.
480  */
482 
483  /**
484  * Specifies the behavior for the existence of the record.
485  */
487 
488  /**
489  * Minimum record size beyond which it is compressed and sent to the server.
490  */
492 
493  /**
494  * If the transaction results in a record deletion, leave a tombstone for the record.
495  * This prevents deleted records from reappearing after node failures.
496  * Valid for Aerospike Server Enterprise Edition only.
497  *
498  * Default: false (do not tombstone deleted records).
499  */
501 
503 
504 /**
505  * Key Apply Policy
506  *
507  * @ingroup client_policies
508  */
509 typedef struct as_policy_apply_s {
510 
511  /**
512  * Generic policy fields.
513  */
515 
516  /**
517  * Specifies the behavior for the key.
518  */
520 
521  /**
522  * Specifies the replica to be consulted for the read.
523  */
525 
526  /**
527  * Specifies the number of replicas required to be committed successfully when writing
528  * before returning transaction succeeded.
529  */
531 
532  /**
533  * The time-to-live (expiration) of the record in seconds.
534  * There are also special values that can be set in the record TTL:
535  * (*) ZERO (defined as AS_RECORD_DEFAULT_TTL), which means that the
536  * record will adopt the default TTL value from the namespace.
537  * (*) 0xFFFFFFFF (also, -1 in a signed 32 bit int)
538  * (defined as AS_RECORD_NO_EXPIRE_TTL), which means that the record
539  * will get an internal "void_time" of zero, and thus will never expire.
540  * (*) 0xFFFFFFFE (also, -2 in a signed 32 bit int)
541  * (defined as AS_RECORD_NO_CHANGE_TTL), which means that the record
542  * ttl will not change when the record is updated.
543  *
544  * Note that the TTL value will be employed ONLY on write/update calls.
545  */
546  uint32_t ttl;
547 
548  /**
549  * Specifies the behavior for the generation value.
550  */
552 
553  /**
554  * The expected generation of the record.
555  */
556  uint16_t gen_value;
557 
558  /**
559  * If the transaction results in a record deletion, leave a tombstone for the record.
560  * This prevents deleted records from reappearing after node failures.
561  * Valid for Aerospike Server Enterprise Edition only.
562  *
563  * Default: false (do not tombstone deleted records).
564  */
566 
568 
569 /**
570  * Operate Policy
571  *
572  * @ingroup client_policies
573  */
574 typedef struct as_policy_operate_s {
575 
576  /**
577  * Generic policy fields.
578  */
580 
581  /**
582  * Specifies the behavior for the key.
583  */
585 
586  /**
587  * Specifies the replica to be consulted for the read.
588  */
590 
591  /**
592  * Specifies the number of replicas consulted when reading for the desired consistency guarantee.
593  */
595 
596  /**
597  * Specifies the number of replicas required to be committed successfully when writing
598  * before returning transaction succeeded.
599  */
601 
602  /**
603  * Specifies the behavior for the generation value.
604  */
606 
607  /**
608  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
609  * Set to false for backup programs that just need access to raw bytes.
610  * Default: true
611  */
613 
614  /**
615  * If the transaction results in a record deletion, leave a tombstone for the record.
616  * This prevents deleted records from reappearing after node failures.
617  * Valid for Aerospike Server Enterprise Edition only.
618  *
619  * Default: false (do not tombstone deleted records).
620  */
622 
624 
625 /**
626  * Remove Policy
627  *
628  * @ingroup client_policies
629  */
630 typedef struct as_policy_remove_s {
631 
632  /**
633  * Generic policy fields.
634  */
636 
637  /**
638  * Specifies the behavior for the key.
639  */
641 
642  /**
643  * Specifies the replica to be consulted for the read.
644  */
646 
647  /**
648  * Specifies the number of replicas required to be committed successfully when writing
649  * before returning transaction succeeded.
650  */
652 
653  /**
654  * Specifies the behavior for the generation value.
655  */
657 
658  /**
659  * The generation of the record.
660  */
661  uint16_t generation;
662 
663  /**
664  * If the transaction results in a record deletion, leave a tombstone for the record.
665  * This prevents deleted records from reappearing after node failures.
666  * Valid for Aerospike Server Enterprise Edition only.
667  *
668  * Default: false (do not tombstone deleted records).
669  */
671 
673 
674 /**
675  * Batch Policy
676  *
677  * @ingroup client_policies
678  */
679 typedef struct as_policy_batch_s {
680 
681  /**
682  * Generic policy fields.
683  */
685 
686  /**
687  * Specifies the number of replicas consulted when reading for the desired consistency guarantee.
688  */
690 
691  /**
692  * Determine if batch commands to each server are run in parallel threads.
693  *
694  * Values:
695  * <ul>
696  * <li>
697  * false: Issue batch commands sequentially. This mode has a performance advantage for small
698  * to medium sized batch sizes because commands can be issued in the main transaction thread.
699  * This is the default.
700  * </li>
701  * <li>
702  * true: Issue batch commands in parallel threads. This mode has a performance
703  * advantage for large batch sizes because each node can process the command immediately.
704  * The downside is extra threads will need to be created (or taken from
705  * a thread pool).
706  * </li>
707  * </ul>
708  */
710 
711  /**
712  * Use old batch direct protocol where batch reads are handled by direct low-level batch server
713  * database routines. The batch direct protocol can be faster when there is a single namespace,
714  * but there is one important drawback. The batch direct protocol will not proxy to a different
715  * server node when the mapped node has migrated a record to another node (resulting in not
716  * found record).
717  *
718  * This can happen after a node has been added/removed from the cluster and there is a lag
719  * between records being migrated and client partition map update (once per second).
720  *
721  * The new batch index protocol will perform this record proxy when necessary.
722  * Default: false (use new batch index protocol if server supports it)
723  */
725 
726  /**
727  * Allow batch to be processed immediately in the server's receiving thread when the server
728  * deems it to be appropriate. If false, the batch will always be processed in separate
729  * transaction threads. This field is only relevant for the new batch index protocol.
730  *
731  * For batch exists or batch reads of smaller sized records (<= 1K per record), inline
732  * processing will be significantly faster on "in memory" namespaces. The server disables
733  * inline processing on disk based namespaces regardless of this policy field.
734  *
735  * Inline processing can introduce the possibility of unfairness because the server
736  * can process the entire batch before moving onto the next command.
737  * Default: true
738  */
740 
741  /**
742  * Send set name field to server for every key in the batch for batch index protocol.
743  * This is only necessary when authentication is enabled and security roles are defined
744  * on a per set basis.
745  * Default: false
746  */
748 
749  /**
750  * Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
751  * just need access to raw bytes.
752  * Default: true
753  */
755 
757 
758 /**
759  * Query Policy
760  *
761  * @ingroup client_policies
762  */
763 typedef struct as_policy_query_s {
764 
765  /**
766  * Generic policy fields.
767  */
769 
770  /**
771  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
772  * Set to false for backup programs that just need access to raw bytes.
773  * Default: true
774  */
776 
778 
779 /**
780  * Scan Policy
781  *
782  * @ingroup client_policies
783  */
784 typedef struct as_policy_scan_s {
785 
786  /**
787  * Generic policy fields.
788  */
790 
791  /**
792  * Abort the scan if the cluster is not in a stable state.
793  */
795 
796  /**
797  * If the transaction results in a record deletion, leave a tombstone for the record.
798  * This prevents deleted records from reappearing after node failures.
799  * Valid for Aerospike Server Enterprise Edition only.
800  *
801  * Default: false (do not tombstone deleted records).
802  */
804 
806 
807 /**
808  * Info Policy
809  *
810  * @ingroup client_policies
811  */
812 typedef struct as_policy_info_s {
813 
814  /**
815  * Maximum time in milliseconds to wait for the operation to complete.
816  */
817  uint32_t timeout;
818 
819  /**
820  * Send request without any further processing.
821  */
823 
824  /**
825  * Ensure the request is within allowable size limits.
826  */
828 
830 
831 /**
832  * Administration Policy
833  *
834  * @ingroup client_policies
835  */
836 typedef struct as_policy_admin_s {
837 
838  /**
839  * Maximum time in milliseconds to wait for the operation to complete.
840  */
841  uint32_t timeout;
842 
844 
845 /**
846  * Struct of all policy values and operation policies.
847  *
848  * This is utilized by as_config to define default values for policies.
849  *
850  * @ingroup as_config_t
851  */
852 typedef struct as_policies_s {
853 
854  /**
855  * The default read policy.
856  */
858 
859  /**
860  * The default write policy.
861  */
863 
864  /**
865  * The default operate policy.
866  */
868 
869  /**
870  * The default remove policy.
871  */
873 
874  /**
875  * The default apply policy.
876  */
878 
879  /**
880  * The default batch policy.
881  */
883 
884  /**
885  * The default scan policy.
886  */
888 
889  /**
890  * The default query policy.
891  */
893 
894  /**
895  * The default info policy.
896  */
898 
899  /**
900  * The default administration policy.
901  */
903 
904 } as_policies;
905 
906 /******************************************************************************
907  * FUNCTIONS
908  *****************************************************************************/
909 
910 /**
911  * Initialize as_policy_read to default values.
912  *
913  * @param p The policy to initialize.
914  * @return The initialized policy.
915  *
916  * @relates as_policy_read
917  */
918 static inline as_policy_read*
920 {
928  p->deserialize = true;
929  return p;
930 }
931 
932 /**
933  * Copy as_policy_read values.
934  *
935  * @param src The source policy.
936  * @param trg The target policy.
937  *
938  * @relates as_policy_read
939  */
940 static inline void
942 {
943  *trg = *src;
944 }
945 
946 /**
947  * Initialize as_policy_write to default values.
948  *
949  * @param p The policy to initialize.
950  * @return The initialized policy.
951  *
952  * @relates as_policy_write
953  */
954 static inline as_policy_write*
956 {
960  p->base.sleep_between_retries = 500;
967  p->durable_delete = false;
968  return p;
969 }
970 
971 /**
972  * Copy as_policy_write values.
973  *
974  * @param src The source policy.
975  * @param trg The target policy.
976  *
977  * @relates as_policy_write
978  */
979 static inline void
981 {
982  *trg = *src;
983 }
984 
985 /**
986  * Initialize as_policy_operate to default values.
987  *
988  * @param p The policy to initialize.
989  * @return The initialized policy.
990  *
991  * @relates as_policy_operate
992  */
993 static inline as_policy_operate*
995 {
999  p->base.sleep_between_retries = 500;
1005  p->deserialize = true;
1006  p->durable_delete = false;
1007  return p;
1008 }
1009 
1010 /**
1011  * Copy as_policy_operate values.
1012  *
1013  * @param src The source policy.
1014  * @param trg The target policy.
1015  *
1016  * @relates as_policy_operate
1017  */
1018 static inline void
1020 {
1021  *trg = *src;
1022 }
1023 
1024 /**
1025  * Initialize as_policy_remove to default values.
1026  *
1027  * @param p The policy to initialize.
1028  * @return The initialized policy.
1029  *
1030  * @relates as_policy_remove
1031  */
1032 static inline as_policy_remove*
1034 {
1038  p->base.sleep_between_retries = 500;
1043  p->generation = 0;
1044  p->durable_delete = false;
1045  return p;
1046 }
1047 
1048 /**
1049  * Copy as_policy_remove values.
1050  *
1051  * @param src The source policy.
1052  * @param trg The target policy.
1053  *
1054  * @relates as_policy_remove
1055  */
1056 static inline void
1058 {
1059  *trg = *src;
1060 }
1061 
1062 /**
1063  * Initialize as_policy_apply to default values.
1064  *
1065  * @param p The policy to initialize.
1066  * @return The initialized policy.
1067  *
1068  * @relates as_policy_apply
1069  */
1070 static inline as_policy_apply*
1072 {
1076  p->base.sleep_between_retries = 500;
1080  p->ttl = 0; // AS_RECORD_DEFAULT_TTL
1082  p->gen_value = 0;
1083  p->durable_delete = false;
1084  return p;
1085 }
1086 
1087 /**
1088  * Copy as_policy_apply values.
1089  *
1090  * @param src The source policy.
1091  * @param trg The target policy.
1092  *
1093  * @relates as_policy_apply
1094  */
1095 static inline void
1097 {
1098  *trg = *src;
1099 }
1100 
1101 /**
1102  * Initialize as_policy_batch to default values.
1103  *
1104  * @param p The policy to initialize.
1105  * @return The initialized policy.
1106  *
1107  * @relates as_policy_batch
1108  */
1109 static inline as_policy_batch*
1111 {
1117  p->concurrent = false;
1118  p->use_batch_direct = false;
1119  p->allow_inline = true;
1120  p->send_set_name = false;
1121  p->deserialize = true;
1122  return p;
1123 }
1124 
1125 /**
1126  * Copy as_policy_batch values.
1127  *
1128  * @param src The source policy.
1129  * @param trg The target policy.
1130  *
1131  * @relates as_policy_batch
1132  */
1133 static inline void
1135 {
1136  *trg = *src;
1137 }
1138 
1139 /**
1140  * Initialize as_policy_scan to default values.
1141  *
1142  * @param p The policy to initialize.
1143  * @return The initialized policy.
1144  *
1145  * @relates as_policy_scan
1146  */
1147 static inline as_policy_scan*
1149 {
1150  p->base.socket_timeout = 10000;
1151  p->base.total_timeout = 0;
1152  p->base.max_retries = 0;
1153  p->base.sleep_between_retries = 0;
1154  p->fail_on_cluster_change = false;
1155  p->durable_delete = false;
1156  return p;
1157 }
1158 
1159 /**
1160  * Copy as_policy_scan values.
1161  *
1162  * @param src The source policy.
1163  * @param trg The target policy.
1164  *
1165  * @relates as_policy_scan
1166  */
1167 static inline void
1169 {
1170  *trg = *src;
1171 }
1172 
1173 /**
1174  * Initialize as_policy_query to default values.
1175  *
1176  * @param p The policy to initialize.
1177  * @return The initialized policy.
1178  *
1179  * @relates as_policy_query
1180  */
1181 static inline as_policy_query*
1183 {
1184  p->base.socket_timeout = 10000;
1185  p->base.total_timeout = 0;
1186  p->base.max_retries = 0;
1187  p->base.sleep_between_retries = 0;
1188  p->deserialize = true;
1189  return p;
1190 }
1191 
1192 /**
1193  * Copy as_policy_query values.
1194  *
1195  * @param src The source policy.
1196  * @param trg The target policy.
1197  *
1198  * @relates as_policy_query
1199  */
1200 static inline void
1202 {
1203  *trg = *src;
1204 }
1205 
1206 /**
1207  * Initialize as_policy_info to default values.
1208  *
1209  * @param p The policy to initialize.
1210  * @return The initialized policy.
1211  *
1212  * @relates as_policy_info
1213  */
1214 static inline as_policy_info*
1216 {
1218  p->send_as_is = true;
1219  p->check_bounds = true;
1220  return p;
1221 }
1222 
1223 /**
1224  * Copy as_policy_info values.
1225  *
1226  * @param src The source policy.
1227  * @param trg The target policy.
1228  *
1229  * @relates as_policy_info
1230  */
1231 static inline void
1233 {
1234  *trg = *src;
1235 }
1236 
1237 /**
1238  * Initialize as_policy_admin to default values.
1239  *
1240  * @param p The policy to initialize.
1241  * @return The initialized policy.
1242  *
1243  * @relates as_policy_admin
1244  */
1245 static inline as_policy_admin*
1247 {
1249  return p;
1250 }
1251 
1252 /**
1253  * Copy as_policy_admin values.
1254  *
1255  * @param src The source policy.
1256  * @param trg The target policy.
1257  *
1258  * @relates as_policy_admin
1259  */
1260 static inline void
1262 {
1263  *trg = *src;
1264 }
1265 
1266 /**
1267  * Initialize as_policies.
1268  *
1269  * @relates as_policies
1270  */
1271 as_policies*
1273 
1274 #ifdef __cplusplus
1275 } // end extern "C"
1276 #endif