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