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
* Send set name field to server for every key in the batch for batch index protocol.
690
* This is only necessary when authentication is enabled and security roles are defined
691
* on a per set basis.
692
* Default: false
693
*/
694
bool
send_set_name
;
695
696
/**
697
* Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
698
* just need access to raw bytes.
699
* Default: true
700
*/
701
bool
deserialize
;
702
703
}
as_policy_batch
;
704
705
/**
706
* Administration Policy
707
*
708
* @ingroup client_policies
709
*/
710
typedef
struct
as_policy_admin_s {
711
712
/**
713
* Maximum time in milliseconds to wait for
714
* the operation to complete.
715
*/
716
uint32_t
timeout
;
717
718
}
as_policy_admin
;
719
720
/**
721
* Struct of all policy values and operation policies.
722
*
723
* This is utilizes by as_config, to define global and default values
724
* for policies.
725
*
726
* @ingroup as_config_t
727
*/
728
typedef
struct
as_policies_s {
729
730
/***************************************************************************
731
* DEFAULT VALUES, IF SPECIFIC POLICY IS UNDEFINED
732
**************************************************************************/
733
734
/**
735
* Default timeout in milliseconds.
736
*
737
* Will be used if specific policies have a timeout of 0 (zero).
738
*
739
* The default value is `AS_POLICY_TIMEOUT_DEFAULT`.
740
*/
741
uint32_t
timeout
;
742
743
/**
744
* Maximum number of retries when a transaction fails due to a network error.
745
*
746
* The default value is `AS_POLICY_RETRY_DEFAULT`.
747
*/
748
uint32_t
retry
;
749
750
/**
751
* Specifies the behavior for the key.
752
*
753
* The default value is `AS_POLICY_KEY_DEFAULT`.
754
*/
755
as_policy_key
key
;
756
757
/**
758
* Specifies the behavior for the generation
759
* value.
760
*
761
* The default value is `AS_POLICY_GEN_DEFAULT`.
762
*/
763
as_policy_gen
gen
;
764
765
/**
766
* Specifies the behavior for the existence
767
* of the record.
768
*
769
* The default value is `AS_POLICY_EXISTS_DEFAULT`.
770
*/
771
as_policy_exists
exists
;
772
773
/**
774
* Specifies which replica to read.
775
*
776
* The default value is `AS_POLICY_REPLICA_MASTER`.
777
*/
778
as_policy_replica
replica
;
779
780
/**
781
* Specifies the consistency level for reading.
782
*
783
* The default value is `AS_POLICY_CONSISTENCY_LEVEL_ONE`.
784
*/
785
as_policy_consistency_level
consistency_level
;
786
787
/**
788
* Specifies the commit level for writing.
789
*
790
* The default value is `AS_POLICY_COMMIT_LEVEL_ALL`.
791
*/
792
as_policy_commit_level
commit_level
;
793
794
/***************************************************************************
795
* SPECIFIC POLICIES
796
**************************************************************************/
797
798
/**
799
* The default read policy.
800
*/
801
as_policy_read
read
;
802
803
/**
804
* The default write policy.
805
*/
806
as_policy_write
write
;
807
808
/**
809
* The default operate policy.
810
*/
811
as_policy_operate
operate
;
812
813
/**
814
* The default remove policy.
815
*/
816
as_policy_remove
remove
;
817
818
/**
819
* The default apply policy.
820
*/
821
as_policy_apply
apply
;
822
823
/**
824
* The default query policy.
825
*/
826
as_policy_query
query
;
827
828
/**
829
* The default scan policy.
830
*/
831
as_policy_scan
scan
;
832
833
/**
834
* The default info policy.
835
*/
836
as_policy_info
info
;
837
838
/**
839
* The default batch policy.
840
*/
841
as_policy_batch
batch
;
842
843
/**
844
* The default administration policy.
845
*/
846
as_policy_admin
admin
;
847
848
}
as_policies
;
849
850
/******************************************************************************
851
* FUNCTIONS
852
*****************************************************************************/
853
854
/**
855
* Initialize as_policy_read to default values.
856
*
857
* @param p The policy to initialize.
858
* @return The initialized policy.
859
*
860
* @relates as_policy_read
861
*/
862
static
inline
as_policy_read
*
863
as_policy_read_init
(
as_policy_read
* p)
864
{
865
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
866
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
867
p->
key
=
AS_POLICY_KEY_DEFAULT
;
868
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
869
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
870
p->
deserialize
=
true
;
871
return
p;
872
}
873
874
/**
875
* Copy as_policy_read values.
876
*
877
* @param src The source policy.
878
* @param trg The target policy.
879
*
880
* @relates as_policy_read
881
*/
882
static
inline
void
883
as_policy_read_copy
(
as_policy_read
* src,
as_policy_read
* trg)
884
{
885
trg->
timeout
= src->
timeout
;
886
trg->
retry
= src->
retry
;
887
trg->
key
= src->
key
;
888
trg->
replica
= src->
replica
;
889
trg->
consistency_level
= src->
consistency_level
;
890
trg->
deserialize
= src->
deserialize
;
891
}
892
893
/**
894
* Initialize as_policy_write to default values.
895
*
896
* @param p The policy to initialize.
897
* @return The initialized policy.
898
*
899
* @relates as_policy_write
900
*/
901
static
inline
as_policy_write
*
902
as_policy_write_init
(
as_policy_write
* p)
903
{
904
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
905
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
906
p->
compression_threshold
=
AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT
;
907
p->
key
=
AS_POLICY_KEY_DEFAULT
;
908
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
909
p->
exists
=
AS_POLICY_EXISTS_DEFAULT
;
910
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
911
return
p;
912
}
913
914
/**
915
* Copy as_policy_write values.
916
*
917
* @param src The source policy.
918
* @param trg The target policy.
919
*
920
* @relates as_policy_write
921
*/
922
static
inline
void
923
as_policy_write_copy
(
as_policy_write
* src,
as_policy_write
* trg)
924
{
925
trg->
timeout
= src->
timeout
;
926
trg->
retry
= src->
retry
;
927
trg->
compression_threshold
= src->
compression_threshold
;
928
trg->
key
= src->
key
;
929
trg->
gen
= src->
gen
;
930
trg->
exists
= src->
exists
;
931
trg->
commit_level
= src->
commit_level
;
932
}
933
934
/**
935
* Initialize as_policy_operate to default values.
936
*
937
* @param p The policy to initialize.
938
* @return The initialized policy.
939
*
940
* @relates as_policy_operate
941
*/
942
static
inline
as_policy_operate
*
943
as_policy_operate_init
(
as_policy_operate
* p)
944
{
945
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
946
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
947
p->
key
=
AS_POLICY_KEY_DEFAULT
;
948
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
949
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
950
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
951
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
952
p->
deserialize
=
true
;
953
return
p;
954
}
955
956
/**
957
* Copy as_policy_operate values.
958
*
959
* @param src The source policy.
960
* @param trg The target policy.
961
*
962
* @relates as_policy_operate
963
*/
964
static
inline
void
965
as_policy_operate_copy
(
as_policy_operate
* src,
as_policy_operate
* trg)
966
{
967
trg->
timeout
= src->
timeout
;
968
trg->
retry
= src->
retry
;
969
trg->
key
= src->
key
;
970
trg->
gen
= src->
gen
;
971
trg->
replica
= src->
replica
;
972
trg->
consistency_level
= src->
consistency_level
;
973
trg->
commit_level
= src->
commit_level
;
974
trg->
deserialize
= src->
deserialize
;
975
}
976
977
/**
978
* Initialize as_policy_remove to default values.
979
*
980
* @param p The policy to initialize.
981
* @return The initialized policy.
982
*
983
* @relates as_policy_remove
984
*/
985
static
inline
as_policy_remove
*
986
as_policy_remove_init
(
as_policy_remove
* p)
987
{
988
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
989
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
990
p->
key
=
AS_POLICY_KEY_DEFAULT
;
991
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
992
p->
generation
= 0;
993
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
994
return
p;
995
}
996
997
/**
998
* Copy as_policy_remove values.
999
*
1000
* @param src The source policy.
1001
* @param trg The target policy.
1002
*
1003
* @relates as_policy_remove
1004
*/
1005
static
inline
void
1006
as_policy_remove_copy
(
as_policy_remove
* src,
as_policy_remove
* trg)
1007
{
1008
trg->
timeout
= src->
timeout
;
1009
trg->
retry
= src->
retry
;
1010
trg->
key
= src->
key
;
1011
trg->
gen
= src->
gen
;
1012
trg->
generation
= src->
generation
;
1013
trg->
commit_level
= src->
commit_level
;
1014
}
1015
1016
/**
1017
* Initialize as_policy_apply to default values.
1018
*
1019
* @param p The policy to initialize.
1020
* @return The initialized policy.
1021
*
1022
* @relates as_policy_apply
1023
*/
1024
static
inline
as_policy_apply
*
1025
as_policy_apply_init
(
as_policy_apply
* p)
1026
{
1027
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1028
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1029
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1030
p->
ttl
= 0;
// AS_RECORD_DEFAULT_TTL
1031
return
p;
1032
}
1033
1034
/**
1035
* Copy as_policy_apply values.
1036
*
1037
* @param src The source policy.
1038
* @param trg The target policy.
1039
*
1040
* @relates as_policy_apply
1041
*/
1042
static
inline
void
1043
as_policy_apply_copy
(
as_policy_apply
* src,
as_policy_apply
* trg)
1044
{
1045
trg->
timeout
= src->
timeout
;
1046
trg->
key
= src->
key
;
1047
trg->
commit_level
= src->
commit_level
;
1048
trg->
ttl
= src->
ttl
;
1049
}
1050
1051
/**
1052
* Initialize as_policy_info to default values.
1053
*
1054
* @param p The policy to initialize.
1055
* @return The initialized policy.
1056
*
1057
* @relates as_policy_info
1058
*/
1059
static
inline
as_policy_info
*
1060
as_policy_info_init
(
as_policy_info
* p)
1061
{
1062
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1063
p->
send_as_is
=
true
;
1064
p->
check_bounds
=
true
;
1065
return
p;
1066
}
1067
1068
/**
1069
* Copy as_policy_info values.
1070
*
1071
* @param src The source policy.
1072
* @param trg The target policy.
1073
*
1074
* @relates as_policy_info
1075
*/
1076
static
inline
void
1077
as_policy_info_copy
(
as_policy_info
* src,
as_policy_info
* trg)
1078
{
1079
trg->
timeout
= src->
timeout
;
1080
trg->
send_as_is
= src->
send_as_is
;
1081
trg->
check_bounds
= src->
check_bounds
;
1082
}
1083
1084
/**
1085
* Initialize as_policy_batch to default values.
1086
*
1087
* @param p The policy to initialize.
1088
* @return The initialized policy.
1089
*
1090
* @relates as_policy_batch
1091
*/
1092
static
inline
as_policy_batch
*
1093
as_policy_batch_init
(
as_policy_batch
* p)
1094
{
1095
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1096
p->
concurrent
=
false
;
1097
p->
use_batch_direct
=
false
;
1098
p->
allow_inline
=
true
;
1099
p->
send_set_name
=
false
;
1100
p->
deserialize
=
true
;
1101
return
p;
1102
}
1103
1104
/**
1105
* Copy as_policy_batch values.
1106
*
1107
* @param src The source policy.
1108
* @param trg The target policy.
1109
*
1110
* @relates as_policy_batch
1111
*/
1112
static
inline
void
1113
as_policy_batch_copy
(
as_policy_batch
* src,
as_policy_batch
* trg)
1114
{
1115
trg->
timeout
= src->
timeout
;
1116
trg->
concurrent
= src->
concurrent
;
1117
trg->
use_batch_direct
= src->
use_batch_direct
;
1118
trg->
allow_inline
= src->
allow_inline
;
1119
trg->
send_set_name
= src->
send_set_name
;
1120
trg->
deserialize
= src->
deserialize
;
1121
}
1122
1123
/**
1124
* Initialize as_policy_admin to default values.
1125
*
1126
* @param p The policy to initialize.
1127
* @return The initialized policy.
1128
*
1129
* @relates as_policy_admin
1130
*/
1131
static
inline
as_policy_admin
*
1132
as_policy_admin_init
(
as_policy_admin
* p)
1133
{
1134
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1135
return
p;
1136
}
1137
1138
/**
1139
* Copy as_policy_admin values.
1140
*
1141
* @param src The source policy.
1142
* @param trg The target policy.
1143
*
1144
* @relates as_policy_admin
1145
*/
1146
static
inline
void
1147
as_policy_admin_copy
(
as_policy_admin
* src,
as_policy_admin
* trg)
1148
{
1149
trg->
timeout
= src->
timeout
;
1150
}
1151
1152
/**
1153
* Initialize as_policy_scan to default values.
1154
*
1155
* @param p The policy to initialize.
1156
* @return The initialized policy.
1157
*
1158
* @relates as_policy_scan
1159
*/
1160
static
inline
as_policy_scan
*
1161
as_policy_scan_init
(
as_policy_scan
* p)
1162
{
1163
p->
timeout
= 0;
1164
p->
fail_on_cluster_change
=
false
;
1165
return
p;
1166
}
1167
1168
/**
1169
* Copy as_policy_scan values.
1170
*
1171
* @param src The source policy.
1172
* @param trg The target policy.
1173
*
1174
* @relates as_policy_scan
1175
*/
1176
static
inline
void
1177
as_policy_scan_copy
(
as_policy_scan
* src,
as_policy_scan
* trg)
1178
{
1179
trg->
timeout
= src->
timeout
;
1180
trg->
fail_on_cluster_change
= src->
fail_on_cluster_change
;
1181
}
1182
1183
/**
1184
* Initialize as_policy_query to default values.
1185
*
1186
* @param p The policy to initialize.
1187
* @return The initialized policy.
1188
*
1189
* @relates as_policy_query
1190
*/
1191
static
inline
as_policy_query
*
1192
as_policy_query_init
(
as_policy_query
* p)
1193
{
1194
p->
timeout
= 0;
1195
p->
deserialize
=
true
;
1196
return
p;
1197
}
1198
1199
/**
1200
* Copy as_policy_query values.
1201
*
1202
* @param src The source policy.
1203
* @param trg The target policy.
1204
*
1205
* @relates as_policy_query
1206
*/
1207
static
inline
void
1208
as_policy_query_copy
(
as_policy_query
* src,
as_policy_query
* trg)
1209
{
1210
trg->
timeout
= src->
timeout
;
1211
trg->
deserialize
= src->
deserialize
;
1212
}
1213
1214
/**
1215
* Initialize as_policies to undefined values.
1216
* as_policies_resolve() will later be called resolve undefined values to global defaults.
1217
*
1218
* @param p The policies to undefine
1219
* @return The undefined policies.
1220
*
1221
* @relates as_policies
1222
*/
1223
as_policies
*
1224
as_policies_init
(
as_policies
* p);
1225
1226
/**
1227
* Resolve global policies (like timeout) with operational policies (like as_policy_read).
1228
*
1229
* @param p The policies to resolve
1230
*
1231
* @relates as_policies
1232
*/
1233
void
1234
as_policies_resolve
(
as_policies
* p);
1235
1236
#ifdef __cplusplus
1237
}
// end extern "C"
1238
#endif