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-2015 Aerospike, Inc.
3
*
4
* Portions may be licensed to Aerospike, Inc. under one or more contributor
5
* license agreements.
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
* use this file except in compliance with the License. You may obtain a copy of
9
* the License at http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*/
17
#pragma once
18
19
/**
20
* @defgroup client_policies Client Policies
21
*
22
* Policies define the behavior of database operations.
23
*
24
* Policies fall into two groups: policy values and operation policies.
25
* A policy value is a single value which defines how the client behaves. An
26
* operation policy is a group of policy values which affect an operation.
27
*
28
* ## Policy Values
29
*
30
* The following are the policy values. For details, please see the documentation
31
* for each policy value
32
*
33
* - as_policy_key
34
* - as_policy_gen
35
* - as_policy_retry
36
* - as_policy_exists
37
* - as_policy_replica
38
* - as_policy_consistency_level
39
* - as_policy_commit_level
40
*
41
* ## Operation Policies
42
*
43
* The following are the operation policies. Operation policies are groups of
44
* policy values for a type of operation.
45
*
46
* - as_policy_batch
47
* - as_policy_info
48
* - as_policy_operate
49
* - as_policy_read
50
* - as_policy_remove
51
* - as_policy_query
52
* - as_policy_scan
53
* - as_policy_write
54
*/
55
56
#include <stdbool.h>
57
#include <stdint.h>
58
59
#ifdef __cplusplus
60
extern
"C"
{
61
#endif
62
63
/******************************************************************************
64
* MACROS
65
*****************************************************************************/
66
67
/**
68
* Default timeout value
69
*
70
* @ingroup client_policies
71
*/
72
#define AS_POLICY_TIMEOUT_DEFAULT 1000
73
74
/**
75
* Default as_policy_retry value
76
*
77
* @ingroup client_policies
78
*/
79
#define AS_POLICY_RETRY_DEFAULT AS_POLICY_RETRY_ONCE
80
81
/**
82
* Default as_policy_gen value
83
*
84
* @ingroup client_policies
85
*/
86
#define AS_POLICY_GEN_DEFAULT AS_POLICY_GEN_IGNORE
87
88
/**
89
* Default as_policy_key value
90
*
91
* @ingroup client_policies
92
*/
93
#define AS_POLICY_KEY_DEFAULT AS_POLICY_KEY_DIGEST
94
95
/**
96
* Default as_policy_exists value
97
*
98
* @ingroup client_policies
99
*/
100
#define AS_POLICY_EXISTS_DEFAULT AS_POLICY_EXISTS_IGNORE
101
102
/**
103
* Default as_policy_replica value
104
*
105
* @ingroup client_policies
106
*/
107
#define AS_POLICY_REPLICA_DEFAULT AS_POLICY_REPLICA_MASTER
108
109
/**
110
* Default as_policy_consistency_level value for read
111
*
112
* @ingroup client_policies
113
*/
114
#define AS_POLICY_CONSISTENCY_LEVEL_DEFAULT AS_POLICY_CONSISTENCY_LEVEL_ONE
115
116
/**
117
* Default as_policy_commit_level value for write
118
*
119
* @ingroup client_policies
120
*/
121
#define AS_POLICY_COMMIT_LEVEL_DEFAULT AS_POLICY_COMMIT_LEVEL_ALL
122
123
/******************************************************************************
124
* TYPES
125
*****************************************************************************/
126
127
/**
128
* Retry Policy
129
*
130
* Specifies the behavior of failed operations.
131
*
132
* @ingroup client_policies
133
*/
134
typedef
enum
as_policy_retry_e {
135
136
/**
137
* Only attempt an operation once.
138
*/
139
AS_POLICY_RETRY_NONE
,
140
141
/**
142
* If an operation fails, attempt the operation
143
* one more time.
144
*/
145
AS_POLICY_RETRY_ONCE
,
146
147
}
as_policy_retry
;
148
149
/**
150
* Generation Policy
151
*
152
* Specifies the behavior of record modifications with regard to the
153
* generation value.
154
*
155
* @ingroup client_policies
156
*/
157
typedef
enum
as_policy_gen_e {
158
159
/**
160
* Write a record, regardless of generation.
161
*/
162
AS_POLICY_GEN_IGNORE
,
163
164
/**
165
* Write a record, ONLY if generations are equal
166
*/
167
AS_POLICY_GEN_EQ
,
168
169
/**
170
* Write a record, ONLY if local generation is
171
* greater-than remote generation
172
*/
173
AS_POLICY_GEN_GT
174
175
}
as_policy_gen
;
176
177
/**
178
* Key Policy
179
*
180
* Specifies the behavior for whether keys or digests
181
* should be sent to the cluster.
182
*
183
* @ingroup client_policies
184
*/
185
typedef
enum
as_policy_key_e {
186
187
/**
188
* Send the digest value of the key.
189
*
190
* This is the recommended mode of operation. This calculates the digest
191
* and send the digest to the server. The digest is only calculated on
192
* the client, and not on the server.
193
*/
194
AS_POLICY_KEY_DIGEST
,
195
196
/**
197
* Send the key, in addition to the digest value.
198
*
199
* If you want keys to be returned when scanning or querying, the keys must
200
* be stored on the server. This policy causes a write operation to store
201
* the key. Once a key is stored, the server will keep it - there is no
202
* need to use this policy on subsequent updates of the record.
203
*
204
* If this policy is used on read or delete operations, or on subsequent
205
* updates of a record with a stored key, the key sent will be compared
206
* with the key stored on the server. A mismatch will cause
207
* AEROSPIKE_ERR_RECORD_KEY_MISMATCH to be returned.
208
*/
209
AS_POLICY_KEY_SEND
,
210
211
}
as_policy_key
;
212
213
/**
214
* Existence Policy
215
*
216
* Specifies the behavior for writing the record
217
* depending whether or not it exists.
218
*
219
* @ingroup client_policies
220
*/
221
typedef
enum
as_policy_exists_e {
222
223
/**
224
* Write the record, regardless of existence. (i.e. create or update.)
225
*/
226
AS_POLICY_EXISTS_IGNORE
,
227
228
/**
229
* Create a record, ONLY if it doesn't exist.
230
*/
231
AS_POLICY_EXISTS_CREATE
,
232
233
/**
234
* Update a record, ONLY if it exists.
235
*/
236
AS_POLICY_EXISTS_UPDATE
,
237
238
/**
239
* Completely replace a record, ONLY if it exists.
240
*/
241
AS_POLICY_EXISTS_REPLACE
,
242
243
/**
244
* Completely replace a record if it exists, otherwise create it.
245
*/
246
AS_POLICY_EXISTS_CREATE_OR_REPLACE
247
248
}
as_policy_exists
;
249
250
/**
251
* Replica Policy
252
*
253
* Specifies which partition replica to read from.
254
*
255
* @ingroup client_policies
256
*/
257
typedef
enum
as_policy_replica_e {
258
259
/**
260
* Read from the partition master replica node.
261
*/
262
AS_POLICY_REPLICA_MASTER
,
263
264
/**
265
* Read from an unspecified replica node.
266
*/
267
AS_POLICY_REPLICA_ANY
268
269
}
as_policy_replica
;
270
271
/**
272
* Consistency Level
273
*
274
* Specifies the number of replicas to be consulted
275
* in a read operation to provide the desired
276
* consistency guarantee.
277
*
278
* @ingroup client_policies
279
*/
280
typedef
enum
as_policy_consistency_level_e {
281
282
/**
283
* Involve a single replica in the operation.
284
*/
285
AS_POLICY_CONSISTENCY_LEVEL_ONE
,
286
287
/**
288
* Involve all replicas in the operation.
289
*/
290
AS_POLICY_CONSISTENCY_LEVEL_ALL
,
291
292
}
as_policy_consistency_level
;
293
294
/**
295
* Commit Level
296
*
297
* Specifies the number of replicas required to be successfully
298
* committed before returning success in a write operation
299
* to provide the desired consistency guarantee.
300
*
301
* @ingroup client_policies
302
*/
303
typedef
enum
as_policy_commit_level_e {
304
305
/**
306
* Return succcess only after successfully committing all replicas.
307
*/
308
AS_POLICY_COMMIT_LEVEL_ALL
,
309
310
/**
311
* Return succcess after successfully committing the master replica.
312
*/
313
AS_POLICY_COMMIT_LEVEL_MASTER
,
314
315
}
as_policy_commit_level
;
316
317
/**
318
* Write Policy
319
*
320
* @ingroup client_policies
321
*/
322
typedef
struct
as_policy_write_s {
323
324
/**
325
* Maximum time in milliseconds to wait for
326
* the operation to complete.
327
*
328
* If undefined (-1), then the value will default to
329
* either as_config.policies.timeout
330
* or `AS_POLICY_TIMEOUT_DEFAULT`.
331
*/
332
uint32_t
timeout
;
333
334
/**
335
* Specifies the behavior for failed operations.
336
*/
337
as_policy_retry
retry
;
338
339
/**
340
* Specifies the behavior for the key.
341
*/
342
as_policy_key
key
;
343
344
/**
345
* Specifies the behavior for the generation
346
* value.
347
*/
348
as_policy_gen
gen
;
349
350
/**
351
* Specifies the behavior for the existence
352
* of the record.
353
*/
354
as_policy_exists
exists
;
355
356
/**
357
* Specifies the number of replicas required
358
* to be committed successfully when writing
359
* before returning transaction succeeded.
360
*/
361
as_policy_commit_level
commit_level
;
362
363
}
as_policy_write
;
364
365
/**
366
* Read Policy
367
*
368
* @ingroup client_policies
369
*/
370
typedef
struct
as_policy_read_s {
371
372
/**
373
* Maximum time in milliseconds to wait for
374
* the operation to complete.
375
*
376
* If undefined (-1), then the value will default to
377
* either as_config.policies.timeout
378
* or `AS_POLICY_TIMEOUT_DEFAULT`.
379
*/
380
uint32_t
timeout
;
381
382
/**
383
* Specifies the behavior for the key.
384
*/
385
as_policy_key
key
;
386
387
/**
388
* Specifies the replica to be consulted for the read.
389
*/
390
as_policy_replica
replica
;
391
392
/**
393
* Specifies the number of replicas consulted
394
* when reading for the desired consistency guarantee.
395
*/
396
as_policy_consistency_level
consistency_level
;
397
398
}
as_policy_read
;
399
400
/**
401
* Key Apply Policy
402
*
403
* @ingroup client_policies
404
*/
405
typedef
struct
as_policy_apply_s {
406
407
/**
408
* Maximum time in milliseconds to wait for
409
* the operation to complete.
410
*
411
* If undefined (-1), then the value will default to
412
* either as_config.policies.timeout
413
* or `AS_POLICY_TIMEOUT_DEFAULT`.
414
*/
415
uint32_t
timeout
;
416
417
/**
418
* Specifies the behavior for the key.
419
*/
420
as_policy_key
key
;
421
422
/**
423
* Specifies the number of replicas required
424
* to be committed successfully when writing
425
* before returning transaction succeeded.
426
*/
427
as_policy_commit_level
commit_level
;
428
429
}
as_policy_apply
;
430
431
/**
432
* Operate Policy
433
*
434
* @ingroup client_policies
435
*/
436
typedef
struct
as_policy_operate_s {
437
438
/**
439
* Maximum time in milliseconds to wait for
440
* the operation to complete.
441
*
442
* If undefined (-1), then the value will default to
443
* either as_config.policies.timeout
444
* or `AS_POLICY_TIMEOUT_DEFAULT`.
445
*/
446
uint32_t
timeout
;
447
448
/**
449
* Specifies the behavior for failed operations.
450
*/
451
as_policy_retry
retry
;
452
453
/**
454
* Specifies the behavior for the key.
455
*/
456
as_policy_key
key
;
457
458
/**
459
* Specifies the behavior for the generation
460
* value.
461
*/
462
as_policy_gen
gen
;
463
464
/**
465
* Specifies the replica to be consulted for the read.
466
*/
467
as_policy_replica
replica
;
468
469
/**
470
* Specifies the number of replicas consulted
471
* when reading for the desired consistency guarantee.
472
*/
473
as_policy_consistency_level
consistency_level
;
474
475
/**
476
* Specifies the number of replicas required
477
* to be committed successfully when writing
478
* before returning transaction succeeded.
479
*/
480
as_policy_commit_level
commit_level
;
481
482
}
as_policy_operate
;
483
484
/**
485
* Remove Policy
486
*
487
* @ingroup client_policies
488
*/
489
typedef
struct
as_policy_remove_s {
490
491
/**
492
* Maximum time in milliseconds to wait for
493
* the operation to complete.
494
*
495
* If undefined (-1), then the value will default to
496
* either as_config.policies.timeout
497
* or `AS_POLICY_TIMEOUT_DEFAULT`.
498
*/
499
uint32_t
timeout
;
500
501
/**
502
* The generation of the record.
503
*/
504
uint16_t
generation
;
505
506
/**
507
* Specifies the behavior of failed operations.
508
*/
509
as_policy_retry
retry
;
510
511
/**
512
* Specifies the behavior for the key.
513
*/
514
as_policy_key
key
;
515
516
/**
517
* Specifies the behavior for the generation
518
* value.
519
*/
520
as_policy_gen
gen
;
521
522
/**
523
* Specifies the number of replicas required
524
* to be committed successfully when writing
525
* before returning transaction succeeded.
526
*/
527
as_policy_commit_level
commit_level
;
528
529
}
as_policy_remove
;
530
531
/**
532
* Query Policy
533
*
534
* @ingroup client_policies
535
*/
536
typedef
struct
as_policy_query_s {
537
538
/**
539
* Maximum time in milliseconds to wait for
540
* the operation to complete.
541
*
542
* The default (0) means do not timeout.
543
*/
544
uint32_t
timeout
;
545
546
}
as_policy_query
;
547
548
/**
549
* Scan Policy
550
*
551
* @ingroup client_policies
552
*/
553
typedef
struct
as_policy_scan_s {
554
555
/**
556
* Maximum time in milliseconds to wait for the operation to complete.
557
*
558
* The default (0) means do not timeout.
559
*/
560
uint32_t
timeout
;
561
562
/**
563
* Abort the scan if the cluster is not in a
564
* stable state.
565
*/
566
bool
fail_on_cluster_change
;
567
568
}
as_policy_scan
;
569
570
/**
571
* Info Policy
572
*
573
* @ingroup client_policies
574
*/
575
typedef
struct
as_policy_info_s {
576
577
/**
578
* Maximum time in milliseconds to wait for
579
* the operation to complete.
580
*
581
* If undefined (-1), then the value will default to
582
* either as_config.policies.timeout
583
* or `AS_POLICY_TIMEOUT_DEFAULT`.
584
*/
585
uint32_t
timeout
;
586
587
/**
588
* Send request without any further processing.
589
*/
590
bool
send_as_is
;
591
592
/**
593
* Ensure the request is within allowable size limits.
594
*/
595
bool
check_bounds
;
596
597
}
as_policy_info
;
598
599
/**
600
* Batch Policy
601
*
602
* @ingroup client_policies
603
*/
604
typedef
struct
as_policy_batch_s {
605
606
/**
607
* Maximum time in milliseconds to wait for
608
* the operation to complete.
609
*
610
* If undefined (-1), then the value will default to
611
* either as_config.policies.timeout
612
* or `AS_POLICY_TIMEOUT_DEFAULT`.
613
*/
614
uint32_t
timeout
;
615
616
}
as_policy_batch
;
617
618
/**
619
* Administration Policy
620
*
621
* @ingroup client_policies
622
*/
623
typedef
struct
as_policy_admin_s {
624
625
/**
626
* Maximum time in milliseconds to wait for
627
* the operation to complete.
628
*
629
* If undefined (-1), then the value will default to
630
* either as_config.policies.timeout
631
* or `AS_POLICY_TIMEOUT_DEFAULT`.
632
*/
633
uint32_t
timeout
;
634
635
}
as_policy_admin
;
636
637
/**
638
* Struct of all policy values and operation policies.
639
*
640
* This is utilizes by as_config, to define global and default values
641
* for policies.
642
*
643
* @ingroup as_config_t
644
*/
645
typedef
struct
as_policies_s {
646
647
/***************************************************************************
648
* DEFAULT VALUES, IF SPECIFIC POLICY IS UNDEFINED
649
**************************************************************************/
650
651
/**
652
* Default timeout in milliseconds.
653
*
654
* Will be used if specific policies have a timeout of 0 (zero).
655
*
656
* The default value is `AS_POLICY_TIMEOUT_DEFAULT`.
657
*/
658
uint32_t
timeout
;
659
660
/**
661
* Specifies the behavior for failed operations.
662
*
663
* The default value is `AS_POLICY_RETRY_DEFAULT`.
664
*/
665
as_policy_retry
retry
;
666
667
/**
668
* Specifies the behavior for the key.
669
*
670
* The default value is `AS_POLICY_KEY_DEFAULT`.
671
*/
672
as_policy_key
key
;
673
674
/**
675
* Specifies the behavior for the generation
676
* value.
677
*
678
* The default value is `AS_POLICY_GEN_DEFAULT`.
679
*/
680
as_policy_gen
gen
;
681
682
/**
683
* Specifies the behavior for the existence
684
* of the record.
685
*
686
* The default value is `AS_POLICY_EXISTS_DEFAULT`.
687
*/
688
as_policy_exists
exists
;
689
690
/**
691
* Specifies which replica to read.
692
*
693
* The default value is `AS_POLICY_REPLICA_MASTER`.
694
*/
695
as_policy_replica
replica
;
696
697
/**
698
* Specifies the consistency level for reading.
699
*
700
* The default value is `AS_POLICY_CONSISTENCY_LEVEL_ONE`.
701
*/
702
as_policy_consistency_level
consistency_level
;
703
704
/**
705
* Specifies the commit level for writing.
706
*
707
* The default value is `AS_POLICY_COMMIT_LEVEL_ALL`.
708
*/
709
as_policy_commit_level
commit_level
;
710
711
/***************************************************************************
712
* SPECIFIC POLICIES
713
**************************************************************************/
714
715
/**
716
* The default read policy.
717
*/
718
as_policy_read
read
;
719
720
/**
721
* The default write policy.
722
*/
723
as_policy_write
write
;
724
725
/**
726
* The default operate policy.
727
*/
728
as_policy_operate
operate
;
729
730
/**
731
* The default remove policy.
732
*/
733
as_policy_remove
remove
;
734
735
/**
736
* The default apply policy.
737
*/
738
as_policy_apply
apply
;
739
740
/**
741
* The default query policy.
742
*/
743
as_policy_query
query
;
744
745
/**
746
* The default scan policy.
747
*/
748
as_policy_scan
scan
;
749
750
/**
751
* The default info policy.
752
*/
753
as_policy_info
info
;
754
755
/**
756
* The default batch policy.
757
*/
758
as_policy_batch
batch
;
759
760
/**
761
* The default administration policy.
762
*/
763
as_policy_admin
admin
;
764
765
}
as_policies
;
766
767
/******************************************************************************
768
* FUNCTIONS
769
*****************************************************************************/
770
771
/**
772
* Initialize as_policy_read to default values.
773
*
774
* @param p The policy to initialize.
775
* @return The initialized policy.
776
*
777
* @relates as_policy_read
778
*/
779
static
inline
as_policy_read
*
780
as_policy_read_init
(
as_policy_read
* p)
781
{
782
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
783
p->
key
=
AS_POLICY_KEY_DEFAULT
;
784
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
785
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
786
return
p;
787
}
788
789
/**
790
* Copy as_policy_read values.
791
*
792
* @param src The source policy.
793
* @param trg The target policy.
794
*
795
* @relates as_policy_read
796
*/
797
static
inline
void
798
as_policy_read_copy
(
as_policy_read
* src,
as_policy_read
* trg)
799
{
800
trg->
timeout
= src->
timeout
;
801
trg->
key
= src->
key
;
802
trg->
replica
= src->
replica
;
803
trg->
consistency_level
= src->
consistency_level
;
804
}
805
806
/**
807
* Initialize as_policy_write to default values.
808
*
809
* @param p The policy to initialize.
810
* @return The initialized policy.
811
*
812
* @relates as_policy_write
813
*/
814
static
inline
as_policy_write
*
815
as_policy_write_init
(
as_policy_write
* p)
816
{
817
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
818
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
819
p->
key
=
AS_POLICY_KEY_DEFAULT
;
820
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
821
p->
exists
=
AS_POLICY_EXISTS_DEFAULT
;
822
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
823
return
p;
824
}
825
826
/**
827
* Copy as_policy_write values.
828
*
829
* @param src The source policy.
830
* @param trg The target policy.
831
*
832
* @relates as_policy_write
833
*/
834
static
inline
void
835
as_policy_write_copy
(
as_policy_write
* src,
as_policy_write
* trg)
836
{
837
trg->
timeout
= src->
timeout
;
838
trg->
retry
= src->
retry
;
839
trg->
key
= src->
key
;
840
trg->
gen
= src->
gen
;
841
trg->
exists
= src->
exists
;
842
trg->
commit_level
= src->
commit_level
;
843
}
844
845
/**
846
* Initialize as_policy_operate to default values.
847
*
848
* @param p The policy to initialize.
849
* @return The initialized policy.
850
*
851
* @relates as_policy_operate
852
*/
853
static
inline
as_policy_operate
*
854
as_policy_operate_init
(
as_policy_operate
* p)
855
{
856
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
857
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
858
p->
key
=
AS_POLICY_KEY_DEFAULT
;
859
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
860
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
861
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
862
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
863
return
p;
864
}
865
866
/**
867
* Copy as_policy_operate values.
868
*
869
* @param src The source policy.
870
* @param trg The target policy.
871
*
872
* @relates as_policy_operate
873
*/
874
static
inline
void
875
as_policy_operate_copy
(
as_policy_operate
* src,
as_policy_operate
* trg)
876
{
877
trg->
timeout
= src->
timeout
;
878
trg->
retry
= src->
retry
;
879
trg->
key
= src->
key
;
880
trg->
gen
= src->
gen
;
881
trg->
replica
= src->
replica
;
882
trg->
consistency_level
= src->
consistency_level
;
883
trg->
commit_level
= src->
commit_level
;
884
}
885
886
/**
887
* Initialize as_policy_remove to default values.
888
*
889
* @param p The policy to initialize.
890
* @return The initialized policy.
891
*
892
* @relates as_policy_remove
893
*/
894
static
inline
as_policy_remove
*
895
as_policy_remove_init
(
as_policy_remove
* p)
896
{
897
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
898
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
899
p->
key
=
AS_POLICY_KEY_DEFAULT
;
900
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
901
p->
generation
= 0;
902
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
903
return
p;
904
}
905
906
/**
907
* Copy as_policy_remove values.
908
*
909
* @param src The source policy.
910
* @param trg The target policy.
911
*
912
* @relates as_policy_remove
913
*/
914
static
inline
void
915
as_policy_remove_copy
(
as_policy_remove
* src,
as_policy_remove
* trg)
916
{
917
trg->
timeout
= src->
timeout
;
918
trg->
retry
= src->
retry
;
919
trg->
key
= src->
key
;
920
trg->
gen
= src->
gen
;
921
trg->
generation
= src->
generation
;
922
trg->
commit_level
= src->
commit_level
;
923
}
924
925
/**
926
* Initialize as_policy_apply to default values.
927
*
928
* @param p The policy to initialize.
929
* @return The initialized policy.
930
*
931
* @relates as_policy_apply
932
*/
933
static
inline
as_policy_apply
*
934
as_policy_apply_init
(
as_policy_apply
* p)
935
{
936
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
937
p->
key
=
AS_POLICY_KEY_DEFAULT
;
938
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
939
return
p;
940
}
941
942
/**
943
* Copy as_policy_apply values.
944
*
945
* @param src The source policy.
946
* @param trg The target policy.
947
*
948
* @relates as_policy_apply
949
*/
950
static
inline
void
951
as_policy_apply_copy
(
as_policy_apply
* src,
as_policy_apply
* trg)
952
{
953
trg->
timeout
= src->
timeout
;
954
trg->
key
= src->
key
;
955
trg->
commit_level
= src->
commit_level
;
956
}
957
958
/**
959
* Initialize as_policy_info to default values.
960
*
961
* @param p The policy to initialize.
962
* @return The initialized policy.
963
*
964
* @relates as_policy_info
965
*/
966
static
inline
as_policy_info
*
967
as_policy_info_init
(
as_policy_info
* p)
968
{
969
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
970
p->
send_as_is
=
true
;
971
p->
check_bounds
=
true
;
972
return
p;
973
}
974
975
/**
976
* Copy as_policy_info values.
977
*
978
* @param src The source policy.
979
* @param trg The target policy.
980
*
981
* @relates as_policy_info
982
*/
983
static
inline
void
984
as_policy_info_copy
(
as_policy_info
* src,
as_policy_info
* trg)
985
{
986
trg->
timeout
= src->
timeout
;
987
trg->
send_as_is
= src->
send_as_is
;
988
trg->
check_bounds
= src->
check_bounds
;
989
}
990
991
/**
992
* Initialize as_policy_batch to default values.
993
*
994
* @param p The policy to initialize.
995
* @return The initialized policy.
996
*
997
* @relates as_policy_batch
998
*/
999
static
inline
as_policy_batch
*
1000
as_policy_batch_init
(
as_policy_batch
* p)
1001
{
1002
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1003
return
p;
1004
}
1005
1006
/**
1007
* Copy as_policy_batch values.
1008
*
1009
* @param src The source policy.
1010
* @param trg The target policy.
1011
*
1012
* @relates as_policy_batch
1013
*/
1014
static
inline
void
1015
as_policy_batch_copy
(
as_policy_batch
* src,
as_policy_batch
* trg)
1016
{
1017
trg->
timeout
= src->
timeout
;
1018
}
1019
1020
/**
1021
* Initialize as_policy_admin to default values.
1022
*
1023
* @param p The policy to initialize.
1024
* @return The initialized policy.
1025
*
1026
* @relates as_policy_admin
1027
*/
1028
static
inline
as_policy_admin
*
1029
as_policy_admin_init
(
as_policy_admin
* p)
1030
{
1031
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1032
return
p;
1033
}
1034
1035
/**
1036
* Copy as_policy_admin values.
1037
*
1038
* @param src The source policy.
1039
* @param trg The target policy.
1040
*
1041
* @relates as_policy_admin
1042
*/
1043
static
inline
void
1044
as_policy_admin_copy
(
as_policy_admin
* src,
as_policy_admin
* trg)
1045
{
1046
trg->
timeout
= src->
timeout
;
1047
}
1048
1049
/**
1050
* Initialize as_policy_scan to default values.
1051
*
1052
* @param p The policy to initialize.
1053
* @return The initialized policy.
1054
*
1055
* @relates as_policy_scan
1056
*/
1057
static
inline
as_policy_scan
*
1058
as_policy_scan_init
(
as_policy_scan
* p)
1059
{
1060
p->
timeout
= 0;
1061
p->
fail_on_cluster_change
=
false
;
1062
return
p;
1063
}
1064
1065
/**
1066
* Copy as_policy_scan values.
1067
*
1068
* @param src The source policy.
1069
* @param trg The target policy.
1070
*
1071
* @relates as_policy_scan
1072
*/
1073
static
inline
void
1074
as_policy_scan_copy
(
as_policy_scan
* src,
as_policy_scan
* trg)
1075
{
1076
trg->
timeout
= src->
timeout
;
1077
trg->
fail_on_cluster_change
= src->
fail_on_cluster_change
;
1078
}
1079
1080
/**
1081
* Initialize as_policy_query to default values.
1082
*
1083
* @param p The policy to initialize.
1084
* @return The initialized policy.
1085
*
1086
* @relates as_policy_query
1087
*/
1088
static
inline
as_policy_query
*
1089
as_policy_query_init
(
as_policy_query
* p)
1090
{
1091
p->
timeout
= 0;
1092
return
p;
1093
}
1094
1095
/**
1096
* Copy as_policy_query values.
1097
*
1098
* @param src The source policy.
1099
* @param trg The target policy.
1100
*
1101
* @relates as_policy_query
1102
*/
1103
static
inline
void
1104
as_policy_query_copy
(
as_policy_query
* src,
as_policy_query
* trg)
1105
{
1106
trg->
timeout
= src->
timeout
;
1107
}
1108
1109
/**
1110
* Initialize as_policies to undefined values.
1111
* as_policies_resolve() will later be called resolve undefined values to global defaults.
1112
*
1113
* @param p The policies to undefine
1114
* @return The undefined policies.
1115
*
1116
* @relates as_policies
1117
*/
1118
as_policies
*
1119
as_policies_init
(
as_policies
* p);
1120
1121
/**
1122
* Resolve global policies (like timeout) with operational policies (like as_policy_read).
1123
*
1124
* @param p The policies to resolve
1125
*
1126
* @relates as_policies
1127
*/
1128
void
1129
as_policies_resolve
(
as_policies
* p);
1130
1131
#ifdef __cplusplus
1132
}
// end extern "C"
1133
#endif