orionis 0.483.0__py3-none-any.whl → 0.485.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.
- orionis/console/base/scheduler.py +56 -0
- orionis/console/commands/scheduler_list.py +30 -51
- orionis/console/commands/scheduler_work.py +13 -38
- orionis/console/commands/test.py +0 -1
- orionis/console/contracts/event_listener.py +27 -0
- orionis/console/core/reactor.py +3 -4
- orionis/console/entities/__init__.py +0 -0
- orionis/console/entities/listeners.py +241 -0
- orionis/console/tasks/event.py +7 -0
- orionis/console/tasks/listener.py +0 -0
- orionis/console/tasks/schedule.py +23 -2
- orionis/foundation/application.py +157 -100
- orionis/foundation/config/roots/paths.py +40 -45
- orionis/foundation/contracts/application.py +60 -0
- orionis/metadata/framework.py +1 -1
- orionis/services/file/__init__.py +0 -0
- orionis/services/file/directory.py +312 -0
- orionis/services/file/storage.py +7 -0
- {orionis-0.483.0.dist-info → orionis-0.485.0.dist-info}/METADATA +1 -1
- {orionis-0.483.0.dist-info → orionis-0.485.0.dist-info}/RECORD +25 -17
- tests/foundation/config/root/test_foundation_config_root_paths.py +1 -1
- {orionis-0.483.0.dist-info → orionis-0.485.0.dist-info}/WHEEL +0 -0
- {orionis-0.483.0.dist-info → orionis-0.485.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.483.0.dist-info → orionis-0.485.0.dist-info}/top_level.txt +0 -0
- {orionis-0.483.0.dist-info → orionis-0.485.0.dist-info}/zip-safe +0 -0
|
@@ -2,6 +2,7 @@ import asyncio
|
|
|
2
2
|
import time
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import Any, List, Type
|
|
5
|
+
from orionis.console.base.scheduler import BaseScheduler
|
|
5
6
|
from orionis.container.container import Container
|
|
6
7
|
from orionis.container.contracts.service_provider import IServiceProvider
|
|
7
8
|
from orionis.foundation.config.app.entities.app import App
|
|
@@ -113,6 +114,9 @@ class Application(Container, IApplication):
|
|
|
113
114
|
# This will be initialized with default values or from configurators
|
|
114
115
|
self.__config: dict = {}
|
|
115
116
|
|
|
117
|
+
# Property to store the scheduler instance
|
|
118
|
+
self.__scheduler: BaseScheduler = None
|
|
119
|
+
|
|
116
120
|
# Flag to prevent re-initialization
|
|
117
121
|
self.__initialized = True
|
|
118
122
|
|
|
@@ -377,6 +381,78 @@ class Application(Container, IApplication):
|
|
|
377
381
|
# for complex and unique application requirements, supporting advanced customization
|
|
378
382
|
# of every subsystem as needed.
|
|
379
383
|
|
|
384
|
+
def setScheduler(
|
|
385
|
+
self,
|
|
386
|
+
scheduler: BaseScheduler
|
|
387
|
+
) -> 'Application':
|
|
388
|
+
"""
|
|
389
|
+
Register a custom scheduler class for the application.
|
|
390
|
+
|
|
391
|
+
This method allows you to specify a custom scheduler class that inherits from
|
|
392
|
+
`BaseScheduler`. The scheduler is responsible for managing scheduled tasks
|
|
393
|
+
within the application. The provided class will be validated to ensure it is
|
|
394
|
+
a subclass of `BaseScheduler` and then stored for later use.
|
|
395
|
+
|
|
396
|
+
Parameters
|
|
397
|
+
----------
|
|
398
|
+
scheduler : Type[BaseScheduler]
|
|
399
|
+
The scheduler class to be used by the application. Must inherit from
|
|
400
|
+
`BaseScheduler`.
|
|
401
|
+
|
|
402
|
+
Returns
|
|
403
|
+
-------
|
|
404
|
+
Application
|
|
405
|
+
Returns the current `Application` instance to enable method chaining.
|
|
406
|
+
|
|
407
|
+
Raises
|
|
408
|
+
------
|
|
409
|
+
OrionisTypeError
|
|
410
|
+
If the provided scheduler is not a subclass of `BaseScheduler`.
|
|
411
|
+
|
|
412
|
+
Notes
|
|
413
|
+
-----
|
|
414
|
+
The scheduler class is stored internally and can be used by the application
|
|
415
|
+
to manage scheduled jobs or tasks. This method does not instantiate the
|
|
416
|
+
scheduler; it only registers the class for later use.
|
|
417
|
+
"""
|
|
418
|
+
|
|
419
|
+
# Ensure the provided scheduler is a subclass of BaseScheduler
|
|
420
|
+
if not issubclass(scheduler, BaseScheduler):
|
|
421
|
+
raise OrionisTypeError(f"Expected BaseScheduler subclass, got {type(scheduler).__name__}")
|
|
422
|
+
|
|
423
|
+
# Store the scheduler class in the application for later use
|
|
424
|
+
self.__scheduler = scheduler
|
|
425
|
+
|
|
426
|
+
# Return the application instance for method chaining
|
|
427
|
+
return self
|
|
428
|
+
|
|
429
|
+
def getScheduler(
|
|
430
|
+
self
|
|
431
|
+
) -> BaseScheduler:
|
|
432
|
+
"""
|
|
433
|
+
Retrieve the currently registered scheduler instance.
|
|
434
|
+
|
|
435
|
+
This method returns the scheduler instance that has been set using the
|
|
436
|
+
`setScheduler` method. If no scheduler has been set, it raises an error.
|
|
437
|
+
|
|
438
|
+
Returns
|
|
439
|
+
-------
|
|
440
|
+
BaseScheduler
|
|
441
|
+
The currently registered scheduler instance.
|
|
442
|
+
|
|
443
|
+
Raises
|
|
444
|
+
------
|
|
445
|
+
OrionisRuntimeError
|
|
446
|
+
If no scheduler has been set in the application.
|
|
447
|
+
"""
|
|
448
|
+
|
|
449
|
+
# Check if a scheduler has been set
|
|
450
|
+
if self.__scheduler is None:
|
|
451
|
+
raise OrionisRuntimeError("No scheduler has been set for this application.")
|
|
452
|
+
|
|
453
|
+
# Return the registered scheduler instance
|
|
454
|
+
return self.__scheduler()
|
|
455
|
+
|
|
380
456
|
def withConfigurators(
|
|
381
457
|
self,
|
|
382
458
|
*,
|
|
@@ -1212,11 +1288,11 @@ class Application(Container, IApplication):
|
|
|
1212
1288
|
def setPaths(
|
|
1213
1289
|
self,
|
|
1214
1290
|
*,
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1291
|
+
root: str | Path = Path.cwd().resolve(),
|
|
1292
|
+
commands: str | Path = (Path.cwd() / 'app' / 'console' / 'commands').resolve(),
|
|
1293
|
+
controllers: str | Path = (Path.cwd() / 'app' / 'http' / 'controllers').resolve(),
|
|
1294
|
+
middleware: str | Path = (Path.cwd() / 'app' / 'http' / 'middleware').resolve(),
|
|
1295
|
+
requests: str | Path = (Path.cwd() / 'app' / 'http' / 'requests').resolve(),
|
|
1220
1296
|
models: str | Path = (Path.cwd() / 'app' / 'models').resolve(),
|
|
1221
1297
|
providers: str | Path = (Path.cwd() / 'app' / 'providers').resolve(),
|
|
1222
1298
|
events: str | Path = (Path.cwd() / 'app' / 'events').resolve(),
|
|
@@ -1229,139 +1305,120 @@ class Application(Container, IApplication):
|
|
|
1229
1305
|
views: str | Path = (Path.cwd() / 'resources' / 'views').resolve(),
|
|
1230
1306
|
lang: str | Path = (Path.cwd() / 'resources' / 'lang').resolve(),
|
|
1231
1307
|
assets: str | Path = (Path.cwd() / 'resources' / 'assets').resolve(),
|
|
1232
|
-
|
|
1233
|
-
routes_api: str | Path = (Path.cwd() / 'routes' / 'api.py').resolve(),
|
|
1234
|
-
routes_console: str | Path = (Path.cwd() / 'routes' / 'console.py').resolve(),
|
|
1235
|
-
routes_channels: str | Path = (Path.cwd() / 'routes' / 'channels.py').resolve(),
|
|
1308
|
+
routes: str | Path = (Path.cwd() / 'routes').resolve(),
|
|
1236
1309
|
config: str | Path = (Path.cwd() / 'config').resolve(),
|
|
1237
1310
|
migrations: str | Path = (Path.cwd() / 'database' / 'migrations').resolve(),
|
|
1238
1311
|
seeders: str | Path = (Path.cwd() / 'database' / 'seeders').resolve(),
|
|
1239
1312
|
factories: str | Path = (Path.cwd() / 'database' / 'factories').resolve(),
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
storage_views: str | Path = (Path.cwd() / 'storage' / 'framework' / 'views').resolve(),
|
|
1245
|
-
storage_testing: str | Path = (Path.cwd() / 'storage' / 'framework' / 'testing').resolve(),
|
|
1313
|
+
logs: str | Path = (Path.cwd() / 'storage' / 'logs').resolve(),
|
|
1314
|
+
sessions: str | Path = (Path.cwd() / 'storage' / 'framework' / 'sessions').resolve(),
|
|
1315
|
+
cache: str | Path = (Path.cwd() / 'storage' / 'framework' / 'cache').resolve(),
|
|
1316
|
+
testing: str | Path = (Path.cwd() / 'storage' / 'framework' / 'testing').resolve(),
|
|
1246
1317
|
) -> 'Application':
|
|
1247
1318
|
"""
|
|
1248
|
-
|
|
1319
|
+
Set and resolve application directory paths using keyword arguments.
|
|
1249
1320
|
|
|
1250
|
-
This method allows customization of all application directory paths
|
|
1321
|
+
This method allows customization of all major application directory paths, such as
|
|
1251
1322
|
console components, HTTP components, application layers, resources, routes,
|
|
1252
|
-
database files, and storage locations. All paths are resolved to absolute
|
|
1253
|
-
paths and stored as strings in the configuration.
|
|
1323
|
+
database files, and storage locations. All provided paths are resolved to absolute
|
|
1324
|
+
paths and stored as strings in the configuration dictionary.
|
|
1254
1325
|
|
|
1255
1326
|
Parameters
|
|
1256
1327
|
----------
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
Directory
|
|
1261
|
-
|
|
1262
|
-
Directory
|
|
1263
|
-
|
|
1264
|
-
Directory
|
|
1265
|
-
|
|
1266
|
-
Directory
|
|
1328
|
+
root : str or Path, optional
|
|
1329
|
+
Root directory of the application. Defaults to the current working directory.
|
|
1330
|
+
commands : str or Path, optional
|
|
1331
|
+
Directory for console command classes. Defaults to 'app/console/commands'.
|
|
1332
|
+
controllers : str or Path, optional
|
|
1333
|
+
Directory for HTTP controller classes. Defaults to 'app/http/controllers'.
|
|
1334
|
+
middleware : str or Path, optional
|
|
1335
|
+
Directory for HTTP middleware classes. Defaults to 'app/http/middleware'.
|
|
1336
|
+
requests : str or Path, optional
|
|
1337
|
+
Directory for HTTP request classes. Defaults to 'app/http/requests'.
|
|
1267
1338
|
models : str or Path, optional
|
|
1268
|
-
Directory
|
|
1339
|
+
Directory for data model classes. Defaults to 'app/models'.
|
|
1269
1340
|
providers : str or Path, optional
|
|
1270
|
-
Directory
|
|
1341
|
+
Directory for service provider classes. Defaults to 'app/providers'.
|
|
1271
1342
|
events : str or Path, optional
|
|
1272
|
-
Directory
|
|
1343
|
+
Directory for event classes. Defaults to 'app/events'.
|
|
1273
1344
|
listeners : str or Path, optional
|
|
1274
|
-
Directory
|
|
1345
|
+
Directory for event listener classes. Defaults to 'app/listeners'.
|
|
1275
1346
|
notifications : str or Path, optional
|
|
1276
|
-
Directory
|
|
1347
|
+
Directory for notification classes. Defaults to 'app/notifications'.
|
|
1277
1348
|
jobs : str or Path, optional
|
|
1278
|
-
Directory
|
|
1349
|
+
Directory for queue job classes. Defaults to 'app/jobs'.
|
|
1279
1350
|
policies : str or Path, optional
|
|
1280
|
-
Directory
|
|
1351
|
+
Directory for authorization policy classes. Defaults to 'app/policies'.
|
|
1281
1352
|
exceptions : str or Path, optional
|
|
1282
|
-
Directory
|
|
1353
|
+
Directory for custom exception classes. Defaults to 'app/exceptions'.
|
|
1283
1354
|
services : str or Path, optional
|
|
1284
|
-
Directory
|
|
1355
|
+
Directory for application service classes. Defaults to 'app/services'.
|
|
1285
1356
|
views : str or Path, optional
|
|
1286
|
-
Directory
|
|
1357
|
+
Directory for view templates. Defaults to 'resources/views'.
|
|
1287
1358
|
lang : str or Path, optional
|
|
1288
|
-
Directory
|
|
1359
|
+
Directory for language files. Defaults to 'resources/lang'.
|
|
1289
1360
|
assets : str or Path, optional
|
|
1290
|
-
Directory
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
routes_api : str or Path, optional
|
|
1294
|
-
File path for API route definitions. Default is 'routes/api.py'.
|
|
1295
|
-
routes_console : str or Path, optional
|
|
1296
|
-
File path for console route definitions. Default is 'routes/console.py'.
|
|
1297
|
-
routes_channels : str or Path, optional
|
|
1298
|
-
File path for broadcast channel definitions. Default is 'routes/channels.py'.
|
|
1361
|
+
Directory for asset files. Defaults to 'resources/assets'.
|
|
1362
|
+
routes : str or Path, optional
|
|
1363
|
+
Directory for route definitions. Defaults to 'routes'.
|
|
1299
1364
|
config : str or Path, optional
|
|
1300
|
-
Directory
|
|
1365
|
+
Directory for configuration files. Defaults to 'config'.
|
|
1301
1366
|
migrations : str or Path, optional
|
|
1302
|
-
Directory
|
|
1367
|
+
Directory for database migration files. Defaults to 'database/migrations'.
|
|
1303
1368
|
seeders : str or Path, optional
|
|
1304
|
-
Directory
|
|
1369
|
+
Directory for database seeder files. Defaults to 'database/seeders'.
|
|
1305
1370
|
factories : str or Path, optional
|
|
1306
|
-
Directory
|
|
1307
|
-
|
|
1308
|
-
Directory
|
|
1309
|
-
|
|
1310
|
-
Directory
|
|
1311
|
-
|
|
1312
|
-
Directory
|
|
1313
|
-
|
|
1314
|
-
Directory
|
|
1315
|
-
storage_views : str or Path, optional
|
|
1316
|
-
Directory path for compiled view storage. Default is 'storage/framework/views'.
|
|
1317
|
-
storage_testing : str or Path, optional
|
|
1318
|
-
Directory path for testing file storage. Default is 'storage/framework/testing'.
|
|
1371
|
+
Directory for model factory files. Defaults to 'database/factories'.
|
|
1372
|
+
logs : str or Path, optional
|
|
1373
|
+
Directory for log file storage. Defaults to 'storage/logs'.
|
|
1374
|
+
sessions : str or Path, optional
|
|
1375
|
+
Directory for session file storage. Defaults to 'storage/framework/sessions'.
|
|
1376
|
+
cache : str or Path, optional
|
|
1377
|
+
Directory for cache file storage. Defaults to 'storage/framework/cache'.
|
|
1378
|
+
testing : str or Path, optional
|
|
1379
|
+
Directory for testing file storage. Defaults to 'storage/framework/testing'.
|
|
1319
1380
|
|
|
1320
1381
|
Returns
|
|
1321
1382
|
-------
|
|
1322
1383
|
Application
|
|
1323
|
-
|
|
1384
|
+
Returns the current Application instance to enable method chaining.
|
|
1324
1385
|
|
|
1325
1386
|
Notes
|
|
1326
1387
|
-----
|
|
1327
1388
|
All path parameters accept either string or Path objects and are automatically
|
|
1328
1389
|
resolved to absolute paths relative to the current working directory. The
|
|
1329
|
-
resolved paths are stored as strings in the internal configuration
|
|
1390
|
+
resolved paths are stored as strings in the internal configuration dictionary.
|
|
1330
1391
|
"""
|
|
1331
1392
|
|
|
1393
|
+
# Prepare and store all resolved paths as strings in the configurators dictionary
|
|
1332
1394
|
# Ensure 'paths' exists in configurators
|
|
1333
|
-
self.__configurators['
|
|
1334
|
-
'
|
|
1335
|
-
'
|
|
1336
|
-
'
|
|
1337
|
-
'
|
|
1338
|
-
'
|
|
1339
|
-
'models': str(models),
|
|
1340
|
-
'providers': str(providers),
|
|
1341
|
-
'events': str(events),
|
|
1342
|
-
'listeners': str(listeners),
|
|
1343
|
-
'notifications': str(notifications),
|
|
1344
|
-
'jobs': str(jobs),
|
|
1345
|
-
'policies': str(policies),
|
|
1346
|
-
'exceptions': str(exceptions),
|
|
1347
|
-
'services': str(services),
|
|
1348
|
-
'views': str(views),
|
|
1349
|
-
'lang': str(lang),
|
|
1350
|
-
'assets': str(assets),
|
|
1351
|
-
'
|
|
1352
|
-
'
|
|
1353
|
-
'
|
|
1354
|
-
'
|
|
1355
|
-
'
|
|
1356
|
-
'
|
|
1357
|
-
'
|
|
1358
|
-
'
|
|
1359
|
-
'
|
|
1360
|
-
'storage_framework': str(storage_framework),
|
|
1361
|
-
'storage_sessions': str(storage_sessions),
|
|
1362
|
-
'storage_cache': str(storage_cache),
|
|
1363
|
-
'storage_views': str(storage_views),
|
|
1364
|
-
'storage_testing': str(storage_testing),
|
|
1395
|
+
self.__configurators['path'] = {
|
|
1396
|
+
'root' : str(root),
|
|
1397
|
+
'commands' : str(commands),
|
|
1398
|
+
'controllers' : str(controllers),
|
|
1399
|
+
'middleware' : str(middleware),
|
|
1400
|
+
'requests' : str(requests),
|
|
1401
|
+
'models' : str(models),
|
|
1402
|
+
'providers' : str(providers),
|
|
1403
|
+
'events' : str(events),
|
|
1404
|
+
'listeners' : str(listeners),
|
|
1405
|
+
'notifications' : str(notifications),
|
|
1406
|
+
'jobs' : str(jobs),
|
|
1407
|
+
'policies' : str(policies),
|
|
1408
|
+
'exceptions' : str(exceptions),
|
|
1409
|
+
'services' : str(services),
|
|
1410
|
+
'views' : str(views),
|
|
1411
|
+
'lang' : str(lang),
|
|
1412
|
+
'assets' : str(assets),
|
|
1413
|
+
'routes' : str(routes),
|
|
1414
|
+
'config' : str(config),
|
|
1415
|
+
'migrations' : str(migrations),
|
|
1416
|
+
'seeders' : str(seeders),
|
|
1417
|
+
'factories' : str(factories),
|
|
1418
|
+
'logs' : str(logs),
|
|
1419
|
+
'sessions' : str(sessions),
|
|
1420
|
+
'cache' : str(cache),
|
|
1421
|
+
'testing' : str(testing)
|
|
1365
1422
|
}
|
|
1366
1423
|
|
|
1367
1424
|
# Return self instance for method chaining
|
|
@@ -1410,7 +1467,7 @@ class Application(Container, IApplication):
|
|
|
1410
1467
|
paths = Paths(**paths)
|
|
1411
1468
|
|
|
1412
1469
|
# Store the configuration
|
|
1413
|
-
self.__configurators['
|
|
1470
|
+
self.__configurators['path'] = paths
|
|
1414
1471
|
|
|
1415
1472
|
# Return the application instance for method chaining
|
|
1416
1473
|
return self
|
|
@@ -6,23 +6,23 @@ from orionis.support.entities.base import BaseEntity
|
|
|
6
6
|
@dataclass(frozen=True, kw_only=True)
|
|
7
7
|
class Paths(BaseEntity):
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
default_factory = lambda: str(
|
|
9
|
+
root: str = field(
|
|
10
|
+
default_factory = lambda: str(Path.cwd().resolve()),
|
|
11
11
|
metadata = {
|
|
12
|
-
'description': '
|
|
13
|
-
'default': lambda: str(
|
|
12
|
+
'description': 'The root directory of the application.',
|
|
13
|
+
'default': lambda: str(Path.cwd().resolve())
|
|
14
14
|
}
|
|
15
15
|
)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
commands: str = field(
|
|
18
18
|
default_factory = lambda: str((Path.cwd() / 'app' / 'console' / 'commands').resolve()),
|
|
19
19
|
metadata = {
|
|
20
|
-
'description': 'Directory containing
|
|
20
|
+
'description': 'Directory containing subfolders for console commands and scheduler.py.',
|
|
21
21
|
'default': lambda: str((Path.cwd() / 'app' / 'console' / 'commands').resolve())
|
|
22
22
|
}
|
|
23
23
|
)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
controllers: str = field(
|
|
26
26
|
default_factory = lambda: str((Path.cwd() / 'app' / 'http' / 'controllers').resolve()),
|
|
27
27
|
metadata = {
|
|
28
28
|
'description': 'Directory containing HTTP controller classes.',
|
|
@@ -30,7 +30,7 @@ class Paths(BaseEntity):
|
|
|
30
30
|
}
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
middleware: str = field(
|
|
34
34
|
default_factory = lambda: str((Path.cwd() / 'app' / 'http' / 'middleware').resolve()),
|
|
35
35
|
metadata = {
|
|
36
36
|
'description': 'Directory containing HTTP middleware classes.',
|
|
@@ -38,7 +38,7 @@ class Paths(BaseEntity):
|
|
|
38
38
|
}
|
|
39
39
|
)
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
requests: str = field(
|
|
42
42
|
default_factory = lambda: str((Path.cwd() / 'app' / 'http' / 'requests').resolve()),
|
|
43
43
|
metadata = {
|
|
44
44
|
'description': 'Directory containing HTTP form request validation classes.',
|
|
@@ -142,35 +142,11 @@ class Paths(BaseEntity):
|
|
|
142
142
|
}
|
|
143
143
|
)
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
default_factory = lambda: str((Path.cwd() / 'routes'
|
|
145
|
+
routes: str = field(
|
|
146
|
+
default_factory = lambda: str((Path.cwd() / 'routes').resolve()),
|
|
147
147
|
metadata = {
|
|
148
148
|
'description': 'Path to the web routes definition file.',
|
|
149
|
-
'default': lambda: str((Path.cwd() / 'routes'
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
routes_api: str = field(
|
|
154
|
-
default_factory = lambda: str((Path.cwd() / 'routes' / 'api.py').resolve()),
|
|
155
|
-
metadata = {
|
|
156
|
-
'description': 'Path to the API routes definition file.',
|
|
157
|
-
'default': lambda: str((Path.cwd() / 'routes' / 'api.py').resolve())
|
|
158
|
-
}
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
routes_console: str = field(
|
|
162
|
-
default_factory = lambda: str((Path.cwd() / 'routes' / 'console.py').resolve()),
|
|
163
|
-
metadata = {
|
|
164
|
-
'description': 'Path to the console routes definition file.',
|
|
165
|
-
'default': lambda: str((Path.cwd() / 'routes' / 'console.py').resolve())
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
routes_channels: str = field(
|
|
170
|
-
default_factory = lambda: str((Path.cwd() / 'routes' / 'channels.py').resolve()),
|
|
171
|
-
metadata = {
|
|
172
|
-
'description': 'Path to the broadcast channels routes file.',
|
|
173
|
-
'default': lambda: str((Path.cwd() / 'routes' / 'channels.py').resolve())
|
|
149
|
+
'default': lambda: str((Path.cwd() / 'routes').resolve())
|
|
174
150
|
}
|
|
175
151
|
)
|
|
176
152
|
|
|
@@ -206,7 +182,7 @@ class Paths(BaseEntity):
|
|
|
206
182
|
}
|
|
207
183
|
)
|
|
208
184
|
|
|
209
|
-
|
|
185
|
+
logs: str = field(
|
|
210
186
|
default_factory = lambda: str((Path.cwd() / 'storage' / 'logs').resolve()),
|
|
211
187
|
metadata = {
|
|
212
188
|
'description': 'Directory containing application log files.',
|
|
@@ -214,7 +190,7 @@ class Paths(BaseEntity):
|
|
|
214
190
|
}
|
|
215
191
|
)
|
|
216
192
|
|
|
217
|
-
|
|
193
|
+
framework: str = field(
|
|
218
194
|
default_factory = lambda: str((Path.cwd() / 'storage' / 'framework').resolve()),
|
|
219
195
|
metadata = {
|
|
220
196
|
'description': 'Directory for framework-generated files (cache, sessions, views).',
|
|
@@ -222,7 +198,7 @@ class Paths(BaseEntity):
|
|
|
222
198
|
}
|
|
223
199
|
)
|
|
224
200
|
|
|
225
|
-
|
|
201
|
+
sessions: str = field(
|
|
226
202
|
default_factory = lambda: str((Path.cwd() / 'storage' / 'framework' / 'sessions').resolve()),
|
|
227
203
|
metadata = {
|
|
228
204
|
'description': 'Directory containing session files.',
|
|
@@ -230,7 +206,7 @@ class Paths(BaseEntity):
|
|
|
230
206
|
}
|
|
231
207
|
)
|
|
232
208
|
|
|
233
|
-
|
|
209
|
+
cache: str = field(
|
|
234
210
|
default_factory = lambda: str((Path.cwd() / 'storage' / 'framework' / 'cache').resolve()),
|
|
235
211
|
metadata = {
|
|
236
212
|
'description': 'Directory containing framework cache files.',
|
|
@@ -238,7 +214,7 @@ class Paths(BaseEntity):
|
|
|
238
214
|
}
|
|
239
215
|
)
|
|
240
216
|
|
|
241
|
-
|
|
217
|
+
views: str = field(
|
|
242
218
|
default_factory = lambda: str((Path.cwd() / 'storage' / 'framework' / 'views').resolve()),
|
|
243
219
|
metadata = {
|
|
244
220
|
'description': 'Directory containing compiled view files.',
|
|
@@ -246,7 +222,7 @@ class Paths(BaseEntity):
|
|
|
246
222
|
}
|
|
247
223
|
)
|
|
248
224
|
|
|
249
|
-
|
|
225
|
+
testing: str = field(
|
|
250
226
|
default_factory = lambda: str((Path.cwd() / 'storage' / 'framework' / 'testing').resolve()),
|
|
251
227
|
metadata = {
|
|
252
228
|
'description': 'Directory containing compiled view files.',
|
|
@@ -255,18 +231,37 @@ class Paths(BaseEntity):
|
|
|
255
231
|
)
|
|
256
232
|
|
|
257
233
|
def __post_init__(self) -> None:
|
|
258
|
-
super().__post_init__()
|
|
259
234
|
"""
|
|
260
|
-
|
|
235
|
+
Post-initialization hook to validate path attributes.
|
|
236
|
+
|
|
237
|
+
This method is called automatically after the dataclass is initialized.
|
|
238
|
+
It ensures that all attributes representing paths are of type `str`.
|
|
239
|
+
If any attribute is not a string, an `OrionisIntegrityException` is raised
|
|
240
|
+
to prevent invalid configuration.
|
|
241
|
+
|
|
242
|
+
Parameters
|
|
243
|
+
----------
|
|
244
|
+
self : Paths
|
|
245
|
+
The instance of the Paths dataclass.
|
|
246
|
+
|
|
247
|
+
Returns
|
|
248
|
+
-------
|
|
249
|
+
None
|
|
250
|
+
This method does not return any value.
|
|
261
251
|
|
|
262
252
|
Raises
|
|
263
253
|
------
|
|
264
254
|
OrionisIntegrityException
|
|
265
|
-
If any attribute is not
|
|
255
|
+
If any attribute is not of type `str`.
|
|
266
256
|
"""
|
|
257
|
+
super().__post_init__() # Call the parent class's post-init if defined
|
|
258
|
+
|
|
259
|
+
# Iterate over all dataclass fields to validate their types
|
|
267
260
|
for field_ in fields(self):
|
|
268
261
|
value = getattr(self, field_.name)
|
|
262
|
+
# Check if the field value is not a string
|
|
269
263
|
if not isinstance(value, str):
|
|
264
|
+
# Raise an exception if the type is invalid
|
|
270
265
|
raise OrionisIntegrityException(
|
|
271
266
|
f"Invalid type for '{field_.name}': expected str, got {type(value).__name__}"
|
|
272
267
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from typing import Any, List, Type
|
|
4
|
+
from orionis.console.base.scheduler import BaseScheduler
|
|
4
5
|
from orionis.foundation.config.roots.paths import Paths
|
|
5
6
|
from orionis.container.contracts.service_provider import IServiceProvider
|
|
6
7
|
from orionis.container.contracts.container import IContainer
|
|
@@ -92,6 +93,65 @@ class IApplication(IContainer):
|
|
|
92
93
|
"""
|
|
93
94
|
pass
|
|
94
95
|
|
|
96
|
+
@abstractmethod
|
|
97
|
+
def setScheduler(
|
|
98
|
+
self,
|
|
99
|
+
scheduler: BaseScheduler
|
|
100
|
+
) -> 'IApplication':
|
|
101
|
+
"""
|
|
102
|
+
Register a custom scheduler class for the application.
|
|
103
|
+
|
|
104
|
+
This method allows you to specify a custom scheduler class that inherits from
|
|
105
|
+
`BaseScheduler`. The scheduler is responsible for managing scheduled tasks
|
|
106
|
+
within the application. The provided class will be validated to ensure it is
|
|
107
|
+
a subclass of `BaseScheduler` and then stored for later use.
|
|
108
|
+
|
|
109
|
+
Parameters
|
|
110
|
+
----------
|
|
111
|
+
scheduler : Type[BaseScheduler]
|
|
112
|
+
The scheduler class to be used by the application. Must inherit from
|
|
113
|
+
`BaseScheduler`.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
Application
|
|
118
|
+
Returns the current `Application` instance to enable method chaining.
|
|
119
|
+
|
|
120
|
+
Raises
|
|
121
|
+
------
|
|
122
|
+
OrionisTypeError
|
|
123
|
+
If the provided scheduler is not a subclass of `BaseScheduler`.
|
|
124
|
+
|
|
125
|
+
Notes
|
|
126
|
+
-----
|
|
127
|
+
The scheduler class is stored internally and can be used by the application
|
|
128
|
+
to manage scheduled jobs or tasks. This method does not instantiate the
|
|
129
|
+
scheduler; it only registers the class for later use.
|
|
130
|
+
"""
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
def getScheduler(
|
|
135
|
+
self
|
|
136
|
+
) -> BaseScheduler:
|
|
137
|
+
"""
|
|
138
|
+
Retrieve the currently registered scheduler instance.
|
|
139
|
+
|
|
140
|
+
This method returns the scheduler instance that has been set using the
|
|
141
|
+
`setScheduler` method. If no scheduler has been set, it raises an error.
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
BaseScheduler
|
|
146
|
+
The currently registered scheduler instance.
|
|
147
|
+
|
|
148
|
+
Raises
|
|
149
|
+
------
|
|
150
|
+
OrionisRuntimeError
|
|
151
|
+
If no scheduler has been set in the application.
|
|
152
|
+
"""
|
|
153
|
+
pass
|
|
154
|
+
|
|
95
155
|
@abstractmethod
|
|
96
156
|
def withConfigurators(
|
|
97
157
|
self,
|
orionis/metadata/framework.py
CHANGED
|
File without changes
|