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 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 milliseconds to sleep before a command retry.
82  *
83  * @ingroup client_policies
84  */
85 #define AS_POLICY_RETRY_SLEEP_DEFAULT 0
86 
87 /**
88  * Default value for compression threshold
89  *
90  * @ingroup client_policies
91  */
92 #define AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT 0
93 
94 /**
95  * Default as_policy_gen value
96  *
97  * @ingroup client_policies
98  */
99 #define AS_POLICY_GEN_DEFAULT AS_POLICY_GEN_IGNORE
100 
101 /**
102  * Default as_policy_key value
103  *
104  * @ingroup client_policies
105  */
106 #define AS_POLICY_KEY_DEFAULT AS_POLICY_KEY_DIGEST
107 
108 /**
109  * Default as_policy_exists value
110  *
111  * @ingroup client_policies
112  */
113 #define AS_POLICY_EXISTS_DEFAULT AS_POLICY_EXISTS_IGNORE
114 
115 /**
116  * Default as_policy_replica value
117  *
118  * @ingroup client_policies
119  */
120 #define AS_POLICY_REPLICA_DEFAULT AS_POLICY_REPLICA_MASTER
121 
122 /**
123  * Default as_policy_consistency_level value for read
124  *
125  * @ingroup client_policies
126  */
127 #define AS_POLICY_CONSISTENCY_LEVEL_DEFAULT AS_POLICY_CONSISTENCY_LEVEL_ONE
128 
129 /**
130  * Default as_policy_commit_level value for write
131  *
132  * @ingroup client_policies
133  */
134 #define AS_POLICY_COMMIT_LEVEL_DEFAULT AS_POLICY_COMMIT_LEVEL_ALL
135 
136 /******************************************************************************
137  * TYPES
138  *****************************************************************************/
139 
140 /**
141  * Retry Policy
142  *
143  * Specifies the behavior of failed operations.
144  *
145  * @ingroup client_policies
146  */
147 typedef enum as_policy_retry_e {
148 
149  /**
150  * Only attempt an operation once.
151  */
153 
154  /**
155  * If an operation fails, attempt the operation
156  * one more time.
157  */
159 
161 
162 /**
163  * Generation Policy
164  *
165  * Specifies the behavior of record modifications with regard to the
166  * generation value.
167  *
168  * @ingroup client_policies
169  */
170 typedef enum as_policy_gen_e {
171 
172  /**
173  * Write a record, regardless of generation.
174  */
176 
177  /**
178  * Write a record, ONLY if generations are equal
179  */
181 
182  /**
183  * Write a record, ONLY if local generation is
184  * greater-than remote generation
185  */
187 
188 } as_policy_gen;
189 
190 /**
191  * Key Policy
192  *
193  * Specifies the behavior for whether keys or digests
194  * should be sent to the cluster.
195  *
196  * @ingroup client_policies
197  */
198 typedef enum as_policy_key_e {
199 
200  /**
201  * Send the digest value of the key.
202  *
203  * This is the recommended mode of operation. This calculates the digest
204  * and send the digest to the server. The digest is only calculated on
205  * the client, and not on the server.
206  */
208 
209  /**
210  * Send the key, in addition to the digest value.
211  *
212  * If you want keys to be returned when scanning or querying, the keys must
213  * be stored on the server. This policy causes a write operation to store
214  * the key. Once a key is stored, the server will keep it - there is no
215  * need to use this policy on subsequent updates of the record.
216  *
217  * If this policy is used on read or delete operations, or on subsequent
218  * updates of a record with a stored key, the key sent will be compared
219  * with the key stored on the server. A mismatch will cause
220  * AEROSPIKE_ERR_RECORD_KEY_MISMATCH to be returned.
221  */
223 
224 } as_policy_key;
225 
226 /**
227  * Existence Policy
228  *
229  * Specifies the behavior for writing the record
230  * depending whether or not it exists.
231  *
232  * @ingroup client_policies
233  */
234 typedef enum as_policy_exists_e {
235 
236  /**
237  * Write the record, regardless of existence. (i.e. create or update.)
238  */
240 
241  /**
242  * Create a record, ONLY if it doesn't exist.
243  */
245 
246  /**
247  * Update a record, ONLY if it exists.
248  */
250 
251  /**
252  * Completely replace a record, ONLY if it exists.
253  */
255 
256  /**
257  * Completely replace a record if it exists, otherwise create it.
258  */
260 
262 
263 /**
264  * Replica Policy
265  *
266  * Specifies which partition replica to read from.
267  *
268  * @ingroup client_policies
269  */
270 typedef enum as_policy_replica_e {
271 
272  /**
273  * Read from the partition master replica node.
274  */
276 
277  /**
278  * Distribute reads across nodes containing key's master and replicated partition
279  * in round-robin fashion. Currently restricted to master and one prole.
280  */
282 
283  /**
284  * Always try node containing master partition first. If connection fails and
285  * `retry_on_timeout` is true, try node containing prole partition.
286  * Currently restricted to master and one prole.
287  */
289 
291 
292 /**
293  * Consistency Level
294  *
295  * Specifies the number of replicas to be consulted
296  * in a read operation to provide the desired
297  * consistency guarantee.
298  *
299  * @ingroup client_policies
300  */
301 typedef enum as_policy_consistency_level_e {
302 
303  /**
304  * Involve a single replica in the operation.
305  */
307 
308  /**
309  * Involve all replicas in the operation.
310  */
312 
314 
315 /**
316  * Commit Level
317  *
318  * Specifies the number of replicas required to be successfully
319  * committed before returning success in a write operation
320  * to provide the desired consistency guarantee.
321  *
322  * @ingroup client_policies
323  */
324 typedef enum as_policy_commit_level_e {
325 
326  /**
327  * Return succcess only after successfully committing all replicas.
328  */
330 
331  /**
332  * Return succcess after successfully committing the master replica.
333  */
335 
337 
338 /**
339  * Write Policy
340  *
341  * @ingroup client_policies
342  */
343 typedef struct as_policy_write_s {
344 
345  /**
346  * Maximum time in milliseconds to wait for the operation to complete.
347  */
348  uint32_t timeout;
349 
350  /**
351  * Maximum number of retries when a transaction fails due to a network error.
352  * Used by synchronous commands only.
353  * Default: 1
354  */
355  uint32_t retry;
356 
357  /**
358  * Milliseconds to sleep between retries.
359  * Used by synchronous commands only.
360  * Default: 0 (do not sleep)
361  */
363 
364  /**
365  * Minimum record size beyond which it is compressed and sent to the server.
366  */
368 
369  /**
370  * Specifies the behavior for the key.
371  */
373 
374  /**
375  * Specifies the behavior for the generation
376  * value.
377  */
379 
380  /**
381  * Specifies the behavior for the existence
382  * of the record.
383  */
385 
386  /**
387  * Specifies the number of replicas required
388  * to be committed successfully when writing
389  * before returning transaction succeeded.
390  */
392 
393  /**
394  * Should the client retry a command if the timeout is reached.
395  * Used by synchronous commands only.
396  * <p>
397  * Values:
398  * <ul>
399  * <li>
400  * false: Return error when the timeout has been reached. Note that retries can still occur if
401  * a command fails on a network error before the timeout has been reached.
402  * </li>
403  * <li>
404  * true: Retry command with same timeout when the timeout has been reached. The maximum number
405  * of retries is defined by `retry`.
406  * </li>
407  * </ul>
408  * Default: false
409  */
411 
412  /**
413  * If the transaction results in a record deletion, leave a tombstone for the record.
414  * This prevents deleted records from reappearing after node failures.
415  * Valid for Aerospike Server Enterprise Edition only.
416  *
417  * Default: false (do not tombstone deleted records).
418  */
420 
422 
423 /**
424  * Read Policy
425  *
426  * @ingroup client_policies
427  */
428 typedef struct as_policy_read_s {
429 
430  /**
431  * Maximum time in milliseconds to wait for the operation to complete.
432  */
433  uint32_t timeout;
434 
435  /**
436  * Maximum number of retries when a transaction fails due to a network error.
437  * Used by synchronous commands only.
438  * Default: 1
439  */
440  uint32_t retry;
441 
442  /**
443  * Milliseconds to sleep between retries.
444  * Used by synchronous commands only.
445  * Default: 0 (do not sleep)
446  */
448 
449  /**
450  * Specifies the behavior for the key.
451  */
453 
454  /**
455  * Specifies the replica to be consulted for the read.
456  */
458 
459  /**
460  * Specifies the number of replicas consulted
461  * when reading for the desired consistency guarantee.
462  */
464 
465  /**
466  * Should the client retry a command if the timeout is reached.
467  * Used by synchronous commands only.
468  * <p>
469  * Values:
470  * <ul>
471  * <li>
472  * false: Return error when the timeout has been reached. Note that retries can still occur if
473  * a command fails on a network error before the timeout has been reached.
474  * </li>
475  * <li>
476  * true: Retry command with same timeout when the timeout has been reached. The maximum number
477  * of retries is defined by `retry`.
478  * </li>
479  * </ul>
480  * Default: false
481  */
483 
484  /**
485  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
486  * Set to false for backup programs that just need access to raw bytes.
487  * Default: true
488  */
490 
492 
493 /**
494  * Key Apply Policy
495  *
496  * @ingroup client_policies
497  */
498 typedef struct as_policy_apply_s {
499 
500  /**
501  * Maximum time in milliseconds to wait for the operation to complete.
502  */
503  uint32_t timeout;
504 
505  /**
506  * Maximum number of retries when a transaction fails due to a network error.
507  * Used by synchronous commands only.
508  * Default: 1
509  */
510  uint32_t retry;
511 
512  /**
513  * Milliseconds to sleep between retries.
514  * Used by synchronous commands only.
515  * Default: 0 (do not sleep)
516  */
518 
519  /**
520  * Specifies the behavior for the key.
521  */
523 
524  /**
525  * Specifies the number of replicas required
526  * to be committed successfully when writing
527  * before returning transaction succeeded.
528  */
530 
531  /**
532  * The time-to-live (expiration) of the record in seconds.
533  * There are also special values that can be set in the record TTL:
534  * (*) ZERO (defined as AS_RECORD_DEFAULT_TTL), which means that the
535  * record will adopt the default TTL value from the namespace.
536  * (*) 0xFFFFFFFF (also, -1 in a signed 32 bit int)
537  * (defined as AS_RECORD_NO_EXPIRE_TTL), which means that the record
538  * will get an internal "void_time" of zero, and thus will never expire.
539  * (*) 0xFFFFFFFE (also, -2 in a signed 32 bit int)
540  * (defined as AS_RECORD_NO_CHANGE_TTL), which means that the record
541  * ttl will not change when the record is updated.
542  *
543  * Note that the TTL value will be employed ONLY on write/update calls.
544  */
545  uint32_t ttl;
546 
547  /**
548  * Should the client retry a command if the timeout is reached.
549  * Used by synchronous commands only.
550  * <p>
551  * Values:
552  * <ul>
553  * <li>
554  * false: Return error when the timeout has been reached. Note that retries can still occur if
555  * a command fails on a network error before the timeout has been reached.
556  * </li>
557  * <li>
558  * true: Retry command with same timeout when the timeout has been reached. The maximum number
559  * of retries is defined by `retry`.
560  * </li>
561  * </ul>
562  * Default: false
563  */
565 
566  /**
567  * If the transaction results in a record deletion, leave a tombstone for the record.
568  * This prevents deleted records from reappearing after node failures.
569  * Valid for Aerospike Server Enterprise Edition only.
570  *
571  * Default: false (do not tombstone deleted records).
572  */
574 
576 
577 /**
578  * Operate Policy
579  *
580  * @ingroup client_policies
581  */
582 typedef struct as_policy_operate_s {
583 
584  /**
585  * Maximum time in milliseconds to wait for the operation to complete.
586  */
587  uint32_t timeout;
588 
589  /**
590  * Maximum number of retries when a transaction fails due to a network error.
591  * Used by synchronous commands only.
592  * Default: 1
593  */
594  uint32_t retry;
595 
596  /**
597  * Milliseconds to sleep between retries.
598  * Used by synchronous commands only.
599  * Default: 0 (do not sleep)
600  */
602 
603  /**
604  * Specifies the behavior for the key.
605  */
607 
608  /**
609  * Specifies the behavior for the generation
610  * value.
611  */
613 
614  /**
615  * Specifies the replica to be consulted for the read.
616  */
618 
619  /**
620  * Specifies the number of replicas consulted
621  * when reading for the desired consistency guarantee.
622  */
624 
625  /**
626  * Specifies the number of replicas required
627  * to be committed successfully when writing
628  * before returning transaction succeeded.
629  */
631 
632  /**
633  * Should the client retry a command if the timeout is reached.
634  * Used by synchronous commands only.
635  * <p>
636  * Values:
637  * <ul>
638  * <li>
639  * false: Return error when the timeout has been reached. Note that retries can still occur if
640  * a command fails on a network error before the timeout has been reached.
641  * </li>
642  * <li>
643  * true: Retry command with same timeout when the timeout has been reached. The maximum number
644  * of retries is defined by `retry`.
645  * </li>
646  * </ul>
647  * Default: false
648  */
650 
651  /**
652  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
653  * Set to false for backup programs that just need access to raw bytes.
654  * Default: true
655  */
657 
658  /**
659  * If the transaction results in a record deletion, leave a tombstone for the record.
660  * This prevents deleted records from reappearing after node failures.
661  * Valid for Aerospike Server Enterprise Edition only.
662  *
663  * Default: false (do not tombstone deleted records).
664  */
666 
668 
669 /**
670  * Remove Policy
671  *
672  * @ingroup client_policies
673  */
674 typedef struct as_policy_remove_s {
675 
676  /**
677  * Maximum time in milliseconds to wait for the operation to complete.
678  */
679  uint32_t timeout;
680 
681  /**
682  * Maximum number of retries when a transaction fails due to a network error.
683  * Used by synchronous commands only.
684  * Default: 1
685  */
686  uint32_t retry;
687 
688  /**
689  * Milliseconds to sleep between retries.
690  * Used by synchronous commands only.
691  * Default: 0 (do not sleep)
692  */
694 
695  /**
696  * Specifies the behavior for the key.
697  */
699 
700  /**
701  * Specifies the behavior for the generation
702  * value.
703  */
705 
706  /**
707  * Specifies the number of replicas required
708  * to be committed successfully when writing
709  * before returning transaction succeeded.
710  */
712 
713  /**
714  * The generation of the record.
715  */
716  uint16_t generation;
717 
718  /**
719  * Should the client retry a command if the timeout is reached.
720  * Used by synchronous commands only.
721  * <p>
722  * Values:
723  * <ul>
724  * <li>
725  * false: Return error when the timeout has been reached. Note that retries can still occur if
726  * a command fails on a network error before the timeout has been reached.
727  * </li>
728  * <li>
729  * true: Retry command with same timeout when the timeout has been reached. The maximum number
730  * of retries is defined by `retry`.
731  * </li>
732  * </ul>
733  * Default: false
734  */
736 
737  /**
738  * If the transaction results in a record deletion, leave a tombstone for the record.
739  * This prevents deleted records from reappearing after node failures.
740  * Valid for Aerospike Server Enterprise Edition only.
741  *
742  * Default: false (do not tombstone deleted records).
743  */
745 
747 
748 /**
749  * Query Policy
750  *
751  * @ingroup client_policies
752  */
753 typedef struct as_policy_query_s {
754 
755  /**
756  * Maximum time in milliseconds to wait for
757  * the operation to complete.
758  *
759  * The default (0) means do not timeout.
760  */
761  uint32_t timeout;
762 
763  /**
764  * Should raw bytes representing a list or map be deserialized to as_list or as_map.
765  * Set to false for backup programs that just need access to raw bytes.
766  * Default: true
767  */
769 
771 
772 /**
773  * Scan Policy
774  *
775  * @ingroup client_policies
776  */
777 typedef struct as_policy_scan_s {
778 
779  /**
780  * Maximum time in milliseconds to wait for the operation to complete.
781  *
782  * The default (0) means do not timeout.
783  */
784  uint32_t timeout;
785 
786  /**
787  * Maximum time in milliseconds to wait when polling socket for availability prior to
788  * performing an operation on the socket on the server side. Zero means there is no
789  * socket timeout.
790  *
791  * Default: 10000 ms
792  */
793  uint32_t socket_timeout;
794 
795  /**
796  * Abort the scan if the cluster is not in a
797  * stable state.
798  */
800 
801  /**
802  * If the scan runs a UDF which results in a record deletion, leave a tombstone for the record.
803  * This prevents deleted records from reappearing after node failures.
804  * Valid for Aerospike Server Enterprise Edition only.
805  *
806  * Default: false (do not tombstone deleted records).
807  */
809 
811 
812 /**
813  * Info Policy
814  *
815  * @ingroup client_policies
816  */
817 typedef struct as_policy_info_s {
818 
819  /**
820  * Maximum time in milliseconds to wait for
821  * the operation to complete.
822  */
823  uint32_t timeout;
824 
825  /**
826  * Send request without any further processing.
827  */
829 
830  /**
831  * Ensure the request is within allowable size limits.
832  */
834 
836 
837 /**
838  * Batch Policy
839  *
840  * @ingroup client_policies
841  */
842 typedef struct as_policy_batch_s {
843 
844  /**
845  * Maximum time in milliseconds to wait for the operation to complete.
846  */
847  uint32_t timeout;
848 
849  /**
850  * Maximum number of retries when a transaction fails due to a network error.
851  * Used by synchronous commands only.
852  * Default: 1
853  */
854  uint32_t retry;
855 
856  /**
857  * Milliseconds to sleep between retries.
858  * Used by synchronous commands only.
859  * Default: 0 (do not sleep)
860  */
862 
863  /**
864  * Specifies the number of replicas consulted
865  * when reading for the desired consistency guarantee.
866  */
868 
869  /**
870  * Should the client retry a command if the timeout is reached.
871  * Used by synchronous commands only.
872  * <p>
873  * Values:
874  * <ul>
875  * <li>
876  * false: Return error when the timeout has been reached. Note that retries can still occur if
877  * a command fails on a network error before the timeout has been reached.
878  * </li>
879  * <li>
880  * true: Retry command with same timeout when the timeout has been reached. The maximum number
881  * of retries is defined by `retry`.
882  * </li>
883  * </ul>
884  * Default: false
885  */
887 
888  /**
889  * Determine if batch commands to each server are run in parallel threads.
890  * <p>
891  * Values:
892  * <ul>
893  * <li>
894  * false: Issue batch commands sequentially. This mode has a performance advantage for small
895  * to medium sized batch sizes because commands can be issued in the main transaction thread.
896  * This is the default.
897  * </li>
898  * <li>
899  * true: Issue batch commands in parallel threads. This mode has a performance
900  * advantage for large batch sizes because each node can process the command immediately.
901  * The downside is extra threads will need to be created (or taken from
902  * a thread pool).
903  * </li>
904  * </ul>
905  */
907 
908  /**
909  * Use old batch direct protocol where batch reads are handled by direct low-level batch server
910  * database routines. The batch direct protocol can be faster when there is a single namespace,
911  * but there is one important drawback. The batch direct protocol will not proxy to a different
912  * server node when the mapped node has migrated a record to another node (resulting in not
913  * found record).
914  * <p>
915  * This can happen after a node has been added/removed from the cluster and there is a lag
916  * between records being migrated and client partition map update (once per second).
917  * <p>
918  * The new batch index protocol will perform this record proxy when necessary.
919  * Default: false (use new batch index protocol if server supports it)
920  */
922 
923  /**
924  * Allow batch to be processed immediately in the server's receiving thread when the server
925  * deems it to be appropriate. If false, the batch will always be processed in separate
926  * transaction threads. This field is only relevant for the new batch index protocol.
927  * <p>
928  * For batch exists or batch reads of smaller sized records (<= 1K per record), inline
929  * processing will be significantly faster on "in memory" namespaces. The server disables
930  * inline processing on disk based namespaces regardless of this policy field.
931  * <p>
932  * Inline processing can introduce the possibility of unfairness because the server
933  * can process the entire batch before moving onto the next command.
934  * Default: true
935  */
937 
938  /**
939  * Send set name field to server for every key in the batch for batch index protocol.
940  * This is only necessary when authentication is enabled and security roles are defined
941  * on a per set basis.
942  * Default: false
943  */
945 
946  /**
947  * Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
948  * just need access to raw bytes.
949  * Default: true
950  */
952 
954 
955 /**
956  * Administration Policy
957  *
958  * @ingroup client_policies
959  */
960 typedef struct as_policy_admin_s {
961 
962  /**
963  * Maximum time in milliseconds to wait for
964  * the operation to complete.
965  */
966  uint32_t timeout;
967 
969 
970 /**
971  * Struct of all policy values and operation policies.
972  *
973  * This is utilizes by as_config, to define global and default values
974  * for policies.
975  *
976  * @ingroup as_config_t
977  */
978 typedef struct as_policies_s {
979 
980  /***************************************************************************
981  * DEFAULT VALUES, IF SPECIFIC POLICY IS UNDEFINED
982  **************************************************************************/
983 
984  /**
985  * Default timeout in milliseconds.
986  *
987  * Default: `AS_POLICY_TIMEOUT_DEFAULT`
988  */
989  uint32_t timeout;
990 
991  /**
992  * Default maximum number of retries when a transaction fails due to a network error.
993  *
994  * Default: `AS_POLICY_RETRY_DEFAULT`
995  */
996  uint32_t retry;
997 
998  /**
999  * Default milliseconds to sleep between retries.
1000  *
1001  * Default: `AS_POLICY_RETRY_SLEEP_DEFAULT`
1002  */
1004 
1005  /**
1006  * Specifies the behavior for the key.
1007  *
1008  * Default: `AS_POLICY_KEY_DEFAULT`
1009  */
1011 
1012  /**
1013  * Specifies the behavior for the generation
1014  * value.
1015  *
1016  * Default: `AS_POLICY_GEN_DEFAULT`
1017  */
1019 
1020  /**
1021  * Specifies the behavior for the existence
1022  * of the record.
1023  *
1024  * Default: `AS_POLICY_EXISTS_DEFAULT`
1025  */
1027 
1028  /**
1029  * Specifies which replica to read.
1030  *
1031  * Default: `AS_POLICY_REPLICA_MASTER`
1032  */
1034 
1035  /**
1036  * Specifies the consistency level for reading.
1037  *
1038  * Default: `AS_POLICY_CONSISTENCY_LEVEL_ONE`
1039  */
1041 
1042  /**
1043  * Specifies the commit level for writing.
1044  *
1045  * Default: `AS_POLICY_COMMIT_LEVEL_ALL`
1046  */
1048 
1049  /***************************************************************************
1050  * SPECIFIC POLICIES
1051  **************************************************************************/
1052 
1053  /**
1054  * The default read policy.
1055  */
1057 
1058  /**
1059  * The default write policy.
1060  */
1062 
1063  /**
1064  * The default operate policy.
1065  */
1067 
1068  /**
1069  * The default remove policy.
1070  */
1072 
1073  /**
1074  * The default apply policy.
1075  */
1077 
1078  /**
1079  * The default query policy.
1080  */
1082 
1083  /**
1084  * The default scan policy.
1085  */
1087 
1088  /**
1089  * The default info policy.
1090  */
1092 
1093  /**
1094  * The default batch policy.
1095  */
1097 
1098  /**
1099  * The default administration policy.
1100  */
1102 
1103 } as_policies;
1104 
1105 /******************************************************************************
1106  * FUNCTIONS
1107  *****************************************************************************/
1108 
1109 /**
1110  * Initialize as_policy_read to default values.
1111  *
1112  * @param p The policy to initialize.
1113  * @return The initialized policy.
1114  *
1115  * @relates as_policy_read
1116  */
1117 static inline as_policy_read*
1119 {
1126  p->retry_on_timeout = false;
1127  p->deserialize = true;
1128  return p;
1129 }
1130 
1131 /**
1132  * Copy as_policy_read values.
1133  *
1134  * @param src The source policy.
1135  * @param trg The target policy.
1136  *
1137  * @relates as_policy_read
1138  */
1139 static inline void
1141 {
1142  *trg = *src;
1143 }
1144 
1145 /**
1146  * Initialize as_policy_write to default values.
1147  *
1148  * @param p The policy to initialize.
1149  * @return The initialized policy.
1150  *
1151  * @relates as_policy_write
1152  */
1153 static inline as_policy_write*
1155 {
1164  p->retry_on_timeout = false;
1165  p->durable_delete = false;
1166  return p;
1167 }
1168 
1169 /**
1170  * Copy as_policy_write values.
1171  *
1172  * @param src The source policy.
1173  * @param trg The target policy.
1174  *
1175  * @relates as_policy_write
1176  */
1177 static inline void
1179 {
1180  *trg = *src;
1181 }
1182 
1183 /**
1184  * Initialize as_policy_operate to default values.
1185  *
1186  * @param p The policy to initialize.
1187  * @return The initialized policy.
1188  *
1189  * @relates as_policy_operate
1190  */
1191 static inline as_policy_operate*
1193 {
1202  p->retry_on_timeout = false;
1203  p->deserialize = true;
1204  p->durable_delete = false;
1205  return p;
1206 }
1207 
1208 /**
1209  * Copy as_policy_operate values.
1210  *
1211  * @param src The source policy.
1212  * @param trg The target policy.
1213  *
1214  * @relates as_policy_operate
1215  */
1216 static inline void
1218 {
1219  *trg = *src;
1220 }
1221 
1222 /**
1223  * Initialize as_policy_remove to default values.
1224  *
1225  * @param p The policy to initialize.
1226  * @return The initialized policy.
1227  *
1228  * @relates as_policy_remove
1229  */
1230 static inline as_policy_remove*
1232 {
1239  p->generation = 0;
1240  p->retry_on_timeout = false;
1241  p->durable_delete = false;
1242  return p;
1243 }
1244 
1245 /**
1246  * Copy as_policy_remove values.
1247  *
1248  * @param src The source policy.
1249  * @param trg The target policy.
1250  *
1251  * @relates as_policy_remove
1252  */
1253 static inline void
1255 {
1256  *trg = *src;
1257 }
1258 
1259 /**
1260  * Initialize as_policy_apply to default values.
1261  *
1262  * @param p The policy to initialize.
1263  * @return The initialized policy.
1264  *
1265  * @relates as_policy_apply
1266  */
1267 static inline as_policy_apply*
1269 {
1275  p->ttl = 0; // AS_RECORD_DEFAULT_TTL
1276  p->retry_on_timeout = false;
1277  p->durable_delete = false;
1278  return p;
1279 }
1280 
1281 /**
1282  * Copy as_policy_apply values.
1283  *
1284  * @param src The source policy.
1285  * @param trg The target policy.
1286  *
1287  * @relates as_policy_apply
1288  */
1289 static inline void
1291 {
1292  *trg = *src;
1293 }
1294 
1295 /**
1296  * Initialize as_policy_info to default values.
1297  *
1298  * @param p The policy to initialize.
1299  * @return The initialized policy.
1300  *
1301  * @relates as_policy_info
1302  */
1303 static inline as_policy_info*
1305 {
1307  p->send_as_is = true;
1308  p->check_bounds = true;
1309  return p;
1310 }
1311 
1312 /**
1313  * Copy as_policy_info values.
1314  *
1315  * @param src The source policy.
1316  * @param trg The target policy.
1317  *
1318  * @relates as_policy_info
1319  */
1320 static inline void
1322 {
1323  *trg = *src;
1324 }
1325 
1326 /**
1327  * Initialize as_policy_batch to default values.
1328  *
1329  * @param p The policy to initialize.
1330  * @return The initialized policy.
1331  *
1332  * @relates as_policy_batch
1333  */
1334 static inline as_policy_batch*
1336 {
1341  p->retry_on_timeout = false;
1342  p->concurrent = false;
1343  p->use_batch_direct = false;
1344  p->allow_inline = true;
1345  p->send_set_name = false;
1346  p->deserialize = true;
1347  return p;
1348 }
1349 
1350 /**
1351  * Copy as_policy_batch values.
1352  *
1353  * @param src The source policy.
1354  * @param trg The target policy.
1355  *
1356  * @relates as_policy_batch
1357  */
1358 static inline void
1360 {
1361  *trg = *src;
1362 }
1363 
1364 /**
1365  * Initialize as_policy_admin to default values.
1366  *
1367  * @param p The policy to initialize.
1368  * @return The initialized policy.
1369  *
1370  * @relates as_policy_admin
1371  */
1372 static inline as_policy_admin*
1374 {
1376  return p;
1377 }
1378 
1379 /**
1380  * Copy as_policy_admin values.
1381  *
1382  * @param src The source policy.
1383  * @param trg The target policy.
1384  *
1385  * @relates as_policy_admin
1386  */
1387 static inline void
1389 {
1390  *trg = *src;
1391 }
1392 
1393 /**
1394  * Initialize as_policy_scan to default values.
1395  *
1396  * @param p The policy to initialize.
1397  * @return The initialized policy.
1398  *
1399  * @relates as_policy_scan
1400  */
1401 static inline as_policy_scan*
1403 {
1404  p->timeout = 0;
1405  p->socket_timeout = 10000;
1406  p->fail_on_cluster_change = false;
1407  p->durable_delete = false;
1408  return p;
1409 }
1410 
1411 /**
1412  * Copy as_policy_scan values.
1413  *
1414  * @param src The source policy.
1415  * @param trg The target policy.
1416  *
1417  * @relates as_policy_scan
1418  */
1419 static inline void
1421 {
1422  *trg = *src;
1423 }
1424 
1425 /**
1426  * Initialize as_policy_query to default values.
1427  *
1428  * @param p The policy to initialize.
1429  * @return The initialized policy.
1430  *
1431  * @relates as_policy_query
1432  */
1433 static inline as_policy_query*
1435 {
1436  p->timeout = 0;
1437  p->deserialize = true;
1438  return p;
1439 }
1440 
1441 /**
1442  * Copy as_policy_query values.
1443  *
1444  * @param src The source policy.
1445  * @param trg The target policy.
1446  *
1447  * @relates as_policy_query
1448  */
1449 static inline void
1451 {
1452  *trg = *src;
1453 }
1454 
1455 /**
1456  * Initialize as_policies to undefined values.
1457  * as_policies_resolve() will later be called resolve undefined values to global defaults.
1458  *
1459  * @param p The policies to undefine
1460  * @return The undefined policies.
1461  *
1462  * @relates as_policies
1463  */
1464 as_policies*
1466 
1467 /**
1468  * Resolve global policies (like timeout) with operational policies (like as_policy_read).
1469  *
1470  * @param p The policies to resolve
1471  *
1472  * @relates as_policies
1473  */
1474 void
1476 
1477 #ifdef __cplusplus
1478 } // end extern "C"
1479 #endif
static as_policy_batch * as_policy_batch_init(as_policy_batch *p)
Definition: as_policy.h:1335
static as_policy_operate * as_policy_operate_init(as_policy_operate *p)
Definition: as_policy.h:1192
uint32_t socket_timeout
Definition: as_policy.h:793
bool fail_on_cluster_change
Definition: as_policy.h:799
uint32_t retry
Definition: as_policy.h:355
as_policy_key
Definition: as_policy.h:198
static as_policy_apply * as_policy_apply_init(as_policy_apply *p)
Definition: as_policy.h:1268
uint32_t timeout
Definition: as_policy.h:503
static as_policy_query * as_policy_query_init(as_policy_query *p)
Definition: as_policy.h:1434
as_policy_replica
Definition: as_policy.h:270
as_policy_scan scan
Definition: as_policy.h:1086
as_policy_replica replica
Definition: as_policy.h:457
as_policy_consistency_level
Definition: as_policy.h:301
static as_policy_info * as_policy_info_init(as_policy_info *p)
Definition: as_policy.h:1304
as_policy_commit_level commit_level
Definition: as_policy.h:711
bool deserialize
Definition: as_policy.h:489
uint32_t sleep_between_retries
Definition: as_policy.h:601
as_policy_consistency_level consistency_level
Definition: as_policy.h:463
as_policy_admin admin
Definition: as_policy.h:1101
as_policy_commit_level
Definition: as_policy.h:324
as_policy_key key
Definition: as_policy.h:452
as_policy_gen gen
Definition: as_policy.h:704
uint32_t sleep_between_retries
Definition: as_policy.h:1003
as_policy_gen
Definition: as_policy.h:170
as_policy_retry
Definition: as_policy.h:147
as_policy_key key
Definition: as_policy.h:698
as_policy_commit_level commit_level
Definition: as_policy.h:630
#define AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT
Definition: as_policy.h:92
static void as_policy_write_copy(as_policy_write *src, as_policy_write *trg)
Definition: as_policy.h:1178
uint32_t timeout
Definition: as_policy.h:966
uint32_t retry
Definition: as_policy.h:510
bool check_bounds
Definition: as_policy.h:833
static void as_policy_query_copy(as_policy_query *src, as_policy_query *trg)
Definition: as_policy.h:1450
static as_policy_read * as_policy_read_init(as_policy_read *p)
Definition: as_policy.h:1118
as_policy_key key
Definition: as_policy.h:606
uint32_t sleep_between_retries
Definition: as_policy.h:517
uint32_t timeout
Definition: as_policy.h:847
#define AS_POLICY_RETRY_SLEEP_DEFAULT
Definition: as_policy.h:85
bool retry_on_timeout
Definition: as_policy.h:564
as_policy_exists
Definition: as_policy.h:234
uint32_t timeout
Definition: as_policy.h:761
as_policy_info info
Definition: as_policy.h:1091
bool retry_on_timeout
Definition: as_policy.h:735
uint32_t compression_threshold
Definition: as_policy.h:367
as_policy_write write
Definition: as_policy.h:1061
bool retry_on_timeout
Definition: as_policy.h:886
static void as_policy_apply_copy(as_policy_apply *src, as_policy_apply *trg)
Definition: as_policy.h:1290
static void as_policy_operate_copy(as_policy_operate *src, as_policy_operate *trg)
Definition: as_policy.h:1217
as_policy_apply apply
Definition: as_policy.h:1076
uint32_t timeout
Definition: as_policy.h:823
uint32_t timeout
Definition: as_policy.h:348
#define AS_POLICY_REPLICA_DEFAULT
Definition: as_policy.h:120
static as_policy_remove * as_policy_remove_init(as_policy_remove *p)
Definition: as_policy.h:1231
#define AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
Definition: as_policy.h:127
uint32_t ttl
Definition: as_policy.h:545
uint32_t timeout
Definition: as_policy.h:433
as_policy_query query
Definition: as_policy.h:1081
uint32_t retry
Definition: as_policy.h:686
#define AS_POLICY_RETRY_DEFAULT
Definition: as_policy.h:78
as_policy_operate operate
Definition: as_policy.h:1066
uint32_t retry
Definition: as_policy.h:996
static void as_policy_read_copy(as_policy_read *src, as_policy_read *trg)
Definition: as_policy.h:1140
bool durable_delete
Definition: as_policy.h:419
static as_policy_admin * as_policy_admin_init(as_policy_admin *p)
Definition: as_policy.h:1373
uint32_t sleep_between_retries
Definition: as_policy.h:447
void as_policies_resolve(as_policies *p)
#define AS_POLICY_KEY_DEFAULT
Definition: as_policy.h:106
uint32_t retry
Definition: as_policy.h:594
as_policies * as_policies_init(as_policies *p)
bool durable_delete
Definition: as_policy.h:573
bool retry_on_timeout
Definition: as_policy.h:410
as_policy_replica replica
Definition: as_policy.h:1033
as_policy_key key
Definition: as_policy.h:1010
as_policy_consistency_level consistency_level
Definition: as_policy.h:867
as_policy_key key
Definition: as_policy.h:522
uint32_t timeout
Definition: as_policy.h:989
bool durable_delete
Definition: as_policy.h:808
as_policy_gen gen
Definition: as_policy.h:1018
#define AS_POLICY_GEN_DEFAULT
Definition: as_policy.h:99
as_policy_gen gen
Definition: as_policy.h:612
as_policy_commit_level commit_level
Definition: as_policy.h:1047
bool send_set_name
Definition: as_policy.h:944
static void as_policy_admin_copy(as_policy_admin *src, as_policy_admin *trg)
Definition: as_policy.h:1388
uint32_t timeout
Definition: as_policy.h:679
as_policy_read read
Definition: as_policy.h:1056
as_policy_exists exists
Definition: as_policy.h:1026
uint32_t retry
Definition: as_policy.h:854
static void as_policy_info_copy(as_policy_info *src, as_policy_info *trg)
Definition: as_policy.h:1321
as_policy_batch batch
Definition: as_policy.h:1096
uint32_t timeout
Definition: as_policy.h:784
uint32_t retry
Definition: as_policy.h:440
#define AS_POLICY_TIMEOUT_DEFAULT
Definition: as_policy.h:71
as_policy_consistency_level consistency_level
Definition: as_policy.h:1040
#define AS_POLICY_EXISTS_DEFAULT
Definition: as_policy.h:113
as_policy_exists exists
Definition: as_policy.h:384
static void as_policy_scan_copy(as_policy_scan *src, as_policy_scan *trg)
Definition: as_policy.h:1420
uint32_t timeout
Definition: as_policy.h:587
uint32_t sleep_between_retries
Definition: as_policy.h:861
#define AS_POLICY_COMMIT_LEVEL_DEFAULT
Definition: as_policy.h:134
static void as_policy_batch_copy(as_policy_batch *src, as_policy_batch *trg)
Definition: as_policy.h:1359
as_policy_key key
Definition: as_policy.h:372
as_policy_commit_level commit_level
Definition: as_policy.h:391
static as_policy_scan * as_policy_scan_init(as_policy_scan *p)
Definition: as_policy.h:1402
static void as_policy_remove_copy(as_policy_remove *src, as_policy_remove *trg)
Definition: as_policy.h:1254
bool retry_on_timeout
Definition: as_policy.h:482
static as_policy_write * as_policy_write_init(as_policy_write *p)
Definition: as_policy.h:1154
as_policy_consistency_level consistency_level
Definition: as_policy.h:623
uint32_t sleep_between_retries
Definition: as_policy.h:693
uint32_t sleep_between_retries
Definition: as_policy.h:362
as_policy_gen gen
Definition: as_policy.h:378
bool use_batch_direct
Definition: as_policy.h:921
as_policy_commit_level commit_level
Definition: as_policy.h:529
as_policy_replica replica
Definition: as_policy.h:617
uint16_t generation
Definition: as_policy.h:716