queue-local 0.0.34__tar.gz → 0.0.39__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: queue-local
3
- Version: 0.0.34
3
+ Version: 0.0.39
4
4
  Home-page: https://github.com/circles-zone/queue-local-python-package
5
5
  Author: Circles
6
6
  Author-email: info@circles.life
@@ -8,11 +8,9 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: Other/Proprietary License
9
9
  Classifier: Operating System :: OS Independent
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: mysql-connector>=2.2.9
12
11
  Requires-Dist: pytest>=7.4.1
13
12
  Requires-Dist: database-mysql-local>=0.0.120
14
13
  Requires-Dist: logger-local>=0.0.59
15
14
  Requires-Dist: user-context-remote>=0.0.30
16
- Requires-Dist: requests>=2.22.0
17
15
 
18
16
  queue-local
@@ -3,11 +3,13 @@
3
3
  ## Usage:
4
4
 
5
5
  Install:
6
+
6
7
  ```bash
7
8
  pip install queue-local
8
9
  ```
9
- - It's recommended to add `queue-local` to your `requirements.txt` file if you're using it as part of your project dependencies.
10
10
 
11
+ - It's recommended to add `queue-local` to your `requirements.txt` file if you're using it as part of your project
12
+ dependencies.
11
13
 
12
14
  ### Using the `DatabaseQueue` Class:
13
15
 
@@ -24,7 +26,7 @@ q.push({"item_description": "test 2", "action_id": 2, "parameters_json": {'a': 1
24
26
  result1 = q.peek() # "test 1" is still in the queue
25
27
 
26
28
  # Get an item from the queue (and remove it) based on action_id
27
- result2 = q.get(action_ids=(2, )) # Gets "test 2" (the first item with action_id=2)
29
+ result2 = q.get(action_ids=(2,)) # Gets "test 2" (the first item with action_id=2)
28
30
 
29
31
  # Get an item from the queue (and remove it)
30
32
  result3 = q.get() # Gets "test 1"
@@ -32,17 +34,16 @@ result3 = q.get() # Gets "test 1"
32
34
  q.close() # close the database connection
33
35
  ```
34
36
 
35
-
36
-
37
37
  ### Inheriting from the Abstract `OurQueue` Class:
38
38
 
39
39
  ```py
40
40
  from queue_local.our_queue import OurQueue
41
41
 
42
+
42
43
  class YourCustomQueue(OurQueue):
43
44
  def __init__(self):
44
45
  pass
45
-
46
+
46
47
  def push(self, item):
47
48
  """Push an item to the queue"""
48
49
  pass
@@ -1,15 +1,12 @@
1
1
  import json
2
2
  import os
3
- import threading
4
3
  from collections.abc import Iterable
5
4
  from enum import Enum
6
5
 
7
6
  import mysql.connector
8
- import requests
9
- from circles_local_database_python.connector import Connector
10
- from circles_local_database_python.generic_crud import GenericCRUD
11
- from logger_local.Logger import Logger
7
+ from database_mysql_local.generic_crud import GenericCRUD
12
8
  from logger_local.LoggerComponentEnum import LoggerComponentEnum
9
+ from logger_local.LoggerLocal import Logger
13
10
  from user_context_remote.user_context import UserContext
14
11
 
15
12
  from .our_queue import OurQueue
@@ -18,9 +15,6 @@ QUEUE_LOCAL_PYTHON_COMPONENT_ID = 155
18
15
  QUEUE_LOCAL_PYTHON_COMPONENT_NAME = "queue_local/src/database_queue.py"
19
16
  DEVELOPER_EMAIL = 'akiva.s@circ.zone'
20
17
 
21
- ip_v4 = requests.get('https://ipv4.seeip.org/jsonip').json()['ip']
22
- ip_v6 = requests.get('https://api.seeip.org/jsonip').json()['ip']
23
-
24
18
 
25
19
  class StatusEnum(Enum):
26
20
  NEW = 0
@@ -29,11 +23,25 @@ class StatusEnum(Enum):
29
23
 
30
24
  class DatabaseQueue(OurQueue, GenericCRUD):
31
25
  """A queue that uses a database table as the queue."""
32
- def __init__(self, schema_name: str = "queue", table_name: str = "queue_item_table", view_name: str = "queue_item_view",
33
- id_column_name: str = "queue_item_id", connection: Connector = None) -> None:
26
+
27
+ def __init__(self, schema_name: str = "queue", table_name: str = "queue_item_table",
28
+ view_name: str = "queue_item_view", id_column_name: str = "queue_item_id") -> None:
34
29
  """Initialize the queue.
30
+ Make sure the table has the following columns:
31
+ queue_status_id, action_id, process_id, user_jwt
32
+ created_user_id, updated_user_id
33
+ created_timestamp, updated_timestamp, start_timestamp, end_timestamp
34
+
35
+ ALTER TABLE `invitation`.`invitation_table`
36
+ ADD COLUMN `queue_status_id` SMALLINT UNSIGNED NULL AFTER `updated_effective_profile_id`,
37
+ ADD COLUMN `action_id` SMALLINT UNSIGNED NULL AFTER `queue_status_id`,
38
+ ADD COLUMN `process_id` MEDIUMINT UNSIGNED NULL AFTER `action_id`,
39
+ ADD COLUMN `user_jwt` VARCHAR(255) NULL AFTER `process_id`;
40
+
41
+
35
42
  Default schema_name = the first part of the table_name, before the first underscore.
36
- Default view_name = table_name with "_view" instead of "_table" (or "_view" added to the end if there is no "_table").
43
+ Default view_name = table_name with "_view" instead of "_table"
44
+ (or "_view" added to the end if there is no "_table").
37
45
  You can pass a Connector object to use an existing connection, or None to create a new connection.
38
46
  """
39
47
  self.logger = Logger(
@@ -53,10 +61,11 @@ class DatabaseQueue(OurQueue, GenericCRUD):
53
61
  schema_name = table_name.split("_")[0]
54
62
  self.id_column_name = id_column_name
55
63
 
56
- GenericCRUD.__init__(self, default_schema_name=schema_name, default_table_name=table_name, default_view_table_name=view_name,
57
- default_id_column_name=id_column_name, connection=connection)
64
+ GenericCRUD.__init__(self, default_schema_name=schema_name, default_table_name=table_name,
65
+ default_view_table_name=view_name, default_id_column_name=id_column_name)
58
66
  self.logger.info("DatabaseQueue initialized successfully", object={
59
- "schema_name": schema_name, "table_name": table_name, "view_name": view_name, "id_column_name": id_column_name})
67
+ "schema_name": schema_name, "table_name": table_name,
68
+ "view_name": view_name, "id_column_name": id_column_name})
60
69
  self.user = UserContext()
61
70
 
62
71
  def push(self, data_json: dict) -> int:
@@ -71,7 +80,7 @@ class DatabaseQueue(OurQueue, GenericCRUD):
71
80
  data_json["queue_status_id"] = StatusEnum.NEW.value
72
81
  data_json["created_user_id"] = created_user_id
73
82
 
74
- queue_id = self.insert(data_json=data_json) # returning the queue_id for messages-local
83
+ queue_id = self.insert(data_json=data_json) # returning the queue_id for messages-local
75
84
  self.logger.end("Entry pushed to the queue database successfully")
76
85
  except Exception as e:
77
86
  self.logger.exception("Error while pushing entry to the queue database", object=e)
@@ -107,12 +116,11 @@ class DatabaseQueue(OurQueue, GenericCRUD):
107
116
  queue_item = self.select_one_dict_by_where(where=select_where)
108
117
  if queue_item:
109
118
  # Update the selected queue item
110
- query = f"UPDATE {self.default_table_name} " \
111
- f"SET queue_status_id=%s, updated_user_id=%s, user_jwt=%s, thread_id=%s," \
112
- f"server_ip_v4=%s, server_ip_v6=%s " \
119
+ query = f"UPDATE {self.schema_name}.{self.default_table_name} " \
120
+ f"SET queue_status_id=%s, updated_user_id=%s, user_jwt=%s, updated_timestamp = NOW() " \
113
121
  f"WHERE {self.id_column_name} = %s"
114
- params = (StatusEnum.RETRIEVED.value, updated_user_id, self.user.get_user_JWT(),
115
- get_thread_id(), ip_v4, ip_v6, queue_item[self.id_column_name])
122
+ params = (StatusEnum.RETRIEVED.value, updated_user_id, self.user.get_user_jwt(),
123
+ queue_item[self.id_column_name])
116
124
  self.cursor.execute(query, params)
117
125
  self.connection.commit()
118
126
  self.logger.end("Entry retrieved and updated from the queue database successfully",
@@ -159,8 +167,3 @@ class DatabaseQueue(OurQueue, GenericCRUD):
159
167
  data_json[key] = value.replace("'", '"')
160
168
  else:
161
169
  data_json[key] = json.dumps(value)
162
-
163
-
164
- def get_thread_id():
165
- """Returns the current thread ID"""
166
- return threading.current_thread().ident
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: queue-local
3
- Version: 0.0.34
3
+ Version: 0.0.39
4
4
  Home-page: https://github.com/circles-zone/queue-local-python-package
5
5
  Author: Circles
6
6
  Author-email: info@circles.life
@@ -8,11 +8,9 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: Other/Proprietary License
9
9
  Classifier: Operating System :: OS Independent
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: mysql-connector>=2.2.9
12
11
  Requires-Dist: pytest>=7.4.1
13
12
  Requires-Dist: database-mysql-local>=0.0.120
14
13
  Requires-Dist: logger-local>=0.0.59
15
14
  Requires-Dist: user-context-remote>=0.0.30
16
- Requires-Dist: requests>=2.22.0
17
15
 
18
16
  queue-local
@@ -1,5 +1,4 @@
1
1
  README.md
2
- pyproject.toml
3
2
  setup.py
4
3
  queue_local.egg-info/PKG-INFO
5
4
  queue_local.egg-info/SOURCES.txt
@@ -1,6 +1,4 @@
1
- mysql-connector>=2.2.9
2
1
  pytest>=7.4.1
3
2
  database-mysql-local>=0.0.120
4
3
  logger-local>=0.0.59
5
4
  user-context-remote>=0.0.30
6
- requests>=2.22.0
@@ -5,7 +5,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
5
5
 
6
6
  setuptools.setup(
7
7
  name=PACKAGE_NAME, # https://pypi.org/project/queue-local
8
- version='0.0.34',
8
+ version='0.0.39',
9
9
  author="Circles",
10
10
  author_email="info@circles.life",
11
11
  url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
@@ -19,11 +19,9 @@ setuptools.setup(
19
19
  "License :: Other/Proprietary License",
20
20
  "Operating System :: OS Independent",
21
21
  ],
22
- install_requires=["mysql-connector>=2.2.9",
23
- "pytest>=7.4.1",
22
+ install_requires=["pytest>=7.4.1",
24
23
  "database-mysql-local>=0.0.120",
25
24
  "logger-local>=0.0.59",
26
25
  "user-context-remote>=0.0.30",
27
- "requests>=2.22.0",
28
26
  ]
29
27
  )
@@ -1,14 +0,0 @@
1
- # https://python-poetry.org/docs/pyproject
2
-
3
- [build-system]
4
- requires = ["setuptools>=61.0"]
5
- build-backend = "setuptools.build_meta"
6
-
7
- [tool.poetry]
8
- name = "queue-local"
9
- version = "0.0.26"
10
- description = "Queue Local Python Package"
11
- readme = "README.md"
12
- authors = [
13
- "Circlez.ai <info@circlez.ai>",
14
- ]
File without changes