Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
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
;
37
uint32_t
sleep_between_retries
;
38
bool
retry_on_timeout
;
39
}
as_command_policy
;
40
41
/******************************************************************************
42
* FUNCTIONS
43
******************************************************************************/
44
45
/**
46
* @private
47
* Convert write policy to generic policy.
48
*/
49
static
inline
void
50
as_command_policy_write
(
as_command_policy
* trg,
const
as_policy_write
* src)
51
{
52
trg->
socket_timeout
= 0;
53
trg->
total_timeout
= src->
timeout
;
54
trg->
max_retries
= src->
retry
;
55
trg->
sleep_between_retries
= src->
sleep_between_retries
;
56
trg->
retry_on_timeout
= src->
retry_on_timeout
;
57
}
58
59
/**
60
* @private
61
* Convert read policy to generic policy.
62
*/
63
static
inline
void
64
as_command_policy_read
(
as_command_policy
* trg,
const
as_policy_read
* src)
65
{
66
trg->
socket_timeout
= 0;
67
trg->
total_timeout
= src->
timeout
;
68
trg->
max_retries
= src->
retry
;
69
trg->
sleep_between_retries
= src->
sleep_between_retries
;
70
trg->
retry_on_timeout
= src->
retry_on_timeout
;
71
}
72
73
/**
74
* @private
75
* Convert operate policy to generic policy.
76
*/
77
static
inline
void
78
as_command_policy_operate
(
as_command_policy
* trg,
const
as_policy_operate
* src)
79
{
80
trg->
socket_timeout
= 0;
81
trg->
total_timeout
= src->
timeout
;
82
trg->
max_retries
= src->
retry
;
83
trg->
sleep_between_retries
= src->
sleep_between_retries
;
84
trg->
retry_on_timeout
= src->
retry_on_timeout
;
85
}
86
87
/**
88
* @private
89
* Convert apply policy to generic policy.
90
*/
91
static
inline
void
92
as_command_policy_apply
(
as_command_policy
* trg,
const
as_policy_apply
* src)
93
{
94
trg->
socket_timeout
= 0;
95
trg->
total_timeout
= src->
timeout
;
96
trg->
max_retries
= src->
retry
;
97
trg->
sleep_between_retries
= src->
sleep_between_retries
;
98
trg->
retry_on_timeout
= src->
retry_on_timeout
;
99
}
100
101
/**
102
* @private
103
* Convert remove policy to generic policy.
104
*/
105
static
inline
void
106
as_command_policy_remove
(
as_command_policy
* trg,
const
as_policy_remove
* src)
107
{
108
trg->
socket_timeout
= 0;
109
trg->
total_timeout
= src->
timeout
;
110
trg->
max_retries
= src->
retry
;
111
trg->
sleep_between_retries
= src->
sleep_between_retries
;
112
trg->
retry_on_timeout
= src->
retry_on_timeout
;
113
}
114
115
/**
116
* @private
117
* Convert batch policy to generic policy.
118
*/
119
static
inline
void
120
as_command_policy_batch
(
as_command_policy
* trg,
const
as_policy_batch
* src)
121
{
122
trg->
socket_timeout
= 0;
123
trg->
total_timeout
= src->
timeout
;
124
trg->
max_retries
= src->
retry
;
125
trg->
sleep_between_retries
= src->
sleep_between_retries
;
126
trg->
retry_on_timeout
= src->
retry_on_timeout
;
127
}
128
129
/**
130
* @private
131
* Convert scan policy to generic policy.
132
*/
133
static
inline
void
134
as_command_policy_scan
(
as_command_policy
* trg,
const
as_policy_scan
* src)
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
148
as_command_policy_query
(
as_command_policy
* trg,
const
as_policy_query
* src)
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
162
as_command_policy_query_background
(
as_command_policy
* trg, uint32_t timeout)
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