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