All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_command_policy.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2017 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 #pragma once
18 
19 #include <aerospike/as_policy.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /******************************************************************************
26  * TYPES
27  *****************************************************************************/
28 
29 /**
30  * @private
31  * Generic command policy.
32  */
33 typedef struct as_command_policy_s {
34  uint32_t socket_timeout;
35  uint32_t total_timeout;
36  uint32_t max_retries;
40 
41 /******************************************************************************
42  * FUNCTIONS
43  ******************************************************************************/
44 
45 /**
46  * @private
47  * Convert write policy to generic policy.
48  */
49 static inline void
51 {
52  trg->socket_timeout = 0;
53  trg->total_timeout = src->timeout;
54  trg->max_retries = src->retry;
57 }
58 
59 /**
60  * @private
61  * Convert read policy to generic policy.
62  */
63 static inline void
65 {
66  trg->socket_timeout = 0;
67  trg->total_timeout = src->timeout;
68  trg->max_retries = src->retry;
71 }
72 
73 /**
74  * @private
75  * Convert operate policy to generic policy.
76  */
77 static inline void
79 {
80  trg->socket_timeout = 0;
81  trg->total_timeout = src->timeout;
82  trg->max_retries = src->retry;
85 }
86 
87 /**
88  * @private
89  * Convert apply policy to generic policy.
90  */
91 static inline void
93 {
94  trg->socket_timeout = 0;
95  trg->total_timeout = src->timeout;
96  trg->max_retries = src->retry;
99 }
100 
101 /**
102  * @private
103  * Convert remove policy to generic policy.
104  */
105 static inline void
107 {
108  trg->socket_timeout = 0;
109  trg->total_timeout = src->timeout;
110  trg->max_retries = src->retry;
113 }
114 
115 /**
116  * @private
117  * Convert batch policy to generic policy.
118  */
119 static inline void
121 {
122  trg->socket_timeout = 0;
123  trg->total_timeout = src->timeout;
124  trg->max_retries = src->retry;
127 }
128 
129 /**
130  * @private
131  * Convert scan policy to generic policy.
132  */
133 static inline void
135 {
136  trg->socket_timeout = src->socket_timeout;
137  trg->total_timeout = src->timeout;
138  trg->max_retries = 0;
139  trg->sleep_between_retries = 0;
140  trg->retry_on_timeout = false;
141 }
142 
143 /**
144  * @private
145  * Convert query policy to generic policy.
146  */
147 static inline void
149 {
150  trg->socket_timeout = src->socket_timeout;
151  trg->total_timeout = src->timeout;
152  trg->max_retries = 0;
153  trg->sleep_between_retries = 0;
154  trg->retry_on_timeout = false;
155 }
156 
157 /**
158  * @private
159  * Convert query policy to generic policy.
160  */
161 static inline void
163 {
164  trg->socket_timeout = 0;
165  trg->total_timeout = timeout;
166  trg->max_retries = 0;
167  trg->sleep_between_retries = 0;
168  trg->retry_on_timeout = false;
169 }
170 
171 #ifdef __cplusplus
172 } // end extern "C"
173 #endif