astraflux 1.0.1__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.
- astraflux-1.0.1/LICENSE +21 -0
- astraflux-1.0.1/PKG-INFO +210 -0
- astraflux-1.0.1/README.rst +174 -0
- astraflux-1.0.1/astraflux.egg-info/PKG-INFO +210 -0
- astraflux-1.0.1/astraflux.egg-info/SOURCES.txt +57 -0
- astraflux-1.0.1/astraflux.egg-info/dependency_links.txt +1 -0
- astraflux-1.0.1/astraflux.egg-info/requires.txt +6 -0
- astraflux-1.0.1/astraflux.egg-info/top_level.txt +12 -0
- astraflux-1.0.1/databases/__init__.py +2 -0
- astraflux-1.0.1/databases/_databases_api.py +218 -0
- astraflux-1.0.1/databases/_mongodb.py +243 -0
- astraflux-1.0.1/databases/_redisdb.py +91 -0
- astraflux-1.0.1/generateId/__init__.py +1 -0
- astraflux-1.0.1/generateId/_snowflake.py +144 -0
- astraflux-1.0.1/inject/__init__.py +4 -0
- astraflux-1.0.1/inject/inject_implementation.py +21 -0
- astraflux-1.0.1/inject/inject_init.py +23 -0
- astraflux-1.0.1/interface/__init__.py +14 -0
- astraflux-1.0.1/interface/async_task.py +75 -0
- astraflux-1.0.1/interface/databases_api.py +96 -0
- astraflux-1.0.1/interface/format_time.py +208 -0
- astraflux-1.0.1/interface/logger.py +26 -0
- astraflux-1.0.1/interface/mongodb.py +167 -0
- astraflux-1.0.1/interface/network.py +30 -0
- astraflux-1.0.1/interface/rabbitmq.py +35 -0
- astraflux-1.0.1/interface/redisdb.py +61 -0
- astraflux-1.0.1/interface/rpc.py +80 -0
- astraflux-1.0.1/interface/run.py +34 -0
- astraflux-1.0.1/interface/scheduler.py +56 -0
- astraflux-1.0.1/interface/snowflake.py +14 -0
- astraflux-1.0.1/logger/__init__.py +1 -0
- astraflux-1.0.1/logger/_logger.py +93 -0
- astraflux-1.0.1/mq/__init__.py +1 -0
- astraflux-1.0.1/mq/_rabbitmq.py +123 -0
- astraflux-1.0.1/rpc/__init__.py +1 -0
- astraflux-1.0.1/rpc/_rpc.py +216 -0
- astraflux-1.0.1/rpc/client.py +203 -0
- astraflux-1.0.1/scheduler/__init__.py +1 -0
- astraflux-1.0.1/scheduler/_async_task.py +374 -0
- astraflux-1.0.1/scheduler/_scheduler.py +276 -0
- astraflux-1.0.1/scheduler/cronparser.py +106 -0
- astraflux-1.0.1/servers/__init__.py +1 -0
- astraflux-1.0.1/servers/_run.py +170 -0
- astraflux-1.0.1/servers/build.py +115 -0
- astraflux-1.0.1/servers/run_server.py +67 -0
- astraflux-1.0.1/servers/run_worker.py +206 -0
- astraflux-1.0.1/settings/__init__.py +5 -0
- astraflux-1.0.1/settings/_config_processing.py +139 -0
- astraflux-1.0.1/settings/config_processing.py +49 -0
- astraflux-1.0.1/settings/keys.py +114 -0
- astraflux-1.0.1/settings/meta.py +123 -0
- astraflux-1.0.1/setup.cfg +4 -0
- astraflux-1.0.1/setup.py +35 -0
- astraflux-1.0.1/utils/__init__.py +1 -0
- astraflux-1.0.1/utils/_format_time.py +306 -0
- astraflux-1.0.1/utils/_network.py +50 -0
- astraflux-1.0.1/workflows/__init__.py +4 -0
- astraflux-1.0.1/workflows/monitoring.py +185 -0
- astraflux-1.0.1/workflows/task_distribution.py +123 -0
astraflux-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ZhouYanPing<zyphhxx@foxmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
astraflux-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: astraflux
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: AstraFlux Description
|
|
5
|
+
Home-page: https://gitee.com/ZYPH/astra-flux
|
|
6
|
+
Author: YanPing
|
|
7
|
+
Author-email: zyphhxx@foxmail.com
|
|
8
|
+
Maintainer: YanPing
|
|
9
|
+
Maintainer-email: zyphhxx@foxmail.com
|
|
10
|
+
License: MIT License
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: psutil
|
|
19
|
+
Requires-Dist: pika
|
|
20
|
+
Requires-Dist: pytz
|
|
21
|
+
Requires-Dist: pymongo
|
|
22
|
+
Requires-Dist: pyyaml
|
|
23
|
+
Requires-Dist: redis
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: license
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: maintainer
|
|
32
|
+
Dynamic: maintainer-email
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
AstraFlux User Documentation
|
|
38
|
+
============================
|
|
39
|
+
|
|
40
|
+
.. code-block:: bash
|
|
41
|
+
|
|
42
|
+
AstraFlux enables rapid setup of distributed task systems with minimal configuration. Key features:
|
|
43
|
+
1.Asynchronous/scheduled tasks
|
|
44
|
+
2.Distributed task processing
|
|
45
|
+
3.Service registration, monitoring, dynamic configuration injection, load balancing
|
|
46
|
+
|
|
47
|
+
Framework Initialization
|
|
48
|
+
========================
|
|
49
|
+
|
|
50
|
+
.. code-block:: bash
|
|
51
|
+
|
|
52
|
+
1. Create File config.yaml
|
|
53
|
+
|
|
54
|
+
Mongodb:
|
|
55
|
+
host: 127.0.0.1
|
|
56
|
+
port: 27017
|
|
57
|
+
db: astraflux
|
|
58
|
+
username: scheduleAdmin
|
|
59
|
+
password: scheduleAdminPassword
|
|
60
|
+
|
|
61
|
+
Redis:
|
|
62
|
+
host: 127.0.0.1
|
|
63
|
+
port: 6379
|
|
64
|
+
password: scheduleAdminPassword
|
|
65
|
+
|
|
66
|
+
RabbitMQ:
|
|
67
|
+
host: 127.0.0.1
|
|
68
|
+
port: 5672
|
|
69
|
+
username: scheduleAdmin
|
|
70
|
+
password: scheduleAdminPassword
|
|
71
|
+
|
|
72
|
+
logger:
|
|
73
|
+
level: INFO
|
|
74
|
+
|
|
75
|
+
2. Initialize in main.py
|
|
76
|
+
|
|
77
|
+
import os
|
|
78
|
+
os_dir = os.path.dirname(__file__)
|
|
79
|
+
af = AstraFlux('config.yaml', os_dir)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
Service Registration
|
|
83
|
+
====================
|
|
84
|
+
|
|
85
|
+
1. Create service file (e.g., test_server.py):
|
|
86
|
+
|
|
87
|
+
.. code-block:: bash
|
|
88
|
+
|
|
89
|
+
# -*- coding: utf-8 -*-
|
|
90
|
+
|
|
91
|
+
from nexusflow import *
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class RpcFunction(ServiceConstructor):
|
|
95
|
+
service_name = 'test_server'
|
|
96
|
+
|
|
97
|
+
"""All functions are automatically proxied for RPC calls"""
|
|
98
|
+
|
|
99
|
+
def get_service_name(self):
|
|
100
|
+
return {"service_version": self.service_version}
|
|
101
|
+
|
|
102
|
+
def test_func(self, **args):
|
|
103
|
+
return args
|
|
104
|
+
|
|
105
|
+
class WorkerFunction(WorkerConstructor):
|
|
106
|
+
worker_name = 'test_server'
|
|
107
|
+
|
|
108
|
+
def run(self, data):
|
|
109
|
+
self.loguru.info(data)
|
|
110
|
+
"""
|
|
111
|
+
Executed when new tasks appear in worker_name queue.
|
|
112
|
+
Implement business logic here. `data` contains all task data.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
2. Register the service in main.py
|
|
116
|
+
|
|
117
|
+
.. code-block:: bash
|
|
118
|
+
|
|
119
|
+
import test_server
|
|
120
|
+
af.registry(services=[test_server])
|
|
121
|
+
|
|
122
|
+
af.start()
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
Scheduled/Asynchronous Tasks
|
|
126
|
+
============================
|
|
127
|
+
|
|
128
|
+
.. code-block:: bash
|
|
129
|
+
|
|
130
|
+
from nexusflow.interface import *
|
|
131
|
+
|
|
132
|
+
# Generate Snowflake ID
|
|
133
|
+
_id = snowflake_id()
|
|
134
|
+
|
|
135
|
+
# Create task
|
|
136
|
+
message = {'task_id': 'test_003', 'status': 'wait', 'name': 'xxxx'}
|
|
137
|
+
task_submit_databases(queue='test_server', message=message)
|
|
138
|
+
|
|
139
|
+
# Create subtasks (automatic status updates)
|
|
140
|
+
subtask_create(
|
|
141
|
+
source_task_id='test_003',
|
|
142
|
+
subtask_queue='test_server_sub',
|
|
143
|
+
subtasks=[{
|
|
144
|
+
'task_id': snowflake_id(),
|
|
145
|
+
'name': 'subtask1',
|
|
146
|
+
}]
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
# Stop task
|
|
150
|
+
task_stop(task_id='test_003')
|
|
151
|
+
|
|
152
|
+
# MongoDB interfaces
|
|
153
|
+
mongodb_task() # Task operations
|
|
154
|
+
mongodb_node() # Node operations
|
|
155
|
+
mongodb_services() # Service operations
|
|
156
|
+
|
|
157
|
+
# Redis interfaces
|
|
158
|
+
redis_task()
|
|
159
|
+
redis_services()
|
|
160
|
+
|
|
161
|
+
# RPC service call (auto load-balanced)
|
|
162
|
+
result = proxy_call(
|
|
163
|
+
service_name='test_server',
|
|
164
|
+
method_name='test_func',
|
|
165
|
+
a=1, b=2 # Function arguments
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
Function Reference
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
.. code-block:: bash
|
|
173
|
+
|
|
174
|
+
from nexusflow.interface import *
|
|
175
|
+
|
|
176
|
+
# Generate Snowflake ID
|
|
177
|
+
_id = snowflake_id()
|
|
178
|
+
|
|
179
|
+
# Create task
|
|
180
|
+
message = {'task_id': 'test_003', 'status': 'wait', 'name': 'xxxx'}
|
|
181
|
+
task_submit_databases(queue='test_server', message=message)
|
|
182
|
+
|
|
183
|
+
# Create subtasks (automatic status updates)
|
|
184
|
+
subtask_create(
|
|
185
|
+
source_task_id='test_003',
|
|
186
|
+
subtask_queue='test_server_sub',
|
|
187
|
+
subtasks=[{
|
|
188
|
+
'task_id': snowflake_id(),
|
|
189
|
+
'name': 'subtask1',
|
|
190
|
+
}]
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
# Stop task
|
|
194
|
+
task_stop(task_id='test_003')
|
|
195
|
+
|
|
196
|
+
# MongoDB interfaces
|
|
197
|
+
mongodb_task() # Task operations
|
|
198
|
+
mongodb_node() # Node operations
|
|
199
|
+
mongodb_services() # Service operations
|
|
200
|
+
|
|
201
|
+
# Redis interfaces
|
|
202
|
+
redis_task()
|
|
203
|
+
redis_services()
|
|
204
|
+
|
|
205
|
+
# RPC service call (auto load-balanced)
|
|
206
|
+
result = proxy_call(
|
|
207
|
+
service_name='test_server',
|
|
208
|
+
method_name='test_func',
|
|
209
|
+
a=1, b=2 # Function arguments
|
|
210
|
+
)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
AstraFlux User Documentation
|
|
2
|
+
============================
|
|
3
|
+
|
|
4
|
+
.. code-block:: bash
|
|
5
|
+
|
|
6
|
+
AstraFlux enables rapid setup of distributed task systems with minimal configuration. Key features:
|
|
7
|
+
1.Asynchronous/scheduled tasks
|
|
8
|
+
2.Distributed task processing
|
|
9
|
+
3.Service registration, monitoring, dynamic configuration injection, load balancing
|
|
10
|
+
|
|
11
|
+
Framework Initialization
|
|
12
|
+
========================
|
|
13
|
+
|
|
14
|
+
.. code-block:: bash
|
|
15
|
+
|
|
16
|
+
1. Create File config.yaml
|
|
17
|
+
|
|
18
|
+
Mongodb:
|
|
19
|
+
host: 127.0.0.1
|
|
20
|
+
port: 27017
|
|
21
|
+
db: astraflux
|
|
22
|
+
username: scheduleAdmin
|
|
23
|
+
password: scheduleAdminPassword
|
|
24
|
+
|
|
25
|
+
Redis:
|
|
26
|
+
host: 127.0.0.1
|
|
27
|
+
port: 6379
|
|
28
|
+
password: scheduleAdminPassword
|
|
29
|
+
|
|
30
|
+
RabbitMQ:
|
|
31
|
+
host: 127.0.0.1
|
|
32
|
+
port: 5672
|
|
33
|
+
username: scheduleAdmin
|
|
34
|
+
password: scheduleAdminPassword
|
|
35
|
+
|
|
36
|
+
logger:
|
|
37
|
+
level: INFO
|
|
38
|
+
|
|
39
|
+
2. Initialize in main.py
|
|
40
|
+
|
|
41
|
+
import os
|
|
42
|
+
os_dir = os.path.dirname(__file__)
|
|
43
|
+
af = AstraFlux('config.yaml', os_dir)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Service Registration
|
|
47
|
+
====================
|
|
48
|
+
|
|
49
|
+
1. Create service file (e.g., test_server.py):
|
|
50
|
+
|
|
51
|
+
.. code-block:: bash
|
|
52
|
+
|
|
53
|
+
# -*- coding: utf-8 -*-
|
|
54
|
+
|
|
55
|
+
from nexusflow import *
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class RpcFunction(ServiceConstructor):
|
|
59
|
+
service_name = 'test_server'
|
|
60
|
+
|
|
61
|
+
"""All functions are automatically proxied for RPC calls"""
|
|
62
|
+
|
|
63
|
+
def get_service_name(self):
|
|
64
|
+
return {"service_version": self.service_version}
|
|
65
|
+
|
|
66
|
+
def test_func(self, **args):
|
|
67
|
+
return args
|
|
68
|
+
|
|
69
|
+
class WorkerFunction(WorkerConstructor):
|
|
70
|
+
worker_name = 'test_server'
|
|
71
|
+
|
|
72
|
+
def run(self, data):
|
|
73
|
+
self.loguru.info(data)
|
|
74
|
+
"""
|
|
75
|
+
Executed when new tasks appear in worker_name queue.
|
|
76
|
+
Implement business logic here. `data` contains all task data.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
2. Register the service in main.py
|
|
80
|
+
|
|
81
|
+
.. code-block:: bash
|
|
82
|
+
|
|
83
|
+
import test_server
|
|
84
|
+
af.registry(services=[test_server])
|
|
85
|
+
|
|
86
|
+
af.start()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
Scheduled/Asynchronous Tasks
|
|
90
|
+
============================
|
|
91
|
+
|
|
92
|
+
.. code-block:: bash
|
|
93
|
+
|
|
94
|
+
from nexusflow.interface import *
|
|
95
|
+
|
|
96
|
+
# Generate Snowflake ID
|
|
97
|
+
_id = snowflake_id()
|
|
98
|
+
|
|
99
|
+
# Create task
|
|
100
|
+
message = {'task_id': 'test_003', 'status': 'wait', 'name': 'xxxx'}
|
|
101
|
+
task_submit_databases(queue='test_server', message=message)
|
|
102
|
+
|
|
103
|
+
# Create subtasks (automatic status updates)
|
|
104
|
+
subtask_create(
|
|
105
|
+
source_task_id='test_003',
|
|
106
|
+
subtask_queue='test_server_sub',
|
|
107
|
+
subtasks=[{
|
|
108
|
+
'task_id': snowflake_id(),
|
|
109
|
+
'name': 'subtask1',
|
|
110
|
+
}]
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# Stop task
|
|
114
|
+
task_stop(task_id='test_003')
|
|
115
|
+
|
|
116
|
+
# MongoDB interfaces
|
|
117
|
+
mongodb_task() # Task operations
|
|
118
|
+
mongodb_node() # Node operations
|
|
119
|
+
mongodb_services() # Service operations
|
|
120
|
+
|
|
121
|
+
# Redis interfaces
|
|
122
|
+
redis_task()
|
|
123
|
+
redis_services()
|
|
124
|
+
|
|
125
|
+
# RPC service call (auto load-balanced)
|
|
126
|
+
result = proxy_call(
|
|
127
|
+
service_name='test_server',
|
|
128
|
+
method_name='test_func',
|
|
129
|
+
a=1, b=2 # Function arguments
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
Function Reference
|
|
133
|
+
==================
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
.. code-block:: bash
|
|
137
|
+
|
|
138
|
+
from nexusflow.interface import *
|
|
139
|
+
|
|
140
|
+
# Generate Snowflake ID
|
|
141
|
+
_id = snowflake_id()
|
|
142
|
+
|
|
143
|
+
# Create task
|
|
144
|
+
message = {'task_id': 'test_003', 'status': 'wait', 'name': 'xxxx'}
|
|
145
|
+
task_submit_databases(queue='test_server', message=message)
|
|
146
|
+
|
|
147
|
+
# Create subtasks (automatic status updates)
|
|
148
|
+
subtask_create(
|
|
149
|
+
source_task_id='test_003',
|
|
150
|
+
subtask_queue='test_server_sub',
|
|
151
|
+
subtasks=[{
|
|
152
|
+
'task_id': snowflake_id(),
|
|
153
|
+
'name': 'subtask1',
|
|
154
|
+
}]
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# Stop task
|
|
158
|
+
task_stop(task_id='test_003')
|
|
159
|
+
|
|
160
|
+
# MongoDB interfaces
|
|
161
|
+
mongodb_task() # Task operations
|
|
162
|
+
mongodb_node() # Node operations
|
|
163
|
+
mongodb_services() # Service operations
|
|
164
|
+
|
|
165
|
+
# Redis interfaces
|
|
166
|
+
redis_task()
|
|
167
|
+
redis_services()
|
|
168
|
+
|
|
169
|
+
# RPC service call (auto load-balanced)
|
|
170
|
+
result = proxy_call(
|
|
171
|
+
service_name='test_server',
|
|
172
|
+
method_name='test_func',
|
|
173
|
+
a=1, b=2 # Function arguments
|
|
174
|
+
)
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: astraflux
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: AstraFlux Description
|
|
5
|
+
Home-page: https://gitee.com/ZYPH/astra-flux
|
|
6
|
+
Author: YanPing
|
|
7
|
+
Author-email: zyphhxx@foxmail.com
|
|
8
|
+
Maintainer: YanPing
|
|
9
|
+
Maintainer-email: zyphhxx@foxmail.com
|
|
10
|
+
License: MIT License
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: psutil
|
|
19
|
+
Requires-Dist: pika
|
|
20
|
+
Requires-Dist: pytz
|
|
21
|
+
Requires-Dist: pymongo
|
|
22
|
+
Requires-Dist: pyyaml
|
|
23
|
+
Requires-Dist: redis
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: license
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: maintainer
|
|
32
|
+
Dynamic: maintainer-email
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
AstraFlux User Documentation
|
|
38
|
+
============================
|
|
39
|
+
|
|
40
|
+
.. code-block:: bash
|
|
41
|
+
|
|
42
|
+
AstraFlux enables rapid setup of distributed task systems with minimal configuration. Key features:
|
|
43
|
+
1.Asynchronous/scheduled tasks
|
|
44
|
+
2.Distributed task processing
|
|
45
|
+
3.Service registration, monitoring, dynamic configuration injection, load balancing
|
|
46
|
+
|
|
47
|
+
Framework Initialization
|
|
48
|
+
========================
|
|
49
|
+
|
|
50
|
+
.. code-block:: bash
|
|
51
|
+
|
|
52
|
+
1. Create File config.yaml
|
|
53
|
+
|
|
54
|
+
Mongodb:
|
|
55
|
+
host: 127.0.0.1
|
|
56
|
+
port: 27017
|
|
57
|
+
db: astraflux
|
|
58
|
+
username: scheduleAdmin
|
|
59
|
+
password: scheduleAdminPassword
|
|
60
|
+
|
|
61
|
+
Redis:
|
|
62
|
+
host: 127.0.0.1
|
|
63
|
+
port: 6379
|
|
64
|
+
password: scheduleAdminPassword
|
|
65
|
+
|
|
66
|
+
RabbitMQ:
|
|
67
|
+
host: 127.0.0.1
|
|
68
|
+
port: 5672
|
|
69
|
+
username: scheduleAdmin
|
|
70
|
+
password: scheduleAdminPassword
|
|
71
|
+
|
|
72
|
+
logger:
|
|
73
|
+
level: INFO
|
|
74
|
+
|
|
75
|
+
2. Initialize in main.py
|
|
76
|
+
|
|
77
|
+
import os
|
|
78
|
+
os_dir = os.path.dirname(__file__)
|
|
79
|
+
af = AstraFlux('config.yaml', os_dir)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
Service Registration
|
|
83
|
+
====================
|
|
84
|
+
|
|
85
|
+
1. Create service file (e.g., test_server.py):
|
|
86
|
+
|
|
87
|
+
.. code-block:: bash
|
|
88
|
+
|
|
89
|
+
# -*- coding: utf-8 -*-
|
|
90
|
+
|
|
91
|
+
from nexusflow import *
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class RpcFunction(ServiceConstructor):
|
|
95
|
+
service_name = 'test_server'
|
|
96
|
+
|
|
97
|
+
"""All functions are automatically proxied for RPC calls"""
|
|
98
|
+
|
|
99
|
+
def get_service_name(self):
|
|
100
|
+
return {"service_version": self.service_version}
|
|
101
|
+
|
|
102
|
+
def test_func(self, **args):
|
|
103
|
+
return args
|
|
104
|
+
|
|
105
|
+
class WorkerFunction(WorkerConstructor):
|
|
106
|
+
worker_name = 'test_server'
|
|
107
|
+
|
|
108
|
+
def run(self, data):
|
|
109
|
+
self.loguru.info(data)
|
|
110
|
+
"""
|
|
111
|
+
Executed when new tasks appear in worker_name queue.
|
|
112
|
+
Implement business logic here. `data` contains all task data.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
2. Register the service in main.py
|
|
116
|
+
|
|
117
|
+
.. code-block:: bash
|
|
118
|
+
|
|
119
|
+
import test_server
|
|
120
|
+
af.registry(services=[test_server])
|
|
121
|
+
|
|
122
|
+
af.start()
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
Scheduled/Asynchronous Tasks
|
|
126
|
+
============================
|
|
127
|
+
|
|
128
|
+
.. code-block:: bash
|
|
129
|
+
|
|
130
|
+
from nexusflow.interface import *
|
|
131
|
+
|
|
132
|
+
# Generate Snowflake ID
|
|
133
|
+
_id = snowflake_id()
|
|
134
|
+
|
|
135
|
+
# Create task
|
|
136
|
+
message = {'task_id': 'test_003', 'status': 'wait', 'name': 'xxxx'}
|
|
137
|
+
task_submit_databases(queue='test_server', message=message)
|
|
138
|
+
|
|
139
|
+
# Create subtasks (automatic status updates)
|
|
140
|
+
subtask_create(
|
|
141
|
+
source_task_id='test_003',
|
|
142
|
+
subtask_queue='test_server_sub',
|
|
143
|
+
subtasks=[{
|
|
144
|
+
'task_id': snowflake_id(),
|
|
145
|
+
'name': 'subtask1',
|
|
146
|
+
}]
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
# Stop task
|
|
150
|
+
task_stop(task_id='test_003')
|
|
151
|
+
|
|
152
|
+
# MongoDB interfaces
|
|
153
|
+
mongodb_task() # Task operations
|
|
154
|
+
mongodb_node() # Node operations
|
|
155
|
+
mongodb_services() # Service operations
|
|
156
|
+
|
|
157
|
+
# Redis interfaces
|
|
158
|
+
redis_task()
|
|
159
|
+
redis_services()
|
|
160
|
+
|
|
161
|
+
# RPC service call (auto load-balanced)
|
|
162
|
+
result = proxy_call(
|
|
163
|
+
service_name='test_server',
|
|
164
|
+
method_name='test_func',
|
|
165
|
+
a=1, b=2 # Function arguments
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
Function Reference
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
.. code-block:: bash
|
|
173
|
+
|
|
174
|
+
from nexusflow.interface import *
|
|
175
|
+
|
|
176
|
+
# Generate Snowflake ID
|
|
177
|
+
_id = snowflake_id()
|
|
178
|
+
|
|
179
|
+
# Create task
|
|
180
|
+
message = {'task_id': 'test_003', 'status': 'wait', 'name': 'xxxx'}
|
|
181
|
+
task_submit_databases(queue='test_server', message=message)
|
|
182
|
+
|
|
183
|
+
# Create subtasks (automatic status updates)
|
|
184
|
+
subtask_create(
|
|
185
|
+
source_task_id='test_003',
|
|
186
|
+
subtask_queue='test_server_sub',
|
|
187
|
+
subtasks=[{
|
|
188
|
+
'task_id': snowflake_id(),
|
|
189
|
+
'name': 'subtask1',
|
|
190
|
+
}]
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
# Stop task
|
|
194
|
+
task_stop(task_id='test_003')
|
|
195
|
+
|
|
196
|
+
# MongoDB interfaces
|
|
197
|
+
mongodb_task() # Task operations
|
|
198
|
+
mongodb_node() # Node operations
|
|
199
|
+
mongodb_services() # Service operations
|
|
200
|
+
|
|
201
|
+
# Redis interfaces
|
|
202
|
+
redis_task()
|
|
203
|
+
redis_services()
|
|
204
|
+
|
|
205
|
+
# RPC service call (auto load-balanced)
|
|
206
|
+
result = proxy_call(
|
|
207
|
+
service_name='test_server',
|
|
208
|
+
method_name='test_func',
|
|
209
|
+
a=1, b=2 # Function arguments
|
|
210
|
+
)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.rst
|
|
3
|
+
setup.py
|
|
4
|
+
astraflux.egg-info/PKG-INFO
|
|
5
|
+
astraflux.egg-info/SOURCES.txt
|
|
6
|
+
astraflux.egg-info/dependency_links.txt
|
|
7
|
+
astraflux.egg-info/requires.txt
|
|
8
|
+
astraflux.egg-info/top_level.txt
|
|
9
|
+
databases/__init__.py
|
|
10
|
+
databases/_databases_api.py
|
|
11
|
+
databases/_mongodb.py
|
|
12
|
+
databases/_redisdb.py
|
|
13
|
+
generateId/__init__.py
|
|
14
|
+
generateId/_snowflake.py
|
|
15
|
+
inject/__init__.py
|
|
16
|
+
inject/inject_implementation.py
|
|
17
|
+
inject/inject_init.py
|
|
18
|
+
interface/__init__.py
|
|
19
|
+
interface/async_task.py
|
|
20
|
+
interface/databases_api.py
|
|
21
|
+
interface/format_time.py
|
|
22
|
+
interface/logger.py
|
|
23
|
+
interface/mongodb.py
|
|
24
|
+
interface/network.py
|
|
25
|
+
interface/rabbitmq.py
|
|
26
|
+
interface/redisdb.py
|
|
27
|
+
interface/rpc.py
|
|
28
|
+
interface/run.py
|
|
29
|
+
interface/scheduler.py
|
|
30
|
+
interface/snowflake.py
|
|
31
|
+
logger/__init__.py
|
|
32
|
+
logger/_logger.py
|
|
33
|
+
mq/__init__.py
|
|
34
|
+
mq/_rabbitmq.py
|
|
35
|
+
rpc/__init__.py
|
|
36
|
+
rpc/_rpc.py
|
|
37
|
+
rpc/client.py
|
|
38
|
+
scheduler/__init__.py
|
|
39
|
+
scheduler/_async_task.py
|
|
40
|
+
scheduler/_scheduler.py
|
|
41
|
+
scheduler/cronparser.py
|
|
42
|
+
servers/__init__.py
|
|
43
|
+
servers/_run.py
|
|
44
|
+
servers/build.py
|
|
45
|
+
servers/run_server.py
|
|
46
|
+
servers/run_worker.py
|
|
47
|
+
settings/__init__.py
|
|
48
|
+
settings/_config_processing.py
|
|
49
|
+
settings/config_processing.py
|
|
50
|
+
settings/keys.py
|
|
51
|
+
settings/meta.py
|
|
52
|
+
utils/__init__.py
|
|
53
|
+
utils/_format_time.py
|
|
54
|
+
utils/_network.py
|
|
55
|
+
workflows/__init__.py
|
|
56
|
+
workflows/monitoring.py
|
|
57
|
+
workflows/task_distribution.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|