Syncing
BulkOpException
¶
Bases: Exception
Exception raised when errors are detected in the response of a bulk operation.
Source code in splitgill/indexing/syncing.py
34 35 36 37 38 39 40 41 | |
BulkOptions
dataclass
¶
Options for writing bulk operations to Elasticsearch.
Source code in splitgill/indexing/syncing.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
WriteResult
¶
Represents the outcome of writing a stream of bulk index operations to Elasticsearch.
Source code in splitgill/indexing/syncing.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
__init__(worker_counts=None, indices=None)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
worker_counts
|
Optional[Iterable[Tuple[int, int]]]
|
optional iterable of tuples containing the insert and delete counts from each worker |
None
|
indices
|
Optional[Set[str]]
|
optional set of indices operated by the workers during the load |
None
|
Source code in splitgill/indexing/syncing.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
check_for_errors(tasks)
¶
Loop through the given worker tasks and check if any of them have finished. If they have finished, either update the result or raise the exception that stopped the task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tasks
|
Set[Task]
|
the worker tasks |
required |
Source code in splitgill/indexing/syncing.py
195 196 197 198 199 200 201 202 203 204 205 206 207 | |
refresh(client, indices, attempts=3)
¶
Given an Elasticsearch client and a list of indices, call refresh on the indices. If
the request gets a connection timeout from Elasticsearch, the operation will be
retried up to attempts times with an increasing timeout after each failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Elasticsearch
|
the Elasticsearch client to use |
required |
indices
|
List[str]
|
the indices to refresh |
required |
attempts
|
int
|
the number of times to attempt before raising an exception |
3
|
Source code in splitgill/indexing/syncing.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
setup_indices(client, indices)
async
¶
Sets up the given Elasticsearch indices with settings for optimal bulk indexing. Any index that doesn't exist, will be created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncElasticsearch
|
an AsyncElasticsearch object |
required |
indices
|
Iterable[str]
|
the indices to set up |
required |
Source code in splitgill/indexing/syncing.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
worker(client, task_queue)
async
¶
Async worker function for sending chunks of bulk index operations to Elasticsearch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncElasticsearch
|
the AsyncElasticsearch client to use for requests |
required |
task_queue
|
Queue
|
the queue to retrieve tasks from |
required |
Source code in splitgill/indexing/syncing.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
write_ops(client, op_stream, options)
¶
Write the given iterable of bulk index operations to Elasticsearch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Elasticsearch
|
an Elasticsearch client, this isn't actually used as the processing is done asynchronously using the AsyncElasticsearch class, but we pull the hosts from this Elasticsearch client to create the AsyncElasticsearch object |
required |
op_stream
|
Iterable[BulkOp]
|
an iterable of BulkOp objects |
required |
options
|
Optional[BulkOptions]
|
options determining how we do the bulk write |
required |
Returns:
| Type | Description |
|---|---|
WriteResult
|
a WriteResult object |
Source code in splitgill/indexing/syncing.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
write_ops_async(hosts, op_stream, options)
async
¶
Writes the given iterable of bulk index operations to Elasticsearch using a set of async workers for maximum efficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hosts
|
List[NodeConfig]
|
a list of elasticsearch node configurations |
required |
op_stream
|
Iterable[BulkOp]
|
an iterable of BulkOp objects |
required |
options
|
BulkOptions
|
options determining how we do the bulk write |
required |
Returns:
| Type | Description |
|---|---|
WriteResult
|
a WriteResult object |
Source code in splitgill/indexing/syncing.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |