hazelcast-python-client 5.3.0__py3-none-any.whl → 5.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. hazelcast/__init__.py +1 -1
  2. hazelcast/asyncore.py +643 -0
  3. hazelcast/client.py +21 -1
  4. hazelcast/config.py +2 -2
  5. hazelcast/discovery.py +8 -8
  6. hazelcast/protocol/__init__.py +1 -1
  7. hazelcast/protocol/builtin.py +29 -0
  8. hazelcast/protocol/codec/custom/vector_document_codec.py +26 -0
  9. hazelcast/protocol/codec/custom/vector_index_config_codec.py +47 -0
  10. hazelcast/protocol/codec/custom/vector_pair_codec.py +34 -0
  11. hazelcast/protocol/codec/custom/vector_search_options_codec.py +40 -0
  12. hazelcast/protocol/codec/custom/vector_search_result_codec.py +37 -0
  13. hazelcast/protocol/codec/dynamic_config_add_vector_collection_config_codec.py +18 -0
  14. hazelcast/protocol/codec/vector_collection_clear_codec.py +15 -0
  15. hazelcast/protocol/codec/vector_collection_delete_codec.py +17 -0
  16. hazelcast/protocol/codec/vector_collection_get_codec.py +24 -0
  17. hazelcast/protocol/codec/vector_collection_optimize_codec.py +17 -0
  18. hazelcast/protocol/codec/vector_collection_put_all_codec.py +19 -0
  19. hazelcast/protocol/codec/vector_collection_put_codec.py +25 -0
  20. hazelcast/protocol/codec/vector_collection_put_if_absent_codec.py +25 -0
  21. hazelcast/protocol/codec/vector_collection_remove_codec.py +24 -0
  22. hazelcast/protocol/codec/vector_collection_search_near_vector_codec.py +26 -0
  23. hazelcast/protocol/codec/vector_collection_set_codec.py +19 -0
  24. hazelcast/protocol/codec/vector_collection_size_codec.py +22 -0
  25. hazelcast/proxy/__init__.py +3 -0
  26. hazelcast/proxy/reliable_topic.py +8 -0
  27. hazelcast/proxy/vector_collection.py +484 -0
  28. hazelcast/reactor.py +4 -1
  29. hazelcast/util.py +1 -1
  30. hazelcast/vector.py +142 -0
  31. {hazelcast_python_client-5.3.0.dist-info → hazelcast_python_client-5.5.0.dist-info}/METADATA +16 -14
  32. {hazelcast_python_client-5.3.0.dist-info → hazelcast_python_client-5.5.0.dist-info}/RECORD +35 -15
  33. {hazelcast_python_client-5.3.0.dist-info → hazelcast_python_client-5.5.0.dist-info}/WHEEL +1 -1
  34. {hazelcast_python_client-5.3.0.dist-info → hazelcast_python_client-5.5.0.dist-info}/LICENSE.txt +0 -0
  35. {hazelcast_python_client-5.3.0.dist-info → hazelcast_python_client-5.5.0.dist-info}/top_level.txt +0 -0
hazelcast/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "5.3.0"
1
+ __version__ = "5.5.0"
2
2
 
3
3
  # Set the default handler to "hazelcast" loggers
4
4
  # to avoid "No handlers could be found" warnings.
hazelcast/asyncore.py ADDED
@@ -0,0 +1,643 @@
1
+ # -*- Mode: Python -*-
2
+ # Id: asyncore.py,v 2.51 2000/09/07 22:29:26 rushing Exp
3
+ # Author: Sam Rushing <rushing@nightmare.com>
4
+
5
+ # ======================================================================
6
+ # Copyright 1996 by Sam Rushing
7
+ #
8
+ # All Rights Reserved
9
+ #
10
+ # Permission to use, copy, modify, and distribute this software and
11
+ # its documentation for any purpose and without fee is hereby
12
+ # granted, provided that the above copyright notice appear in all
13
+ # copies and that both that copyright notice and this permission
14
+ # notice appear in supporting documentation, and that the name of Sam
15
+ # Rushing not be used in advertising or publicity pertaining to
16
+ # distribution of the software without specific, written prior
17
+ # permission.
18
+ #
19
+ # SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20
+ # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
21
+ # NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
23
+ # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
24
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
25
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26
+ # ======================================================================
27
+
28
+ """Basic infrastructure for asynchronous socket service clients and servers.
29
+
30
+ There are only two ways to have a program on a single processor do "more
31
+ than one thing at a time". Multi-threaded programming is the simplest and
32
+ most popular way to do it, but there is another very different technique,
33
+ that lets you have nearly all the advantages of multi-threading, without
34
+ actually using multiple threads. it's really only practical if your program
35
+ is largely I/O bound. If your program is CPU bound, then pre-emptive
36
+ scheduled threads are probably what you really need. Network servers are
37
+ rarely CPU-bound, however.
38
+
39
+ If your operating system supports the select() system call in its I/O
40
+ library (and nearly all do), then you can use it to juggle multiple
41
+ communication channels at once; doing other work while your I/O is taking
42
+ place in the "background." Although this strategy can seem strange and
43
+ complex, especially at first, it is in many ways easier to understand and
44
+ control than multi-threaded programming. The module documented here solves
45
+ many of the difficult problems for you, making the task of building
46
+ sophisticated high-performance network servers and clients a snap.
47
+ """
48
+
49
+ import select
50
+ import socket
51
+ import sys
52
+ import time
53
+ import warnings
54
+
55
+ import os
56
+ from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
57
+ ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
58
+ errorcode
59
+
60
+ _DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
61
+ EBADF})
62
+
63
+ try:
64
+ _d: dict = socket_map
65
+ del _d
66
+ except NameError:
67
+ socket_map: dict = {}
68
+
69
+ def _strerror(err):
70
+ try:
71
+ return os.strerror(err)
72
+ except (ValueError, OverflowError, NameError):
73
+ if err in errorcode:
74
+ return errorcode[err]
75
+ return "Unknown error %s" %err
76
+
77
+ class ExitNow(Exception):
78
+ pass
79
+
80
+ _reraised_exceptions = (ExitNow, KeyboardInterrupt, SystemExit)
81
+
82
+ def read(obj):
83
+ try:
84
+ obj.handle_read_event()
85
+ except _reraised_exceptions:
86
+ raise
87
+ except:
88
+ obj.handle_error()
89
+
90
+ def write(obj):
91
+ try:
92
+ obj.handle_write_event()
93
+ except _reraised_exceptions:
94
+ raise
95
+ except:
96
+ obj.handle_error()
97
+
98
+ def _exception(obj):
99
+ try:
100
+ obj.handle_expt_event()
101
+ except _reraised_exceptions:
102
+ raise
103
+ except:
104
+ obj.handle_error()
105
+
106
+ def readwrite(obj, flags):
107
+ try:
108
+ if flags & select.POLLIN:
109
+ obj.handle_read_event()
110
+ if flags & select.POLLOUT:
111
+ obj.handle_write_event()
112
+ if flags & select.POLLPRI:
113
+ obj.handle_expt_event()
114
+ if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
115
+ obj.handle_close()
116
+ except OSError as e:
117
+ if e.errno not in _DISCONNECTED:
118
+ obj.handle_error()
119
+ else:
120
+ obj.handle_close()
121
+ except _reraised_exceptions:
122
+ raise
123
+ except:
124
+ obj.handle_error()
125
+
126
+ def poll(timeout=0.0, map=None):
127
+ if map is None:
128
+ map = socket_map
129
+ if map:
130
+ r = []; w = []; e = []
131
+ for fd, obj in list(map.items()):
132
+ is_r = obj.readable()
133
+ is_w = obj.writable()
134
+ if is_r:
135
+ r.append(fd)
136
+ # accepting sockets should not be writable
137
+ if is_w and not obj.accepting:
138
+ w.append(fd)
139
+ if is_r or is_w:
140
+ e.append(fd)
141
+ if [] == r == w == e:
142
+ time.sleep(timeout)
143
+ return
144
+
145
+ r, w, e = select.select(r, w, e, timeout)
146
+
147
+ for fd in r:
148
+ obj = map.get(fd)
149
+ if obj is None:
150
+ continue
151
+ read(obj)
152
+
153
+ for fd in w:
154
+ obj = map.get(fd)
155
+ if obj is None:
156
+ continue
157
+ write(obj)
158
+
159
+ for fd in e:
160
+ obj = map.get(fd)
161
+ if obj is None:
162
+ continue
163
+ _exception(obj)
164
+
165
+ def poll2(timeout=0.0, map=None):
166
+ # Use the poll() support added to the select module in Python 2.0
167
+ if map is None:
168
+ map = socket_map
169
+ if timeout is not None:
170
+ # timeout is in milliseconds
171
+ timeout = int(timeout*1000)
172
+ pollster = select.poll()
173
+ if map:
174
+ for fd, obj in list(map.items()):
175
+ flags = 0
176
+ if obj.readable():
177
+ flags |= select.POLLIN | select.POLLPRI
178
+ # accepting sockets should not be writable
179
+ if obj.writable() and not obj.accepting:
180
+ flags |= select.POLLOUT
181
+ if flags:
182
+ pollster.register(fd, flags)
183
+
184
+ r = pollster.poll(timeout)
185
+ for fd, flags in r:
186
+ obj = map.get(fd)
187
+ if obj is None:
188
+ continue
189
+ readwrite(obj, flags)
190
+
191
+ poll3 = poll2 # Alias for backward compatibility
192
+
193
+ def loop(timeout=30.0, use_poll=False, map=None, count=None):
194
+ if map is None:
195
+ map = socket_map
196
+
197
+ if use_poll and hasattr(select, 'poll'):
198
+ poll_fun = poll2
199
+ else:
200
+ poll_fun = poll
201
+
202
+ if count is None:
203
+ while map:
204
+ poll_fun(timeout, map)
205
+
206
+ else:
207
+ while map and count > 0:
208
+ poll_fun(timeout, map)
209
+ count = count - 1
210
+
211
+ class dispatcher:
212
+
213
+ debug = False
214
+ connected = False
215
+ accepting = False
216
+ connecting = False
217
+ closing = False
218
+ addr = None
219
+ ignore_log_types = frozenset({'warning'})
220
+
221
+ def __init__(self, sock=None, map=None):
222
+ if map is None:
223
+ self._map = socket_map
224
+ else:
225
+ self._map = map
226
+
227
+ self._fileno = None
228
+
229
+ if sock:
230
+ # Set to nonblocking just to make sure for cases where we
231
+ # get a socket from a blocking source.
232
+ sock.setblocking(False)
233
+ self.set_socket(sock, map)
234
+ self.connected = True
235
+ # The constructor no longer requires that the socket
236
+ # passed be connected.
237
+ try:
238
+ self.addr = sock.getpeername()
239
+ except OSError as err:
240
+ if err.errno in (ENOTCONN, EINVAL):
241
+ # To handle the case where we got an unconnected
242
+ # socket.
243
+ self.connected = False
244
+ else:
245
+ # The socket is broken in some unknown way, alert
246
+ # the user and remove it from the map (to prevent
247
+ # polling of broken sockets).
248
+ self.del_channel(map)
249
+ raise
250
+ else:
251
+ self.socket = None
252
+
253
+ def __repr__(self):
254
+ status = [self.__class__.__module__+"."+self.__class__.__qualname__]
255
+ if self.accepting and self.addr:
256
+ status.append('listening')
257
+ elif self.connected:
258
+ status.append('connected')
259
+ if self.addr is not None:
260
+ try:
261
+ status.append('%s:%d' % self.addr)
262
+ except TypeError:
263
+ status.append(repr(self.addr))
264
+ return '<%s at %#x>' % (' '.join(status), id(self))
265
+
266
+ def add_channel(self, map=None):
267
+ #self.log_info('adding channel %s' % self)
268
+ if map is None:
269
+ map = self._map
270
+ map[self._fileno] = self
271
+
272
+ def del_channel(self, map=None):
273
+ fd = self._fileno
274
+ if map is None:
275
+ map = self._map
276
+ if fd in map:
277
+ #self.log_info('closing channel %d:%s' % (fd, self))
278
+ del map[fd]
279
+ self._fileno = None
280
+
281
+ def create_socket(self, family=socket.AF_INET, type=socket.SOCK_STREAM):
282
+ self.family_and_type = family, type
283
+ sock = socket.socket(family, type)
284
+ sock.setblocking(False)
285
+ self.set_socket(sock)
286
+
287
+ def set_socket(self, sock, map=None):
288
+ self.socket = sock
289
+ self._fileno = sock.fileno()
290
+ self.add_channel(map)
291
+
292
+ def set_reuse_addr(self):
293
+ # try to re-use a server port if possible
294
+ try:
295
+ self.socket.setsockopt(
296
+ socket.SOL_SOCKET, socket.SO_REUSEADDR,
297
+ self.socket.getsockopt(socket.SOL_SOCKET,
298
+ socket.SO_REUSEADDR) | 1
299
+ )
300
+ except OSError:
301
+ pass
302
+
303
+ # ==================================================
304
+ # predicates for select()
305
+ # these are used as filters for the lists of sockets
306
+ # to pass to select().
307
+ # ==================================================
308
+
309
+ def readable(self):
310
+ return True
311
+
312
+ def writable(self):
313
+ return True
314
+
315
+ # ==================================================
316
+ # socket object methods.
317
+ # ==================================================
318
+
319
+ def listen(self, num):
320
+ self.accepting = True
321
+ if os.name == 'nt' and num > 5:
322
+ num = 5
323
+ return self.socket.listen(num)
324
+
325
+ def bind(self, addr):
326
+ self.addr = addr
327
+ return self.socket.bind(addr)
328
+
329
+ def connect(self, address):
330
+ self.connected = False
331
+ self.connecting = True
332
+ err = self.socket.connect_ex(address)
333
+ if err in (EINPROGRESS, EALREADY, EWOULDBLOCK) \
334
+ or err == EINVAL and os.name == 'nt':
335
+ self.addr = address
336
+ return
337
+ if err in (0, EISCONN):
338
+ self.addr = address
339
+ self.handle_connect_event()
340
+ else:
341
+ raise OSError(err, errorcode[err])
342
+
343
+ def accept(self):
344
+ # XXX can return either an address pair or None
345
+ try:
346
+ conn, addr = self.socket.accept()
347
+ except TypeError:
348
+ return None
349
+ except OSError as why:
350
+ if why.errno in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
351
+ return None
352
+ else:
353
+ raise
354
+ else:
355
+ return conn, addr
356
+
357
+ def send(self, data):
358
+ try:
359
+ result = self.socket.send(data)
360
+ return result
361
+ except OSError as why:
362
+ if why.errno == EWOULDBLOCK:
363
+ return 0
364
+ elif why.errno in _DISCONNECTED:
365
+ self.handle_close()
366
+ return 0
367
+ else:
368
+ raise
369
+
370
+ def recv(self, buffer_size):
371
+ try:
372
+ data = self.socket.recv(buffer_size)
373
+ if not data:
374
+ # a closed connection is indicated by signaling
375
+ # a read condition, and having recv() return 0.
376
+ self.handle_close()
377
+ return b''
378
+ else:
379
+ return data
380
+ except OSError as why:
381
+ # winsock sometimes raises ENOTCONN
382
+ if why.errno in _DISCONNECTED:
383
+ self.handle_close()
384
+ return b''
385
+ else:
386
+ raise
387
+
388
+ def close(self):
389
+ self.connected = False
390
+ self.accepting = False
391
+ self.connecting = False
392
+ self.del_channel()
393
+ if self.socket is not None:
394
+ try:
395
+ self.socket.close()
396
+ except OSError as why:
397
+ if why.errno not in (ENOTCONN, EBADF):
398
+ raise
399
+
400
+ # log and log_info may be overridden to provide more sophisticated
401
+ # logging and warning methods. In general, log is for 'hit' logging
402
+ # and 'log_info' is for informational, warning and error logging.
403
+
404
+ def log(self, message):
405
+ sys.stderr.write('log: %s\n' % str(message))
406
+
407
+ def log_info(self, message, type='info'):
408
+ if type not in self.ignore_log_types:
409
+ print('%s: %s' % (type, message))
410
+
411
+ def handle_read_event(self):
412
+ if self.accepting:
413
+ # accepting sockets are never connected, they "spawn" new
414
+ # sockets that are connected
415
+ self.handle_accept()
416
+ elif not self.connected:
417
+ if self.connecting:
418
+ self.handle_connect_event()
419
+ self.handle_read()
420
+ else:
421
+ self.handle_read()
422
+
423
+ def handle_connect_event(self):
424
+ err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
425
+ if err != 0:
426
+ raise OSError(err, _strerror(err))
427
+ self.handle_connect()
428
+ self.connected = True
429
+ self.connecting = False
430
+
431
+ def handle_write_event(self):
432
+ if self.accepting:
433
+ # Accepting sockets shouldn't get a write event.
434
+ # We will pretend it didn't happen.
435
+ return
436
+
437
+ if not self.connected:
438
+ if self.connecting:
439
+ self.handle_connect_event()
440
+ self.handle_write()
441
+
442
+ def handle_expt_event(self):
443
+ # handle_expt_event() is called if there might be an error on the
444
+ # socket, or if there is OOB data
445
+ # check for the error condition first
446
+ err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
447
+ if err != 0:
448
+ # we can get here when select.select() says that there is an
449
+ # exceptional condition on the socket
450
+ # since there is an error, we'll go ahead and close the socket
451
+ # like we would in a subclassed handle_read() that received no
452
+ # data
453
+ self.handle_close()
454
+ else:
455
+ self.handle_expt()
456
+
457
+ def handle_error(self):
458
+ nil, t, v, tbinfo = compact_traceback()
459
+
460
+ # sometimes a user repr method will crash.
461
+ try:
462
+ self_repr = repr(self)
463
+ except:
464
+ self_repr = '<__repr__(self) failed for object at %0x>' % id(self)
465
+
466
+ self.log_info(
467
+ 'uncaptured python exception, closing channel %s (%s:%s %s)' % (
468
+ self_repr,
469
+ t,
470
+ v,
471
+ tbinfo
472
+ ),
473
+ 'error'
474
+ )
475
+ self.handle_close()
476
+
477
+ def handle_expt(self):
478
+ self.log_info('unhandled incoming priority event', 'warning')
479
+
480
+ def handle_read(self):
481
+ self.log_info('unhandled read event', 'warning')
482
+
483
+ def handle_write(self):
484
+ self.log_info('unhandled write event', 'warning')
485
+
486
+ def handle_connect(self):
487
+ self.log_info('unhandled connect event', 'warning')
488
+
489
+ def handle_accept(self):
490
+ pair = self.accept()
491
+ if pair is not None:
492
+ self.handle_accepted(*pair)
493
+
494
+ def handle_accepted(self, sock, addr):
495
+ sock.close()
496
+ self.log_info('unhandled accepted event', 'warning')
497
+
498
+ def handle_close(self):
499
+ self.log_info('unhandled close event', 'warning')
500
+ self.close()
501
+
502
+ # ---------------------------------------------------------------------------
503
+ # adds simple buffered output capability, useful for simple clients.
504
+ # [for more sophisticated usage use asynchat.async_chat]
505
+ # ---------------------------------------------------------------------------
506
+
507
+ class dispatcher_with_send(dispatcher):
508
+
509
+ def __init__(self, sock=None, map=None):
510
+ dispatcher.__init__(self, sock, map)
511
+ self.out_buffer = b''
512
+
513
+ def initiate_send(self):
514
+ num_sent = 0
515
+ num_sent = dispatcher.send(self, self.out_buffer[:65536])
516
+ self.out_buffer = self.out_buffer[num_sent:]
517
+
518
+ def handle_write(self):
519
+ self.initiate_send()
520
+
521
+ def writable(self):
522
+ return (not self.connected) or len(self.out_buffer)
523
+
524
+ def send(self, data):
525
+ if self.debug:
526
+ self.log_info('sending %s' % repr(data))
527
+ self.out_buffer = self.out_buffer + data
528
+ self.initiate_send()
529
+
530
+ # ---------------------------------------------------------------------------
531
+ # used for debugging.
532
+ # ---------------------------------------------------------------------------
533
+
534
+ def compact_traceback():
535
+ t, v, tb = sys.exc_info()
536
+ tbinfo = []
537
+ if not tb: # Must have a traceback
538
+ raise AssertionError("traceback does not exist")
539
+ while tb:
540
+ tbinfo.append((
541
+ tb.tb_frame.f_code.co_filename,
542
+ tb.tb_frame.f_code.co_name,
543
+ str(tb.tb_lineno)
544
+ ))
545
+ tb = tb.tb_next
546
+
547
+ # just to be safe
548
+ del tb
549
+
550
+ file, function, line = tbinfo[-1]
551
+ info = ' '.join(['[%s|%s|%s]' % x for x in tbinfo])
552
+ return (file, function, line), t, v, info
553
+
554
+ def close_all(map=None, ignore_all=False):
555
+ if map is None:
556
+ map = socket_map
557
+ for x in list(map.values()):
558
+ try:
559
+ x.close()
560
+ except OSError as x:
561
+ if x.errno == EBADF:
562
+ pass
563
+ elif not ignore_all:
564
+ raise
565
+ except _reraised_exceptions:
566
+ raise
567
+ except:
568
+ if not ignore_all:
569
+ raise
570
+ map.clear()
571
+
572
+ # Asynchronous File I/O:
573
+ #
574
+ # After a little research (reading man pages on various unixen, and
575
+ # digging through the linux kernel), I've determined that select()
576
+ # isn't meant for doing asynchronous file i/o.
577
+ # Heartening, though - reading linux/mm/filemap.c shows that linux
578
+ # supports asynchronous read-ahead. So _MOST_ of the time, the data
579
+ # will be sitting in memory for us already when we go to read it.
580
+ #
581
+ # What other OS's (besides NT) support async file i/o? [VMS?]
582
+ #
583
+ # Regardless, this is useful for pipes, and stdin/stdout...
584
+
585
+ if os.name == 'posix':
586
+ class file_wrapper:
587
+ # Here we override just enough to make a file
588
+ # look like a socket for the purposes of asyncore.
589
+ # The passed fd is automatically os.dup()'d
590
+
591
+ def __init__(self, fd):
592
+ self.fd = os.dup(fd)
593
+
594
+ def __del__(self):
595
+ if self.fd >= 0:
596
+ warnings.warn("unclosed file %r" % self, ResourceWarning,
597
+ source=self)
598
+ self.close()
599
+
600
+ def recv(self, *args):
601
+ return os.read(self.fd, *args)
602
+
603
+ def send(self, *args):
604
+ return os.write(self.fd, *args)
605
+
606
+ def getsockopt(self, level, optname, buflen=None):
607
+ if (level == socket.SOL_SOCKET and
608
+ optname == socket.SO_ERROR and
609
+ not buflen):
610
+ return 0
611
+ raise NotImplementedError("Only asyncore specific behaviour "
612
+ "implemented.")
613
+
614
+ read = recv
615
+ write = send
616
+
617
+ def close(self):
618
+ if self.fd < 0:
619
+ return
620
+ fd = self.fd
621
+ self.fd = -1
622
+ os.close(fd)
623
+
624
+ def fileno(self):
625
+ return self.fd
626
+
627
+ class file_dispatcher(dispatcher):
628
+
629
+ def __init__(self, fd, map=None):
630
+ dispatcher.__init__(self, None, map)
631
+ self.connected = True
632
+ try:
633
+ fd = fd.fileno()
634
+ except AttributeError:
635
+ pass
636
+ self.set_file(fd)
637
+ # set it to non-blocking mode
638
+ os.set_blocking(fd, False)
639
+
640
+ def set_file(self, fd):
641
+ self.socket = file_wrapper(fd)
642
+ self._fileno = self.socket.fileno()
643
+ self.add_channel()
hazelcast/client.py CHANGED
@@ -21,6 +21,7 @@ from hazelcast.protocol.codec import (
21
21
  client_add_distributed_object_listener_codec,
22
22
  client_get_distributed_objects_codec,
23
23
  client_remove_distributed_object_listener_codec,
24
+ dynamic_config_add_vector_collection_config_codec,
24
25
  )
25
26
  from hazelcast.proxy import (
26
27
  EXECUTOR_SERVICE,
@@ -35,6 +36,7 @@ from hazelcast.proxy import (
35
36
  RINGBUFFER_SERVICE,
36
37
  SET_SERVICE,
37
38
  TOPIC_SERVICE,
39
+ VECTOR_SERVICE,
38
40
  Executor,
39
41
  FlakeIdGenerator,
40
42
  List,
@@ -50,6 +52,7 @@ from hazelcast.proxy import (
50
52
  )
51
53
  from hazelcast.proxy.base import Proxy
52
54
  from hazelcast.proxy.map import Map
55
+ from hazelcast.proxy.vector_collection import VectorCollection
53
56
  from hazelcast.reactor import AsyncoreReactor
54
57
  from hazelcast.serialization import SerializationServiceV1
55
58
  from hazelcast.sql import SqlService, _InternalSqlService
@@ -60,6 +63,8 @@ from hazelcast.util import AtomicInteger, RoundRobinLB
60
63
 
61
64
  __all__ = ("HazelcastClient",)
62
65
 
66
+ from hazelcast.vector import IndexConfig
67
+
63
68
  _logger = logging.getLogger(__name__)
64
69
 
65
70
 
@@ -373,6 +378,21 @@ class HazelcastClient:
373
378
  """
374
379
  return self._proxy_manager.get_or_create(TOPIC_SERVICE, name)
375
380
 
381
+ def create_vector_collection_config(self, name: str, indexes: typing.List[IndexConfig]) -> None:
382
+ # check that indexes have different names
383
+ if indexes:
384
+ index_names = set(index.name for index in indexes)
385
+ if len(index_names) != len(indexes):
386
+ raise AssertionError("index names must be unique")
387
+
388
+ request = dynamic_config_add_vector_collection_config_codec.encode_request(name, indexes)
389
+ invocation = Invocation(request, response_handler=lambda m: m)
390
+ self._invocation_service.invoke(invocation)
391
+ invocation.future.result()
392
+
393
+ def get_vector_collection(self, name: str) -> VectorCollection:
394
+ return self._proxy_manager.get_or_create(VECTOR_SERVICE, name)
395
+
376
396
  def new_transaction(
377
397
  self, timeout: float = 120, durability: int = 1, type: int = TWO_PHASE
378
398
  ) -> Transaction:
@@ -530,7 +550,7 @@ class HazelcastClient:
530
550
  if address_list_provided and cloud_enabled:
531
551
  raise IllegalStateError(
532
552
  "Only one discovery method can be enabled at a time. "
533
- "Cluster members given explicitly: %s, Hazelcast Viridian enabled: %s"
553
+ "Cluster members given explicitly: %s, Hazelcast Cloud enabled: %s"
534
554
  % (address_list_provided, cloud_enabled)
535
555
  )
536
556