queue-local 0.0.38__tar.gz → 0.0.40__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.
- {queue-local-0.0.38 → queue-local-0.0.40}/PKG-INFO +1 -2
- {queue-local-0.0.38 → queue-local-0.0.40}/README.md +6 -5
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local/src/database_queue.py +21 -14
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local/src/our_queue.py +0 -4
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local.egg-info/PKG-INFO +1 -2
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local.egg-info/requires.txt +0 -1
- {queue-local-0.0.38 → queue-local-0.0.40}/setup.py +2 -3
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local/src/__init__.py +0 -0
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local.egg-info/SOURCES.txt +0 -0
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local.egg-info/dependency_links.txt +0 -0
- {queue-local-0.0.38 → queue-local-0.0.40}/queue_local.egg-info/top_level.txt +0 -0
- {queue-local-0.0.38 → queue-local-0.0.40}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: queue-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.40
|
|
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,7 +8,6 @@ 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: pytest>=7.4.1
|
|
12
11
|
Requires-Dist: database-mysql-local>=0.0.120
|
|
13
12
|
Requires-Dist: logger-local>=0.0.59
|
|
14
13
|
Requires-Dist: user-context-remote>=0.0.30
|
|
@@ -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,
|
|
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
|
|
@@ -4,10 +4,9 @@ from collections.abc import Iterable
|
|
|
4
4
|
from enum import Enum
|
|
5
5
|
|
|
6
6
|
import mysql.connector
|
|
7
|
-
from
|
|
8
|
-
from circles_local_database_python.generic_crud import GenericCRUD
|
|
9
|
-
from logger_local.Logger import Logger
|
|
7
|
+
from database_mysql_local.generic_crud import GenericCRUD
|
|
10
8
|
from logger_local.LoggerComponentEnum import LoggerComponentEnum
|
|
9
|
+
from logger_local.LoggerLocal import Logger
|
|
11
10
|
from user_context_remote.user_context import UserContext
|
|
12
11
|
|
|
13
12
|
from .our_queue import OurQueue
|
|
@@ -27,13 +26,20 @@ class DatabaseQueue(OurQueue, GenericCRUD):
|
|
|
27
26
|
|
|
28
27
|
def __init__(self, schema_name: str = "queue", table_name: str = "queue_item_table",
|
|
29
28
|
view_name: str = "queue_item_view", id_column_name: str = "queue_item_id",
|
|
30
|
-
|
|
29
|
+
is_test_data: bool = False) -> None:
|
|
31
30
|
"""Initialize the queue.
|
|
32
31
|
Make sure the table has the following columns:
|
|
33
32
|
queue_status_id, action_id, process_id, user_jwt
|
|
34
33
|
created_user_id, updated_user_id
|
|
35
34
|
created_timestamp, updated_timestamp, start_timestamp, end_timestamp
|
|
36
35
|
|
|
36
|
+
ALTER TABLE `invitation`.`invitation_table`
|
|
37
|
+
ADD COLUMN `queue_status_id` SMALLINT UNSIGNED NULL AFTER `updated_effective_profile_id`,
|
|
38
|
+
ADD COLUMN `action_id` SMALLINT UNSIGNED NULL AFTER `queue_status_id`,
|
|
39
|
+
ADD COLUMN `process_id` MEDIUMINT UNSIGNED NULL AFTER `action_id`,
|
|
40
|
+
ADD COLUMN `user_jwt` VARCHAR(255) NULL AFTER `process_id`;
|
|
41
|
+
|
|
42
|
+
|
|
37
43
|
Default schema_name = the first part of the table_name, before the first underscore.
|
|
38
44
|
Default view_name = table_name with "_view" instead of "_table"
|
|
39
45
|
(or "_view" added to the end if there is no "_table").
|
|
@@ -58,11 +64,11 @@ class DatabaseQueue(OurQueue, GenericCRUD):
|
|
|
58
64
|
|
|
59
65
|
GenericCRUD.__init__(self, default_schema_name=schema_name, default_table_name=table_name,
|
|
60
66
|
default_view_table_name=view_name, default_id_column_name=id_column_name,
|
|
61
|
-
|
|
67
|
+
is_test_data=is_test_data)
|
|
62
68
|
self.logger.info("DatabaseQueue initialized successfully", object={
|
|
63
69
|
"schema_name": schema_name, "table_name": table_name,
|
|
64
70
|
"view_name": view_name, "id_column_name": id_column_name})
|
|
65
|
-
self.
|
|
71
|
+
self.user_context = UserContext().login_using_user_identification_and_password()
|
|
66
72
|
|
|
67
73
|
def push(self, data_json: dict) -> int:
|
|
68
74
|
"""Pushes a new entry to the queue.
|
|
@@ -78,9 +84,9 @@ class DatabaseQueue(OurQueue, GenericCRUD):
|
|
|
78
84
|
|
|
79
85
|
queue_id = self.insert(data_json=data_json) # returning the queue_id for messages-local
|
|
80
86
|
self.logger.end("Entry pushed to the queue database successfully")
|
|
81
|
-
except Exception as
|
|
82
|
-
self.logger.
|
|
83
|
-
raise
|
|
87
|
+
except Exception as exception:
|
|
88
|
+
self.logger.error("Error while pushing entry to the queue database", object=exception)
|
|
89
|
+
raise exception
|
|
84
90
|
return queue_id
|
|
85
91
|
|
|
86
92
|
def push_back(self, queue_item: dict) -> None:
|
|
@@ -97,7 +103,7 @@ class DatabaseQueue(OurQueue, GenericCRUD):
|
|
|
97
103
|
:param action_ids: Tuple of action IDs to consider (optional).
|
|
98
104
|
:return: Dictionary representing the retrieved queue item.
|
|
99
105
|
"""
|
|
100
|
-
updated_user_id = self.
|
|
106
|
+
updated_user_id = self.user_context.get_effective_user_id()
|
|
101
107
|
self.logger.start("Getting and updating queue item from the queue database", object={"action_ids": action_ids})
|
|
102
108
|
action_ids = self._fix_action_ids(action_ids)
|
|
103
109
|
|
|
@@ -115,7 +121,7 @@ class DatabaseQueue(OurQueue, GenericCRUD):
|
|
|
115
121
|
query = f"UPDATE {self.schema_name}.{self.default_table_name} " \
|
|
116
122
|
f"SET queue_status_id=%s, updated_user_id=%s, user_jwt=%s, updated_timestamp = NOW() " \
|
|
117
123
|
f"WHERE {self.id_column_name} = %s"
|
|
118
|
-
params = (StatusEnum.RETRIEVED.value, updated_user_id, self.
|
|
124
|
+
params = (StatusEnum.RETRIEVED.value, updated_user_id, self.user_context.get_user_jwt(),
|
|
119
125
|
queue_item[self.id_column_name])
|
|
120
126
|
self.cursor.execute(query, params)
|
|
121
127
|
self.connection.commit()
|
|
@@ -123,10 +129,11 @@ class DatabaseQueue(OurQueue, GenericCRUD):
|
|
|
123
129
|
object=queue_item)
|
|
124
130
|
else:
|
|
125
131
|
self.logger.end("The queue is empty")
|
|
126
|
-
except mysql.connector.Error as
|
|
132
|
+
except mysql.connector.Error as exception:
|
|
127
133
|
self.connection.rollback()
|
|
128
|
-
self.logger.
|
|
129
|
-
|
|
134
|
+
self.logger.error("Error while getting and updating queue item from the queue database",
|
|
135
|
+
object=exception)
|
|
136
|
+
raise exception
|
|
130
137
|
return queue_item
|
|
131
138
|
|
|
132
139
|
def peek(self, action_ids: tuple = ()) -> dict:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: queue-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.40
|
|
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,7 +8,6 @@ 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: pytest>=7.4.1
|
|
12
11
|
Requires-Dist: database-mysql-local>=0.0.120
|
|
13
12
|
Requires-Dist: logger-local>=0.0.59
|
|
14
13
|
Requires-Dist: user-context-remote>=0.0.30
|
|
@@ -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.
|
|
8
|
+
version='0.0.40',
|
|
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,8 +19,7 @@ setuptools.setup(
|
|
|
19
19
|
"License :: Other/Proprietary License",
|
|
20
20
|
"Operating System :: OS Independent",
|
|
21
21
|
],
|
|
22
|
-
install_requires=["
|
|
23
|
-
"database-mysql-local>=0.0.120",
|
|
22
|
+
install_requires=["database-mysql-local>=0.0.120",
|
|
24
23
|
"logger-local>=0.0.59",
|
|
25
24
|
"user-context-remote>=0.0.30",
|
|
26
25
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|