Compare commits

...
Author SHA1 Message Date
Damodar Lohani 9c0504408c quick patch webp support 2024-09-28 08:52:18 +00:00
Steven NguyenandGitHub 52700f12c2 Merge pull request #8404 from appwrite/1.5.x-db-storage-metrics
db storage metrics
2024-09-25 21:09:26 -07:00
Bradley Schofield 2274767720 Merge branch '1.5.x-db-storage-metrics' of https://github.com/appwrite/appwrite into 1.5.x-db-storage-metrics 2024-09-26 10:41:14 +09:00
Steven NguyenandGitHub 8eb69eb22e Merge pull request #8722 from appwrite/fix-https-mails-worker
Add domain and force HTTPS env vars to mail worker
2024-09-25 16:56:21 -07:00
Steven NguyenandGitHub 31e03bfaae fix: add domain and force HTTPS env vars to mail worker
The worker uses the env vars so we need to include it in the compose file to ensure the variable passes into the container.
2024-09-25 23:25:56 +00:00
Matej BačoandGitHub 1788896a57 Merge pull request #8719 from appwrite/16x-sync-main
Merge pull request #8686 from appwrite/1.6.x
2024-09-25 12:13:44 +02:00
Torsten DittmannandGitHub fdd39a29c3 Merge pull request #8707 from appwrite/feat-make-create-execution-async-loose
feat: make create execution async loose
2024-09-25 12:12:02 +02:00
bff846480a Update app/controllers/api/functions.php
Co-authored-by: Matej Bačo <matejbacocom@gmail.com>
2024-09-25 10:01:12 +01:00
loks0n 711dc7bd08 feat: add logic 2024-09-25 09:59:51 +01:00
loks0n df76c7c268 Merge branch 'main' of https://github.com/appwrite/appwrite into feat-make-create-execution-async-loose 2024-09-25 09:42:12 +01:00
Luke B. SilverandGitHub b52c9648f1 Merge branch '1.6.x' into feat-make-create-execution-async-loose 2024-09-25 09:35:55 +01:00
Bradley Schofield 6d8a969334 Update specs 2024-09-24 18:44:42 +09:00
Bradley SchofieldandGitHub 46bef5a61d Merge branch '1.6.x' into 1.5.x-db-storage-metrics 2024-09-24 18:12:11 +09:00
Bradley Schofield 0101fbda8c Update dependencies 2024-09-24 17:58:25 +09:00
Bradley Schofield fb1c0c85b0 Handle missing database 2024-09-24 16:10:52 +09:00
Bradley Schofield 001d13d7e9 Improve Stability, handle cases of deleted collections or databases 2024-09-24 16:08:46 +09:00
Bradley Schofield 585ee4b88e Get tests passing 2024-09-24 15:18:35 +09:00
Bradley Schofield 3a68c77406 Try and get tests working 2024-09-24 14:28:11 +09:00
Bradley Schofield 9b454b07b9 Address Comments 2024-09-24 01:48:15 +09:00
Bradley Schofield e8bd577d4e Update metric count 2024-09-24 01:43:33 +09:00
Bradley Schofield 5c59083f4d Run Linter 2024-09-24 00:57:22 +09:00
Bradley Schofield 9db6f4cbee Address Comments 2024-09-24 00:54:27 +09:00
Bradley Schofield 00acc2f73b Address Comments 2024-09-24 00:07:54 +09:00
Bradley Schofield f9d0f8fc38 Run Linter 2024-09-23 18:16:18 +09:00
Bradley Schofield a309f31a33 Add tests, move hooks to API Layer 2024-09-23 18:08:48 +09:00
loks0n 8ae99cb373 feat: make create execution async loose 2024-09-20 20:00:59 +01:00
Christy JacobandGitHub 21a406830a Merge pull request #8705 from appwrite/fix-schedule-base
fix: typo in scheduler base
2024-09-20 20:42:41 +04:00
Binyamin Yawitz 5ffca0f6fa fix: typo in scheduler base 2024-09-20 12:37:45 -04:00
Christy JacobandGitHub 9f7bf5a9f7 Merge pull request #8704 from appwrite/revert-7975-feat-eldad4-coroutines
Revert "Feat eldad4 coroutines"
2024-09-20 20:30:39 +04:00
Binyamin YawitzandGitHub 5512340cdd Revert "Feat eldad4 coroutines" 2024-09-20 12:30:05 -04:00
Christy JacobandGitHub f94f7763c8 Merge pull request #8703 from appwrite/revert-8691-fix-schedule-base
Revert "Fix typo in scheduler base"
2024-09-20 20:29:46 +04:00
Binyamin YawitzandGitHub d2aaa99076 Revert "Fix typo in scheduler base" 2024-09-20 12:26:17 -04:00
Christy JacobandGitHub ab19f1323e Merge pull request #8702 from appwrite/revert-8694-fix-auth-injection
Revert "Fix auth injection"
2024-09-20 20:25:40 +04:00
Binyamin YawitzandGitHub 904e4c8650 Revert "Fix auth injection" 2024-09-20 12:24:12 -04:00
Christy JacobandGitHub 778edf1ac2 Merge pull request #8694 from appwrite/fix-auth-injection
Fix auth injection
2024-09-20 02:33:16 +04:00
Binyamin Yawitz 24eef9accf fix: injection name 2024-09-19 18:28:24 -04:00
Christy JacobandGitHub 24ecdd71b1 Merge pull request #8691 from appwrite/fix-schedule-base
Fix typo in scheduler base
2024-09-19 22:25:52 +04:00
Binyamin Yawitz 0702d7ec9c chore: merge 2024-09-19 14:25:05 -04:00
Christy JacobandGitHub 193f94e5e1 Merge pull request #7975 from appwrite/feat-eldad4-coroutines
Feat eldad4 coroutines
2024-09-19 22:16:50 +04:00
Binyamin Yawitz 48d4d873de Merge branch '1.6.x' into feat-eldad4-coroutines 2024-09-19 13:50:27 -04:00
Binyamin Yawitz fe7f39d7a5 fix: reviews 2024-09-19 13:48:15 -04:00
fogelito 2517605cd1 Add this 2024-09-19 18:45:00 +03:00
Bradley Schofield 82687c8ca4 Merge branch 'main' into 1.5.x-db-storage-metrics
# Conflicts:
#	app/config/specs/open-api3-latest-console.json
#	app/config/specs/swagger2-latest-console.json
#	app/controllers/api/project.php
#	src/Appwrite/Utopia/Response/Model/UsageProject.php
#	tests/e2e/General/UsageTest.php
2024-09-19 15:37:27 +09:00
Binyamin Yawitz 1581a8c654 chore: merge 2024-09-18 09:28:55 -04:00
Binyamin Yawitz de95bf677e fix: removing unneeded coroutine 2024-09-16 15:05:20 -04:00
Torsten DittmannandBinyamin Yawitz 7d58879373 fix: architecture agnostic runtimes in cli 2024-09-16 11:18:57 -04:00
Binyamin Yawitz e246005c51 chore: merge 2024-09-16 11:17:40 -04:00
Binyamin Yawitz 8bc123848f chore: packages update 2024-09-10 11:46:58 +02:00
Binyamin Yawitz f8c26e0f0a chore: merge 2024-09-10 11:12:16 +02:00
Binyamin Yawitz 3571260a2b chore: packages update 2024-09-10 11:06:02 +02:00
Binyamin Yawitz 3ca7672726 chore: merge 2024-09-09 17:59:38 +02:00
Binyamin Yawitz 1861ae3f68 fix: mock phone tests 2024-09-09 17:48:26 +02:00
Binyamin Yawitz 828928b609 chore: packages update 2024-09-09 15:03:49 +02:00
Binyamin Yawitz ef1380bf61 chore: merge 2024-09-09 14:52:47 +02:00
Binyamin Yawitz b390485dd9 fix: coroutine access in schedulers 2024-09-06 15:52:20 -04:00
Binyamin Yawitz b200e66bd1 fix: adding getConsoleDB injection 2024-09-06 15:52:04 -04:00
Binyamin Yawitz d0cc9c8a13 fix: expanding exception classes & conditioning experiment logger 2024-09-05 18:44:06 -04:00
Binyamin Yawitz 5622d1fd89 fix: adjusting to cr 2024-09-05 18:22:28 -04:00
Binyamin Yawitz 0d41b084ea chore: formatting and packages updates 2024-09-05 18:17:16 -04:00
Binyamin Yawitz 48264673da fix: adding experimental logger 2024-09-05 18:14:06 -04:00
Binyamin Yawitz 9e525366cb Merge branch '1.6.x' into feat-eldad4-coroutines
# Conflicts:
#	app/controllers/api/functions.php
#	app/init.php
#	composer.lock
#	src/Appwrite/Specification/Format/Swagger2.php
2024-09-05 18:09:16 -04:00
Binyamin Yawitz 557eefe2c4 review: addressing 2024-09-05 18:06:41 -04:00
Binyamin Yawitz 439e42e1ab review: addressing 2024-09-05 14:49:37 -04:00
Binyamin Yawitz 8e145a9519 refactor: global to registry 2024-09-05 14:03:59 -04:00
Binyamin Yawitz 0ecc61fe9e refactor: import instead of FQDN 2024-09-05 13:26:26 -04:00
Binyamin Yawitz 41bffa0165 refactor: small change 2024-09-05 13:24:54 -04:00
Binyamin Yawitz fbb23b227b refactor: global to registry 2024-09-05 13:20:44 -04:00
Binyamin Yawitz 5d70884e6c chore: cleaning 2024-09-05 13:11:39 -04:00
Binyamin Yawitz 3af2ea0d4c chore: updating packages 2024-09-05 13:04:42 -04:00
Binyamin Yawitz 946bf20dd7 chore: update packages to RC 2024-09-04 20:48:10 -04:00
Binyamin Yawitz 5ae124c54c chore: update 2024-09-04 17:33:19 -04:00
Binyamin Yawitz f3ab0d2dca fix: latest vcs 2024-09-04 17:30:28 -04:00
Binyamin Yawitz 74a8c7da12 fix: fixes 2024-09-04 16:41:45 -04:00
Binyamin Yawitz ec4af20d09 chore: packages update 2024-09-04 15:13:49 -04:00
Binyamin Yawitz feb775d2c4 chore: merge, lint, stan 2024-09-04 14:52:01 -04:00
Binyamin Yawitz cedf3cf28d chore: format 2024-09-03 19:32:30 -04:00
Binyamin Yawitz 686b5439a2 chore: merge 2024-09-03 19:22:53 -04:00
Binyamin Yawitz 7d6eac4ddb Merge branch '1.6.x' into feat-eldad4-coroutines
# Conflicts:
#	app/cli.php
#	app/controllers/api/account.php
#	app/controllers/api/functions.php
#	app/controllers/api/projects.php
#	app/controllers/general.php
#	app/controllers/shared/api.php
#	app/http.php
#	app/init.php
#	app/realtime.php
#	app/worker.php
#	composer.json
#	composer.lock
#	src/Appwrite/Migration/Migration.php
#	src/Appwrite/Platform/Tasks/Migrate.php
#	src/Appwrite/Platform/Tasks/ScheduleExecutions.php
#	src/Appwrite/Platform/Workers/Builds.php
#	src/Appwrite/Platform/Workers/Deletes.php
#	src/Appwrite/Specification/Format/Swagger2.php
#	src/Appwrite/Utopia/Response.php
2024-09-03 19:06:48 -04:00
Binyamin Yawitz 579aa5bd1a fixing: Adding missing models from merge 2024-08-07 14:50:06 -04:00
Binyamin Yawitz d2b8d3ae7a chore: finishing merge 2024-08-07 14:24:52 -04:00
Binyamin Yawitz e672a0ebe2 Merge branch 'refs/heads/1.6.x' into feat-eldad4-coroutines
# Conflicts:
#	src/Appwrite/Auth/Validator/MockNumber.php
2024-08-07 14:01:46 -04:00
Binyamin Yawitz fc95877177 chore: stan 2024-08-06 15:20:45 -04:00
Binyamin Yawitz 6475f29d45 chore: lint 2024-08-06 15:12:21 -04:00
Binyamin Yawitz 7a1e3ce4d9 chore: merge 2024-08-06 15:05:24 -04:00
Binyamin Yawitz 90acd79345 chore: Adjusting init to match latest 2024-08-06 15:04:59 -04:00
Binyamin Yawitz 9ed43ebbc2 Merge branch 'refs/heads/1.6.x' into feat-eldad4-coroutines
# Conflicts:
#	app/controllers/api/functions.php
#	app/controllers/general.php
#	app/init.php
#	composer.lock
#	dev/xdebug.ini
#	src/Appwrite/Utopia/Response.php
2024-08-06 14:57:05 -04:00
Binyamin Yawitz 19918843a4 test: 2024-08-01 15:38:18 -04:00
Binyamin Yawitz ff1d4219e3 refactor: Exporting global 2024-07-29 15:15:57 -04:00
Binyamin Yawitz b884059ecd refactor: Making sure database names remains the same as previous versions 2024-07-29 12:29:21 -04:00
Binyamin Yawitz 613c3b41f8 fix: Redis with null password 2024-07-26 12:40:31 -04:00
Binyamin Yawitz 6619870847 fix: Load only when needed 2024-07-26 11:19:54 -04:00
Binyamin Yawitz 2947d22392 chore: Updating workers 2024-07-22 14:45:39 -04:00
Binyamin Yawitz 916f58cd9d fixes: Logger and Abuse timelimit 2024-07-19 14:19:30 -04:00
Binyamin Yawitz 35910a6dbe chore: updating packages 2024-07-19 13:50:34 -04:00
Binyamin Yawitz 7d14a8b742 feat: Supporting old project database name 2024-07-19 13:49:10 -04:00
Binyamin Yawitz 05862e8bc0 chore: lint 2024-07-19 10:02:32 -04:00
Binyamin Yawitz cfdf5ff5cb chore: Merge 2024-07-19 10:00:06 -04:00
Binyamin Yawitz f7a28bcf71 Merge branch 'refs/heads/1.6.x' into feat-eldad4-coroutines
# Conflicts:
#	app/init.php
#	src/Appwrite/Migration/Migration.php
2024-07-19 09:59:08 -04:00
Binyamin Yawitz 87e0f2539c fix: tests 2024-07-18 15:31:24 -04:00
Binyamin Yawitz f4e2736475 fix: Adding restart to the scheduler 2024-07-18 13:53:31 -04:00
Binyamin Yawitz b9596b780b chore: lint 2024-07-18 12:18:43 -04:00
Binyamin Yawitz 5ad0214a1e chore: 1.6 -> current 2024-07-18 12:16:24 -04:00
Binyamin Yawitz 349c4f706f Merge branch 'refs/heads/1.6.x' into feat-eldad4-coroutines
# Conflicts:
#	app/controllers/web/console.php
#	app/http.php
2024-07-18 11:54:01 -04:00
Binyamin Yawitz 850c17dde1 tests: Ensure stability 2024-07-18 11:51:09 -04:00
Binyamin Yawitz 0bdf75a4a0 chore: Update response models 2024-07-18 09:11:04 -04:00
Bradley Schofield 519a444617 Update Tests 2024-07-18 16:47:18 +09:00
Bradley Schofield 70be40468a Run Linter 2024-07-18 16:26:12 +09:00
Bradley Schofield 5c4a92a6d9 Update specs 2024-07-18 16:23:31 +09:00
Bradley Schofield 6768406422 Merge branch '1.5.x' into 1.5.x-db-storage-metrics 2024-07-18 16:21:56 +09:00
Bradley Schofield f39d654725 Implement Trickle Down calculations 2024-07-18 13:58:02 +09:00
Binyamin Yawitz b245aab9d8 fix: Adjusting to coroutine 2024-07-17 15:59:25 -04:00
Binyamin Yawitz c15d362865 chore: Updating composer 2024-07-17 15:50:15 -04:00
Binyamin Yawitz bbdd886a6c fix: Adjusting 2024-07-17 15:48:44 -04:00
Binyamin Yawitz 023e222029 fix: Adjusting 2024-07-17 15:48:38 -04:00
Binyamin Yawitz 8d66536e7f fix: Adjusting 2024-07-17 15:34:57 -04:00
Binyamin Yawitz d1af8cfbe0 feat: Extracting authentication cookie 2024-07-17 15:21:47 -04:00
Binyamin Yawitz 19119b573d chore: Merge and lint 2024-07-17 15:06:06 -04:00
Binyamin Yawitz 927dbc7e11 Merge branch 'refs/heads/1.6.x' into feat-eldad4-coroutines
# Conflicts:
#	app/console
#	app/controllers/api/account.php
#	app/controllers/api/functions.php
#	app/controllers/api/projects.php
#	app/controllers/api/users.php
#	app/controllers/api/vcs.php
#	app/controllers/general.php
#	app/controllers/mock.php
#	app/controllers/shared/api.php
#	app/init.php
#	composer.json
#	composer.lock
#	src/Appwrite/Platform/Tasks/Doctor.php
#	src/Appwrite/Platform/Tasks/ScheduleMessages.php
#	src/Appwrite/Platform/Workers/Builds.php
#	src/Appwrite/Utopia/Response.php
2024-07-17 14:31:13 -04:00
Bradley Schofield fe0ea40dc0 Update UsageDump.php 2024-07-17 17:40:28 +09:00
Bradley Schofield 29541617de Start implementing database metrics in usage dump worker 2024-07-16 13:14:55 +09:00
Binyamin Yawitz acef279091 refactor: headers to instance 2024-07-15 16:15:02 -04:00
Binyamin Yawitz b1e766d61a refactor: Response Models init 2024-07-15 13:26:32 -04:00
Binyamin Yawitz 6d22474af9 fix: Initializing response model 2024-07-15 13:26:18 -04:00
Binyamin Yawitz b86f1c0aa4 refactor: Auto load inline-classes 2024-07-15 12:52:18 -04:00
Binyamin Yawitz 55d4cd2aa5 refactor: response models to static 2024-07-15 10:34:59 -04:00
Binyamin Yawitz 9b94a4a1ed chore: improvements 2024-07-12 18:11:43 -04:00
Binyamin Yawitz 66b9467e6d rollback: Reverting to more stable server 2024-07-05 11:44:58 -04:00
Binyamin Yawitz a60000d631 fix: Small fix 2024-07-04 17:07:33 -04:00
Binyamin Yawitz 1217aee296 refactor: Connection pools 2024-07-04 15:04:36 -04:00
Binyamin Yawitz 664c3ad466 chore: Cleanup 2024-07-04 15:04:20 -04:00
Binyamin Yawitz ea13375109 chore: Merge tasks 2024-07-04 11:02:34 -04:00
Binyamin Yawitz a3682b72e1 Merge remote-tracking branch 'refs/remotes/origin/main' into feat-eldad4-coroutines
# Conflicts:
#	app/cli.php
#	app/console
#	app/controllers/api/projects.php
#	app/controllers/general.php
#	app/init.php
#	app/realtime.php
#	app/worker.php
#	composer.json
#	composer.lock
2024-07-03 17:03:24 -04:00
Binyamin Yawitz 92668fda0d feat: Moving to coroutine dedicated http server 2024-07-03 16:24:04 -04:00
Binyamin Yawitz a4f675c632 feat: Coroutine adjustments 2024-07-02 11:16:44 -04:00
Binyamin Yawitz 77b593dae5 feat: Coroutine adjustments 2024-07-01 14:25:32 -04:00
Binyamin Yawitz b05671b8b3 refactor: Rollback 2024-07-01 08:36:46 -04:00
Binyamin Yawitz 5bcb22cd4f test: Latest swoole 2024-06-28 15:44:52 -04:00
Binyamin Yawitz efb8af902e Merge branch 'refs/heads/main' into feat-eldad4-coroutines
# Conflicts:
#	src/Appwrite/Platform/Workers/Certificates.php
2024-06-28 15:08:15 -04:00
Binyamin Yawitz 6f62f915d9 feat: Adding Authentication injection for user id and secret 2024-06-28 14:33:13 -04:00
Binyamin Yawitz 034814c924 chore: Removing default function timeout 2024-06-25 09:38:33 -04:00
Binyamin Yawitz 78d321b33b chore: rearrange account.php methods 2024-06-24 15:52:22 -04:00
Binyamin Yawitz 97cd5e4934 chore: DI+CO improvements 2024-06-24 13:31:40 -04:00
Binyamin Yawitz 3ecd8ce189 chore: Commenting unused code 2024-06-24 13:31:24 -04:00
Binyamin Yawitz aa4bc1c776 feat: Adapting Migrate to DI 2024-06-24 13:31:01 -04:00
Binyamin Yawitz 4ea291705a feat: Adapting specs to DI 2024-06-24 13:30:51 -04:00
Binyamin Yawitz 4ef09b680f feat: GraphQL DI 2024-06-21 17:22:58 -04:00
Binyamin Yawitz ca0e44620a chore: merge 2024-06-21 15:26:58 -04:00
Binyamin Yawitz c7ba512db5 chore: merge 2024-06-21 15:23:07 -04:00
Binyamin Yawitz bc46ce30ab chore: merge 2024-06-20 17:26:40 -04:00
Binyamin Yawitz 6c26e2eb51 Merge branch 'refs/heads/main' into feat-eldad4-coroutines
# Conflicts:
#	app/cli.php
#	composer.json
#	composer.lock
2024-06-20 17:23:15 -04:00
Binyamin Yawitz 74ef1a4257 chore: GraphQL arrangement 2024-06-20 16:51:30 -04:00
Binyamin Yawitz 7d248f29f0 feat: Coroutine graphql wip 2024-06-11 18:08:40 -04:00
Binyamin Yawitz a2b8f74ae1 chore: Updating dependencies 2024-06-11 12:30:14 -04:00
Binyamin Yawitz 8e9dd17dfd feat: Refreshing GraphQL coroutine cache related resources 2024-06-11 12:29:19 -04:00
Binyamin Yawitz 7dccb21ffc lint 2024-06-10 15:14:06 -04:00
Binyamin Yawitz 8795d72146 test: Temp database workaround for old PHP 2024-06-10 15:09:01 -04:00
Binyamin Yawitz c14fc2a721 test: GraphQL wip 2024-06-10 15:06:42 -04:00
Binyamin Yawitz e75645334a test: GraphQL wip 2024-06-10 12:56:29 -04:00
Binyamin Yawitz 300c0f0ee2 test: Messaging, refactor to use own auth 2024-06-10 07:49:12 -04:00
Binyamin Yawitz c1ded34c12 test: Functions. reverting time and adding restart policy 2024-06-10 07:16:07 -04:00
Binyamin Yawitz dc47007566 test: Realtime tests 2024-06-07 15:36:45 -04:00
Binyamin Yawitz 38cabc8afc test: Databases tests 2024-06-07 12:54:07 -04:00
Binyamin Yawitz 321f621132 test: Functions tests 2024-06-07 12:13:12 -04:00
Binyamin Yawitz 5ac5baca38 fixes: General refactors 2024-06-06 21:06:52 -04:00
Binyamin Yawitz d0a55e266c lint: Linting 2024-06-06 20:54:51 -04:00
Binyamin Yawitz ea5d0fbaf2 refactor: Removing redundant injections 2024-06-06 20:54:39 -04:00
Binyamin Yawitz 269b9b27c2 feat: Adding cache 2024-06-06 20:54:08 -04:00
Binyamin Yawitz 757cf24d4d feat: Adjusting health API to new pools 2024-06-06 20:52:51 -04:00
Binyamin Yawitz ba629e94ef feat: Adjusting Doctor to new pools 2024-06-06 20:52:30 -04:00
Binyamin Yawitz 0bd9426aa7 feat: Adding plans, updating server and exception class 2024-06-06 13:13:39 -04:00
Binyamin Yawitz 1b80ec289b test: Adjusting unit testing to new structure 2024-06-06 10:12:05 -04:00
Binyamin Yawitz cf30941514 fix: compose file 2024-06-05 20:46:49 -04:00
Binyamin Yawitz 6b0892a495 refactor: Adjusting to merge and some code cleanups 2024-06-05 20:41:23 -04:00
Binyamin Yawitz b5a241db8d merge: Main into Coroutines 2024-06-05 18:38:39 -04:00
Binyamin Yawitz 07582ecc5f fix: Changing auth function to instance 2024-06-05 13:38:02 -04:00
Binyamin Yawitz 6a7ee3df8a fix: realtime auth 2024-06-05 09:08:27 -04:00
Binyamin Yawitz 72d5e94c97 wip: coroutines 2024-06-04 16:56:28 -04:00
Binyamin Yawitz 1c9457b1ed cicd: removing logs 2024-06-04 15:47:55 -04:00
Binyamin Yawitz 85ccfd883e fix: Removing local compose values 2024-06-04 15:36:49 -04:00
Binyamin Yawitz 187ccc64de cicd: checking compose logs 2024-06-04 15:31:34 -04:00
Binyamin Yawitz 8ac7d0a160 fix: Removing local compose values 2024-06-04 15:31:20 -04:00
Binyamin Yawitz 3682da417a fix: reverting to run swoole 5.1.1 2024-06-04 15:23:29 -04:00
Binyamin Yawitz c411aa2342 fix: Realtime auth 2024-06-04 15:23:08 -04:00
Binyamin Yawitz d1c3e47392 refactor: CLI injections 2024-06-04 13:22:27 -04:00
Binyamin Yawitz f7d9efc18e feat: Adding DI to realtime 2024-06-04 13:12:10 -04:00
Binyamin Yawitz 0093ad7799 Revert "wip: Starting realtime"
This reverts commit 7dfc654121.
2024-06-04 11:57:16 -04:00
Binyamin Yawitz 7dfc654121 wip: Starting realtime 2024-06-03 15:24:39 -04:00
Binyamin Yawitz 0664c39533 fix: Typo 2024-06-03 14:11:31 -04:00
Binyamin Yawitz 6083d8b7a8 feat(tasks): Coroutine 2024-06-03 14:09:58 -04:00
Eldad Fux 90fd0ba392 Updated db lib 2024-05-09 21:50:34 +01:00
Eldad Fux 525383c725 Updates to realtime 2024-05-08 21:01:07 +01:00
Eldad Fux 0b7c795e2b Updated lock file 2024-05-08 19:33:51 +01:00
Eldad Fux 5cfe4db839 Updated console 2024-05-08 18:24:15 +01:00
Eldad Fux c53de9fb6b Merge branch 'main' of github.com:appwrite/appwrite into feat-eldad4-coroutines 2024-05-08 18:21:55 +01:00
Eldad Fux 90ef64c63e Fixed namespace 2024-05-08 18:16:43 +01:00
Eldad Fux 55fe725f4b Fixed format 2024-04-24 23:16:43 +02:00
Eldad Fux 9fc0342cf1 Updated injections 2024-04-23 13:30:20 +02:00
Eldad Fux beeb66e66d Fixed account tests 2024-04-23 00:17:07 +02:00
Eldad Fux 46ab7b1a36 Fixed functions test 2024-04-22 23:33:18 +02:00
Eldad Fux 69a43aa667 Fixed projects tests 2024-04-22 23:28:40 +02:00
Eldad Fux 7381ababb8 Merge remote-tracking branch 'refs/remotes/origin/feat-eldad4-coroutines' into feat-eldad4-coroutines 2024-04-22 23:02:59 +02:00
Eldad Fux d67df5feb1 Fixed formatting 2024-04-22 22:45:55 +02:00
Eldad A. FuxandGitHub 6c8b228b6c Merge branch 'main' into feat-eldad4-coroutines 2024-04-22 22:37:10 +02:00
Eldad Fux 86b46353ad Fixed for general tests 2024-04-22 22:35:38 +02:00
Eldad Fux 99994f6278 Fixed storage tests 2024-04-22 21:43:57 +02:00
Eldad Fux 09e9483d94 Changed autoloading order 2024-04-22 21:38:48 +02:00
Eldad Fux 351b9318d4 Fixed router, and options 2024-04-22 17:58:40 +02:00
Eldad Fux 6a67a1d48a Fixed execute to match new signature 2024-04-22 14:41:46 +02:00
Eldad Fux 19f8b13cfe Fixed formatting 2024-04-22 14:19:37 +02:00
Eldad Fux ab6744df3a Fixed webhooks tests 2024-04-22 14:12:09 +02:00
Eldad Fux 5d54f567cd Fixed client overwriting 2024-04-22 09:45:31 +02:00
Eldad Fux c413a6cab5 Updated database service 2024-04-22 09:01:48 +02:00
Eldad Fux 3b70ae4d9f Fixed formatting 2024-04-22 07:56:36 +02:00
Eldad Fux b97cf78d9d Enabled more controllers 2024-04-22 07:51:35 +02:00
Eldad Fux aff328c660 Fixed test 2024-04-22 07:51:24 +02:00
Eldad Fux 74dc9957f2 Fixed console test 2024-04-22 07:25:29 +02:00
Eldad Fux 479f20dabf Fixed some workers 2024-04-22 07:00:17 +02:00
Eldad Fux 6d6f22788d Eanble compression 2024-04-15 23:38:36 +02:00
Eldad A. FuxandGitHub 2e4c6eae96 Merge branch 'main' into feat-eldad2-coroutines 2024-04-15 22:14:27 +02:00
Eldad Fux 07a830e9a6 Work on the main worker 2024-04-15 22:03:07 +02:00
Eldad Fux 13eb3bccd0 Fixed users tests 2024-04-15 12:36:42 +02:00
Eldad Fux 87ca2dfb32 Applied fixes for tests 2024-04-15 07:29:32 +02:00
Eldad Fux 49a50b32a7 Test DB failure 2024-04-15 06:29:12 +02:00
Eldad Fux a5ba262c4c Fixed bootstrap file 2024-04-15 05:59:02 +02:00
Eldad Fux fd2410d2ae Fixed bootstrap 2024-04-14 22:42:31 +02:00
Eldad Fux 766b2ba13e Avatars tests are green! 2024-04-14 22:17:07 +02:00
Eldad Fux 6cade89369 New init structure 2024-04-14 11:22:53 +02:00
Eldad Fux 9e234b7600 updated server 2024-04-14 10:58:05 +02:00
Eldad Fux 08b3182ef3 WIP 2024-04-14 10:56:09 +02:00
Eldad Fux 211bcf8948 Removed proxy db 2024-04-09 21:02:02 +02:00
Eldad Fux bd57955168 Enabled coroutines 2024-04-03 13:43:20 +02:00
Eldad Fux a1db69b7e7 Fixed missing System namespace 2024-04-02 08:13:28 +02:00
Eldad Fux 378bb5fda3 Fixed server 2024-04-02 03:14:19 +02:00
Eldad Fux be7a6e55f8 Fixed whitespace 2024-04-02 03:02:06 +02:00
Eldad Fux 5ce3de4933 Merge remote-tracking branch 'origin/main' into feat-eldad2-coroutines 2024-04-02 02:13:15 +02:00
Eldad Fux b570368f10 Fixed auth error in users usage 2024-04-01 23:57:20 +02:00
Eldad Fux c73ef2c649 Fixed 451 status code 2024-04-01 23:46:00 +02:00
Eldad Fux 6ce8781af1 Fixed email escaping 2024-04-01 19:39:26 +02:00
Eldad Fux 713928cff3 Couroutines test
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to appwrite here: https://github.com/appwrite/appwrite/blob/master/CONTRIBUTING.md

Happy contributing!

-->

## What does this PR do?

(Provide a description of what this PR does and why it's needed.)

## Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

## Related PRs and Issues

- (Related PR or issue)

## Checklist

- [ ] Have you read the [Contributing Guidelines on issues](https://github.com/appwrite/appwrite/blob/master/CONTRIBUTING.md)?
- [ ] If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
2024-04-01 18:40:35 +02:00
Matej Bačo 2a0a69f3ed Fix connections pool 2024-03-09 11:59:45 +01:00
Matej Bačo 4de95913a5 Disable debug 2024-03-08 19:12:53 +01:00
Matej Bačo 513bf7eaca Update .env 2024-03-08 15:10:26 +01:00
Matej Bačo d5f180db4f Add debugging 2024-03-08 15:10:20 +01:00
Matej Bačo db1674811f Finish fixing code QL warnings 2024-03-08 13:57:20 +01:00
Matej Bačo 005a239932 Auth fixes 2024-03-07 18:24:01 +01:00
Matej Bačo efeb898be1 Import fixes 2024-03-07 15:29:42 +01:00
Matej Bačo 5a7c43ab32 Introduce code analysis 2024-03-07 10:59:08 +01:00
Matej Bačo 8a8638a817 Formatting fix 2024-03-07 10:20:24 +01:00
Matej Bačo ee065bc64c Merge branch '1.5.x' into feat-database-proxy 2024-03-07 10:18:49 +01:00
Matej Bačo 27e995eb53 Reomve leftpover 2024-03-06 22:31:23 +01:00
Matej Bačo 1b65c5fbc9 linter fix 2024-03-06 22:26:14 +01:00
Matej Bačo 4fa9ccd9e4 upgrade libs 2024-03-06 22:25:43 +01:00
Matej Bačo f83d6e61ae PR review changes 2024-03-06 17:01:43 +01:00
Matej Bačo 882d8e5a88 Fix database tests 2024-03-06 16:19:23 +01:00
Matej Bačo a9731cd5bc Fix account tests 2024-03-06 12:38:51 +01:00
Matej Bačo e807a5d20a Upgrade DB proxy 2024-03-05 13:41:26 +00:00
Matej Bačo d8996b47b5 Implement DB proxy 2024-03-05 11:37:47 +01:00
21 changed files with 847 additions and 68 deletions
+6
View File
@@ -319,10 +319,16 @@ These are the current metrics we collect usage stats for:
| users | Total number of users per project|
| executions | Total number of executions per project |
| databases | Total number of databases per project |
| databases.storage | Total amount of storage used by all databases per project (in bytes) |
| databases.storage_disk | Total amount of storage used by all database per project on disk (in bytes) |
| collections | Total number of collections per project |
| {databaseInternalId}.collections | Total number of collections per database|
| {databaseInternalId}.storage | Sum of database storage (in bytes) |
| {databaseInternalId}.storage_disk | Sum of database storage on disk (in bytes) |
| documents | Total number of documents per project |
| {databaseInternalId}.{collectionInternalId}.documents | Total number of documents per collection |
| {databaseInternalId}.{collectionInternalId}.storage | Sum of database storage used by the collection (in bytes) |
| {databsaeInternalId}.{collectionInternalId}.storage_disk | Sum of database storage used by the collection on disk (in bytes) |
| buckets | Total number of buckets per project |
| files | Total number of files per project |
| {bucketInternalId}.files.storage | Sum of files.storage per bucket (in bytes) |
+3
View File
@@ -28,6 +28,9 @@ RUN \
apk add boost boost-dev; \
fi
RUN \
apk add libwebp
WORKDIR /usr/src/code
COPY --from=composer /usr/local/src/vendor /usr/src/code/vendor
+50 -2
View File
@@ -36747,6 +36747,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total databases storage in bytes.",
"x-example": 0,
"format": "int32"
},
"databases": {
"type": "array",
"description": "Aggregated number of databases per period.",
@@ -36770,6 +36776,14 @@
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "An array of the aggregated number of databases storage in bytes per period.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
}
},
"required": [
@@ -36777,9 +36791,11 @@
"databasesTotal",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databases",
"collections",
"documents"
"documents",
"storage"
]
},
"usageDatabase": {
@@ -36803,6 +36819,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total storage used in bytes.",
"x-example": 0,
"format": "int32"
},
"collections": {
"type": "array",
"description": "Aggregated number of collections per period.",
@@ -36818,14 +36840,24 @@
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "Aggregated storage used in bytes per period.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
}
},
"required": [
"range",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"collections",
"documents"
"documents",
"storage"
]
},
"usageCollection": {
@@ -37366,6 +37398,12 @@
"x-example": 0,
"format": "int32"
},
"databasesStorageTotal": {
"type": "integer",
"description": "Total aggregated sum of databases storage size (in bytes).",
"x-example": 0,
"format": "int32"
},
"usersTotal": {
"type": "integer",
"description": "Total aggregated number of users.",
@@ -37462,6 +37500,14 @@
},
"x-example": []
},
"databasesStorageBreakdown": {
"type": "array",
"description": "An array of the aggregated breakdown of storage usage by databases.",
"items": {
"$ref": "#\/components\/schemas\/metricBreakdown"
},
"x-example": []
},
"executionsMbSecondsBreakdown": {
"type": "array",
"description": "Aggregated breakdown in totals of execution mbSeconds by functions.",
@@ -37491,6 +37537,7 @@
"executionsTotal",
"documentsTotal",
"databasesTotal",
"databasesStorageTotal",
"usersTotal",
"filesStorageTotal",
"functionsStorageTotal",
@@ -37505,6 +37552,7 @@
"executions",
"executionsBreakdown",
"bucketsBreakdown",
"databasesStorageBreakdown",
"executionsMbSecondsBreakdown",
"buildsMbSecondsBreakdown",
"functionsStorageBreakdown"
+50 -2
View File
@@ -36747,6 +36747,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total databases storage in bytes.",
"x-example": 0,
"format": "int32"
},
"databases": {
"type": "array",
"description": "Aggregated number of databases per period.",
@@ -36770,6 +36776,14 @@
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "An array of the aggregated number of databases storage in bytes per period.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
}
},
"required": [
@@ -36777,9 +36791,11 @@
"databasesTotal",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databases",
"collections",
"documents"
"documents",
"storage"
]
},
"usageDatabase": {
@@ -36803,6 +36819,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total storage used in bytes.",
"x-example": 0,
"format": "int32"
},
"collections": {
"type": "array",
"description": "Aggregated number of collections per period.",
@@ -36818,14 +36840,24 @@
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "Aggregated storage used in bytes per period.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
}
},
"required": [
"range",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"collections",
"documents"
"documents",
"storage"
]
},
"usageCollection": {
@@ -37366,6 +37398,12 @@
"x-example": 0,
"format": "int32"
},
"databasesStorageTotal": {
"type": "integer",
"description": "Total aggregated sum of databases storage size (in bytes).",
"x-example": 0,
"format": "int32"
},
"usersTotal": {
"type": "integer",
"description": "Total aggregated number of users.",
@@ -37462,6 +37500,14 @@
},
"x-example": []
},
"databasesStorageBreakdown": {
"type": "array",
"description": "An array of the aggregated breakdown of storage usage by databases.",
"items": {
"$ref": "#\/components\/schemas\/metricBreakdown"
},
"x-example": []
},
"executionsMbSecondsBreakdown": {
"type": "array",
"description": "Aggregated breakdown in totals of execution mbSeconds by functions.",
@@ -37491,6 +37537,7 @@
"executionsTotal",
"documentsTotal",
"databasesTotal",
"databasesStorageTotal",
"usersTotal",
"filesStorageTotal",
"functionsStorageTotal",
@@ -37505,6 +37552,7 @@
"executions",
"executionsBreakdown",
"bucketsBreakdown",
"databasesStorageBreakdown",
"executionsMbSecondsBreakdown",
"buildsMbSecondsBreakdown",
"functionsStorageBreakdown"
+53 -2
View File
@@ -37270,6 +37270,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total databases storage in bytes.",
"x-example": 0,
"format": "int32"
},
"databases": {
"type": "array",
"description": "Aggregated number of databases per period.",
@@ -37296,6 +37302,15 @@
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "An array of the aggregated number of databases storage in bytes per period.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
}
},
"required": [
@@ -37303,9 +37318,11 @@
"databasesTotal",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databases",
"collections",
"documents"
"documents",
"storage"
]
},
"usageDatabase": {
@@ -37329,6 +37346,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total storage used in bytes.",
"x-example": 0,
"format": "int32"
},
"collections": {
"type": "array",
"description": "Aggregated number of collections per period.",
@@ -37346,14 +37369,25 @@
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "Aggregated storage used in bytes per period.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
}
},
"required": [
"range",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"collections",
"documents"
"documents",
"storage"
]
},
"usageCollection": {
@@ -37921,6 +37955,12 @@
"x-example": 0,
"format": "int32"
},
"databasesStorageTotal": {
"type": "integer",
"description": "Total aggregated sum of databases storage size (in bytes).",
"x-example": 0,
"format": "int32"
},
"usersTotal": {
"type": "integer",
"description": "Total aggregated number of users.",
@@ -38023,6 +38063,15 @@
},
"x-example": []
},
"databasesStorageBreakdown": {
"type": "array",
"description": "An array of the aggregated breakdown of storage usage by databases.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metricBreakdown"
},
"x-example": []
},
"executionsMbSecondsBreakdown": {
"type": "array",
"description": "Aggregated breakdown in totals of execution mbSeconds by functions.",
@@ -38055,6 +38104,7 @@
"executionsTotal",
"documentsTotal",
"databasesTotal",
"databasesStorageTotal",
"usersTotal",
"filesStorageTotal",
"functionsStorageTotal",
@@ -38069,6 +38119,7 @@
"executions",
"executionsBreakdown",
"bucketsBreakdown",
"databasesStorageBreakdown",
"executionsMbSecondsBreakdown",
"buildsMbSecondsBreakdown",
"functionsStorageBreakdown"
+53 -2
View File
@@ -37270,6 +37270,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total databases storage in bytes.",
"x-example": 0,
"format": "int32"
},
"databases": {
"type": "array",
"description": "Aggregated number of databases per period.",
@@ -37296,6 +37302,15 @@
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "An array of the aggregated number of databases storage in bytes per period.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
}
},
"required": [
@@ -37303,9 +37318,11 @@
"databasesTotal",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databases",
"collections",
"documents"
"documents",
"storage"
]
},
"usageDatabase": {
@@ -37329,6 +37346,12 @@
"x-example": 0,
"format": "int32"
},
"storageTotal": {
"type": "integer",
"description": "Total aggregated number of total storage used in bytes.",
"x-example": 0,
"format": "int32"
},
"collections": {
"type": "array",
"description": "Aggregated number of collections per period.",
@@ -37346,14 +37369,25 @@
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"storage": {
"type": "array",
"description": "Aggregated storage used in bytes per period.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
}
},
"required": [
"range",
"collectionsTotal",
"documentsTotal",
"storageTotal",
"collections",
"documents"
"documents",
"storage"
]
},
"usageCollection": {
@@ -37921,6 +37955,12 @@
"x-example": 0,
"format": "int32"
},
"databasesStorageTotal": {
"type": "integer",
"description": "Total aggregated sum of databases storage size (in bytes).",
"x-example": 0,
"format": "int32"
},
"usersTotal": {
"type": "integer",
"description": "Total aggregated number of users.",
@@ -38023,6 +38063,15 @@
},
"x-example": []
},
"databasesStorageBreakdown": {
"type": "array",
"description": "An array of the aggregated breakdown of storage usage by databases.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metricBreakdown"
},
"x-example": []
},
"executionsMbSecondsBreakdown": {
"type": "array",
"description": "Aggregated breakdown in totals of execution mbSeconds by functions.",
@@ -38055,6 +38104,7 @@
"executionsTotal",
"documentsTotal",
"databasesTotal",
"databasesStorageTotal",
"usersTotal",
"filesStorageTotal",
"functionsStorageTotal",
@@ -38069,6 +38119,7 @@
"executions",
"executionsBreakdown",
"bucketsBreakdown",
"databasesStorageBreakdown",
"executionsMbSecondsBreakdown",
"buildsMbSecondsBreakdown",
"functionsStorageBreakdown"
+30 -5
View File
@@ -5,6 +5,7 @@ use Appwrite\Detector\Detector;
use Appwrite\Event\Database as EventDatabase;
use Appwrite\Event\Delete;
use Appwrite\Event\Event;
use Appwrite\Event\Usage;
use Appwrite\Extend\Exception;
use Appwrite\Network\Validator\Email;
use Appwrite\Utopia\Database\Validator\CustomId;
@@ -452,7 +453,8 @@ App::post('/v1/databases')
->inject('response')
->inject('dbForProject')
->inject('queueForEvents')
->action(function (string $databaseId, string $name, bool $enabled, Response $response, Database $dbForProject, Event $queueForEvents) {
->inject('queueForUsage')
->action(function (string $databaseId, string $name, bool $enabled, Response $response, Database $dbForProject, Event $queueForEvents, Usage $queueForUsage) {
$databaseId = $databaseId == 'unique()' ? ID::unique() : $databaseId;
@@ -502,6 +504,7 @@ App::post('/v1/databases')
}
$queueForEvents->setParam('databaseId', $database->getId());
$queueForUsage->addMetric(str_replace(['{databaseInternalId}'], [$database->getInternalId()], METRIC_DATABASE_ID_STORAGE), 1); // per database
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
@@ -733,7 +736,8 @@ App::delete('/v1/databases/:databaseId')
->inject('dbForProject')
->inject('queueForDatabase')
->inject('queueForEvents')
->action(function (string $databaseId, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents) {
->inject('queueForUsage')
->action(function (string $databaseId, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Usage $queueForUsage) {
$database = $dbForProject->getDocument('databases', $databaseId);
@@ -756,6 +760,9 @@ App::delete('/v1/databases/:databaseId')
->setParam('databaseId', $database->getId())
->setPayload($response->output($database, Response::MODEL_DATABASE));
$queueForUsage
->addMetric(METRIC_DATABASES_STORAGE, 1); // Global, deletion forces full recalculation
$response->noContent();
});
@@ -2350,7 +2357,8 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key
->inject('dbForProject')
->inject('queueForDatabase')
->inject('queueForEvents')
->action(function (string $databaseId, string $collectionId, string $key, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents) {
->inject('queueForUsage')
->action(function (string $databaseId, string $collectionId, string $key, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Usage $queueForUsage) {
$db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
@@ -2435,6 +2443,9 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key
->setContext('database', $db)
->setPayload($response->output($attribute, $model));
$queueForUsage
->addMetric(str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$db->getInternalId(), $collection->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_STORAGE), 1); // per collection
$response->noContent();
});
@@ -2810,8 +2821,9 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
->inject('dbForProject')
->inject('user')
->inject('queueForEvents')
->inject('queueForUsage')
->inject('mode')
->action(function (string $databaseId, string $documentId, string $collectionId, string|array $data, ?array $permissions, Response $response, Database $dbForProject, Document $user, Event $queueForEvents, string $mode) {
->action(function (string $databaseId, string $documentId, string $collectionId, string|array $data, ?array $permissions, Response $response, Database $dbForProject, Document $user, Event $queueForEvents, Usage $queueForUsage, string $mode) {
$data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array
@@ -3027,6 +3039,9 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
->setContext('database', $database)
->setPayload($response->getPayload(), sensitive: $relationships);
$queueForUsage
->addMetric(str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$database->getInternalId(), $collection->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_STORAGE), 1); // per collection
});
App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
@@ -3643,8 +3658,9 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:docu
->inject('dbForProject')
->inject('queueForDeletes')
->inject('queueForEvents')
->inject('queueForUsage')
->inject('mode')
->action(function (string $databaseId, string $collectionId, string $documentId, ?\DateTime $requestTimestamp, Response $response, Database $dbForProject, Delete $queueForDeletes, Event $queueForEvents, string $mode) {
->action(function (string $databaseId, string $collectionId, string $documentId, ?\DateTime $requestTimestamp, Response $response, Database $dbForProject, Delete $queueForDeletes, Event $queueForEvents, Usage $queueForUsage, string $mode) {
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
$isAPIKey = Auth::isAppUser(Authorization::getRoles());
@@ -3729,6 +3745,9 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:docu
->setContext('database', $database)
->setPayload($response->output($document, Response::MODEL_DOCUMENT), sensitive: $relationships);
$queueForUsage
->addMetric(str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$database->getInternalId(), $collection->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_STORAGE), 1); // per collection
$response->noContent();
});
@@ -3754,6 +3773,7 @@ App::get('/v1/databases/usage')
METRIC_DATABASES,
METRIC_COLLECTIONS,
METRIC_DOCUMENTS,
METRIC_DATABASES_STORAGE
];
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
@@ -3804,9 +3824,11 @@ App::get('/v1/databases/usage')
'databasesTotal' => $usage[$metrics[0]]['total'],
'collectionsTotal' => $usage[$metrics[1]]['total'],
'documentsTotal' => $usage[$metrics[2]]['total'],
'storageTotal' => $usage[$metrics[3]]['total'],
'databases' => $usage[$metrics[0]]['data'],
'collections' => $usage[$metrics[1]]['data'],
'documents' => $usage[$metrics[2]]['data'],
'storage' => $usage[$metrics[3]]['data'],
]), Response::MODEL_USAGE_DATABASES);
});
@@ -3838,6 +3860,7 @@ App::get('/v1/databases/:databaseId/usage')
$metrics = [
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE)
];
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
@@ -3888,8 +3911,10 @@ App::get('/v1/databases/:databaseId/usage')
'range' => $range,
'collectionsTotal' => $usage[$metrics[0]]['total'],
'documentsTotal' => $usage[$metrics[1]]['total'],
'storageTotal' => $usage[$metrics[2]]['total'],
'collections' => $usage[$metrics[0]]['data'],
'documents' => $usage[$metrics[1]]['data'],
'storage' => $usage[$metrics[2]]['data'],
]), Response::MODEL_USAGE_DATABASE);
});
+3 -2
View File
@@ -1718,7 +1718,7 @@ App::post('/v1/functions/:functionId/executions')
->label('sdk.request.type', Response::CONTENT_TYPE_JSON)
->param('functionId', '', new UID(), 'Function ID.')
->param('body', '', new Payload(10485760, 0), 'HTTP body of execution. Default value is empty string.', true)
->param('async', false, new Boolean(), 'Execute code in the background. Default value is false.', true)
->param('async', false, new Boolean(true), 'Execute code in the background. Default value is false.', true)
->param('path', '/', new Text(2048), 'HTTP path of execution. Path can include query params. Default value is /', true)
->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], true), 'HTTP method of execution. Default value is GET.', true)
->param('headers', [], new AnyOf([new Assoc(), new Text(65535)], AnyOf::TYPE_MIXED), 'HTTP headers of execution. Defaults to empty.', true)
@@ -1733,7 +1733,8 @@ App::post('/v1/functions/:functionId/executions')
->inject('queueForUsage')
->inject('queueForFunctions')
->inject('geodb')
->action(function (string $functionId, string $body, bool $async, string $path, string $method, mixed $headers, ?string $scheduledAt, Response $response, Request $request, Document $project, Database $dbForProject, Database $dbForConsole, Document $user, Event $queueForEvents, Usage $queueForUsage, Func $queueForFunctions, Reader $geodb) {
->action(function (string $functionId, string $body, mixed $async, string $path, string $method, mixed $headers, ?string $scheduledAt, Response $response, Request $request, Document $project, Database $dbForProject, Database $dbForConsole, Document $user, Event $queueForEvents, Usage $queueForUsage, Func $queueForFunctions, Reader $geodb) {
$async = \strval($async) === 'true' || \strval($async) === '1';
if (!$async && !is_null($scheduledAt)) {
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Scheduled executions must run asynchronously. Set scheduledAt to a future date, or set async to true.');
+21
View File
@@ -47,6 +47,7 @@ App::get('/v1/project/usage')
METRIC_USERS,
METRIC_BUCKETS,
METRIC_FILES_STORAGE,
METRIC_DATABASES_STORAGE,
METRIC_DEPLOYMENTS_STORAGE,
METRIC_BUILDS_STORAGE
],
@@ -56,6 +57,7 @@ App::get('/v1/project/usage')
METRIC_NETWORK_OUTBOUND,
METRIC_USERS,
METRIC_EXECUTIONS,
METRIC_DATABASES_STORAGE,
METRIC_EXECUTIONS_MB_SECONDS,
METRIC_BUILDS_MB_SECONDS
]
@@ -182,6 +184,23 @@ App::get('/v1/project/usage')
];
}, $dbForProject->find('buckets'));
$databasesStorageBreakdown = array_map(function ($database) use ($dbForProject) {
$id = $database->getId();
$name = $database->getAttribute('name');
$metric = str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE);
$value = $dbForProject->findOne('stats', [
Query::equal('metric', [$metric]),
Query::equal('period', ['inf'])
]);
return [
'resourceId' => $id,
'name' => $name,
'value' => $value['value'] ?? 0,
];
}, $dbForProject->find('databases'));
$functionsStorageBreakdown = array_map(function ($function) use ($dbForProject) {
$id = $function->getId();
$name = $function->getAttribute('name');
@@ -269,6 +288,7 @@ App::get('/v1/project/usage')
'buildsMbSecondsTotal' => $total[METRIC_BUILDS_MB_SECONDS],
'documentsTotal' => $total[METRIC_DOCUMENTS],
'databasesTotal' => $total[METRIC_DATABASES],
'databasesStorageTotal' => $total[METRIC_DATABASES_STORAGE],
'usersTotal' => $total[METRIC_USERS],
'bucketsTotal' => $total[METRIC_BUCKETS],
'filesStorageTotal' => $total[METRIC_FILES_STORAGE],
@@ -279,6 +299,7 @@ App::get('/v1/project/usage')
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
'bucketsBreakdown' => $bucketsBreakdown,
'databasesStorageBreakdown' => $databasesStorageBreakdown,
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
'functionsStorageBreakdown' => $functionsStorageBreakdown,
+1 -1
View File
@@ -95,7 +95,7 @@ $databaseListener = function (string $event, Document $document, Document $proje
$databaseInternalId = $parts[1] ?? 0;
$queueForUsage
->addMetric(METRIC_COLLECTIONS, $value) // per project
->addMetric(str_replace('{databaseInternalId}', $databaseInternalId, METRIC_DATABASE_ID_COLLECTIONS), $value) // per database
->addMetric(str_replace('{databaseInternalId}', $databaseInternalId, METRIC_DATABASE_ID_COLLECTIONS), $value)
;
if ($event === Database::EVENT_DOCUMENT_DELETE) {
+6
View File
@@ -238,10 +238,16 @@ const METRIC_MESSAGES_TYPE_PROVIDER_FAILED = METRIC_MESSAGES . '.{type}.{provid
const METRIC_SESSIONS = 'sessions';
const METRIC_DATABASES = 'databases';
const METRIC_COLLECTIONS = 'collections';
const METRIC_DATABASES_STORAGE = 'databases.storage';
const METRIC_DATABASES_STORAGE_DISK = 'databases.storage_disk';
const METRIC_DATABASE_ID_COLLECTIONS = '{databaseInternalId}.collections';
const METRIC_DATABASE_ID_STORAGE = '{databaseInternalId}.databases.storage';
const METRIC_DATABASE_ID_STORAGE_DISK = '{databaseInternalId}.databases.storage_disk';
const METRIC_DOCUMENTS = 'documents';
const METRIC_DATABASE_ID_DOCUMENTS = '{databaseInternalId}.documents';
const METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS = '{databaseInternalId}.{collectionInternalId}.documents';
const METRIC_DATABASE_ID_COLLECTION_ID_STORAGE = '{databaseInternalId}.{collectionInternalId}.databases.storage';
const METRIC_DATABASE_ID_COLLECTION_ID_STORAGE_DISK = '{databaseInternalId}.{collectionInternalId}.databases.storage_disk';
const METRIC_BUCKETS = 'buckets';
const METRIC_FILES = 'files';
const METRIC_FILES_STORAGE = 'files.storage';
+2
View File
@@ -531,6 +531,8 @@ $image = $this->getParam('image', '');
- _APP_SMTP_USERNAME
- _APP_SMTP_PASSWORD
- _APP_LOGGING_CONFIG
- _APP_DOMAIN
- _APP_OPTIONS_FORCE_HTTPS
appwrite-worker-messaging:
image: <?php echo $organization; ?>/<?php echo $image; ?>:<?php echo $version."\n"; ?>
+7 -1
View File
@@ -51,7 +51,7 @@
"utopia-php/cache": "0.10.*",
"utopia-php/cli": "0.15.*",
"utopia-php/config": "0.2.*",
"utopia-php/database": "0.53.*",
"utopia-php/database": "0.53.5-rc1",
"utopia-php/domains": "0.5.*",
"utopia-php/dsn": "0.2.1",
"utopia-php/framework": "0.33.*",
@@ -97,5 +97,11 @@
"platform": {
"php": "8.3"
}
},
"repositories": {
"utopia-php/database": {
"type": "vcs",
"url": "https://github.com/utopia-php/database"
}
}
}
Generated
+79 -46
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b6820da26239716cf14a445697902a03",
"content-hash": "7066d9ca32e7a1a60614effdc4701970",
"packages": [
{
"name": "adhocore/jwt",
@@ -1723,16 +1723,16 @@
},
{
"name": "utopia-php/database",
"version": "0.53.4",
"version": "0.53.5-rc1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "36a0e89d983afc1368635282e04fa762220a1d2a"
"reference": "689ba22063bf46def385da8695ba7a921e81e38d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/36a0e89d983afc1368635282e04fa762220a1d2a",
"reference": "36a0e89d983afc1368635282e04fa762220a1d2a",
"url": "https://api.github.com/repos/utopia-php/database/zipball/689ba22063bf46def385da8695ba7a921e81e38d",
"reference": "689ba22063bf46def385da8695ba7a921e81e38d",
"shasum": ""
},
"require": {
@@ -1759,7 +1759,38 @@
"Utopia\\Database\\": "src/Database"
}
},
"notification-url": "https://packagist.org/downloads/",
"autoload-dev": {
"psr-4": {
"Tests\\E2E\\": "tests/e2e",
"Tests\\Unit\\": "tests/unit"
}
},
"scripts": {
"build": [
"Composer\\Config::disableProcessTimeout",
"docker compose build"
],
"start": [
"Composer\\Config::disableProcessTimeout",
"docker compose up -d"
],
"test": [
"Composer\\Config::disableProcessTimeout",
"docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml"
],
"lint": [
"./vendor/bin/pint --test"
],
"format": [
"./vendor/bin/pint"
],
"check": [
"./vendor/bin/phpstan analyse --level 7 src tests --memory-limit 512M"
],
"coverage": [
"./vendor/bin/coverage-check ./tmp/clover.xml 90"
]
},
"license": [
"MIT"
],
@@ -1772,10 +1803,10 @@
"utopia"
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.53.4"
"source": "https://github.com/utopia-php/database/tree/0.53.5-rc1",
"issues": "https://github.com/utopia-php/database/issues"
},
"time": "2024-09-10T10:19:57+00:00"
"time": "2024-09-24T08:43:10+00:00"
},
{
"name": "utopia-php/domains",
@@ -2069,16 +2100,16 @@
},
{
"name": "utopia-php/logger",
"version": "0.6.0",
"version": "0.6.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/logger.git",
"reference": "a2d1daeeb8f61fdec6d851950d9a021a3d05c9f9"
"reference": "7e8ff512c6f04577aba1df67c7b9628971946f9c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/logger/zipball/a2d1daeeb8f61fdec6d851950d9a021a3d05c9f9",
"reference": "a2d1daeeb8f61fdec6d851950d9a021a3d05c9f9",
"url": "https://api.github.com/repos/utopia-php/logger/zipball/7e8ff512c6f04577aba1df67c7b9628971946f9c",
"reference": "7e8ff512c6f04577aba1df67c7b9628971946f9c",
"shasum": ""
},
"require": {
@@ -2117,9 +2148,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/logger/issues",
"source": "https://github.com/utopia-php/logger/tree/0.6.0"
"source": "https://github.com/utopia-php/logger/tree/0.6.1"
},
"time": "2024-05-23T13:37:54+00:00"
"time": "2024-09-20T14:02:12+00:00"
},
{
"name": "utopia-php/messaging",
@@ -4185,16 +4216,16 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.30.1",
"version": "1.31.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "51b95ec8670af41009e2b2b56873bad96682413e"
"reference": "249f15fb843bf240cf058372dad29e100cee6c17"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/51b95ec8670af41009e2b2b56873bad96682413e",
"reference": "51b95ec8670af41009e2b2b56873bad96682413e",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/249f15fb843bf240cf058372dad29e100cee6c17",
"reference": "249f15fb843bf240cf058372dad29e100cee6c17",
"shasum": ""
},
"require": {
@@ -4226,9 +4257,9 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.1"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.31.0"
},
"time": "2024-09-07T20:13:05+00:00"
"time": "2024-09-22T11:32:18+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -5865,16 +5896,16 @@
},
{
"name": "symfony/console",
"version": "v7.1.4",
"version": "v7.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111"
"reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/1eed7af6961d763e7832e874d7f9b21c3ea9c111",
"reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111",
"url": "https://api.github.com/repos/symfony/console/zipball/0fa539d12b3ccf068a722bbbffa07ca7079af9ee",
"reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee",
"shasum": ""
},
"require": {
@@ -5938,7 +5969,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v7.1.4"
"source": "https://github.com/symfony/console/tree/v7.1.5"
},
"funding": [
{
@@ -5954,7 +5985,7 @@
"type": "tidelift"
}
],
"time": "2024-08-15T22:48:53+00:00"
"time": "2024-09-20T08:28:38+00:00"
},
{
"name": "symfony/deprecation-contracts",
@@ -6025,16 +6056,16 @@
},
{
"name": "symfony/filesystem",
"version": "v7.1.2",
"version": "v7.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "92a91985250c251de9b947a14bb2c9390b1a562c"
"reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/92a91985250c251de9b947a14bb2c9390b1a562c",
"reference": "92a91985250c251de9b947a14bb2c9390b1a562c",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/61fe0566189bf32e8cfee78335d8776f64a66f5a",
"reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a",
"shasum": ""
},
"require": {
@@ -6071,7 +6102,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v7.1.2"
"source": "https://github.com/symfony/filesystem/tree/v7.1.5"
},
"funding": [
{
@@ -6087,7 +6118,7 @@
"type": "tidelift"
}
],
"time": "2024-06-28T10:03:55+00:00"
"time": "2024-09-17T09:16:35+00:00"
},
{
"name": "symfony/finder",
@@ -6536,16 +6567,16 @@
},
{
"name": "symfony/process",
"version": "v7.1.3",
"version": "v7.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "7f2f542c668ad6c313dc4a5e9c3321f733197eca"
"reference": "5c03ee6369281177f07f7c68252a280beccba847"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/7f2f542c668ad6c313dc4a5e9c3321f733197eca",
"reference": "7f2f542c668ad6c313dc4a5e9c3321f733197eca",
"url": "https://api.github.com/repos/symfony/process/zipball/5c03ee6369281177f07f7c68252a280beccba847",
"reference": "5c03ee6369281177f07f7c68252a280beccba847",
"shasum": ""
},
"require": {
@@ -6577,7 +6608,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v7.1.3"
"source": "https://github.com/symfony/process/tree/v7.1.5"
},
"funding": [
{
@@ -6593,7 +6624,7 @@
"type": "tidelift"
}
],
"time": "2024-07-26T12:44:47+00:00"
"time": "2024-09-19T21:48:23+00:00"
},
{
"name": "symfony/service-contracts",
@@ -6680,16 +6711,16 @@
},
{
"name": "symfony/string",
"version": "v7.1.4",
"version": "v7.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b"
"reference": "d66f9c343fa894ec2037cc928381df90a7ad4306"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/6cd670a6d968eaeb1c77c2e76091c45c56bc367b",
"reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b",
"url": "https://api.github.com/repos/symfony/string/zipball/d66f9c343fa894ec2037cc928381df90a7ad4306",
"reference": "d66f9c343fa894ec2037cc928381df90a7ad4306",
"shasum": ""
},
"require": {
@@ -6747,7 +6778,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v7.1.4"
"source": "https://github.com/symfony/string/tree/v7.1.5"
},
"funding": [
{
@@ -6763,7 +6794,7 @@
"type": "tidelift"
}
],
"time": "2024-08-12T09:59:40+00:00"
"time": "2024-09-20T08:28:38+00:00"
},
{
"name": "textalk/websocket",
@@ -6995,7 +7026,9 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"utopia-php/database": 5
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
+1 -1
View File
@@ -165,7 +165,7 @@ abstract class ScheduleBase extends Action
$total = $total + $sum;
foreach ($results as $document) {
$localDocument = $schedules[$document['resourceId']] ?? null;
$localDocument = $this->schedules[$document->getInternalId()] ?? null;
// Check if resource has been updated since last sync
$org = $localDocument !== null ? \strtotime($localDocument['resourceUpdatedAt']) : null;
+185
View File
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Workers;
use Appwrite\Extend\Exception;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Document;
use Utopia\Database\Exception\Duplicate;
@@ -11,6 +12,10 @@ use Utopia\Platform\Action;
use Utopia\Queue\Message;
use Utopia\System\System;
const METRIC_COLLECTION_LEVEL_STORAGE = 4;
const METRIC_DATABASE_LEVEL_STORAGE = 3;
const METRIC_PROJECT_LEVEL_STORAGE = 2;
class UsageDump extends Action
{
protected array $stats = [];
@@ -70,6 +75,15 @@ class UsageDump extends Action
continue;
}
if (str_contains($key, METRIC_DATABASES_STORAGE)) {
try {
$this->handleDatabaseStorage($key, $dbForProject);
} catch (\Exception $e) {
console::error('[' . DateTime::now() . '] failed to calculate database storage for key [' . $key . '] ' . $e->getMessage());
}
continue;
}
foreach ($this->periods as $period => $format) {
$time = 'inf' === $period ? null : date($format, time());
$id = \md5("{$time}_{$period}_{$key}");
@@ -107,4 +121,175 @@ class UsageDump extends Action
}
}
}
private function handleDatabaseStorage(string $key, Database $dbForProject): void
{
$data = explode('.', $key);
$start = microtime(true);
$updateMetric = function (Database $dbForProject, int $value, string $key, string $period, string|null $time) {
$id = \md5("{$time}_{$period}_{$key}");
try {
$dbForProject->createDocument('stats', new Document([
'$id' => $id,
'period' => $period,
'time' => $time,
'metric' => $key,
'value' => $value,
'region' => System::getEnv('_APP_REGION', 'default'),
]));
} catch (Duplicate $th) {
if ($value < 0) {
$dbForProject->decreaseDocumentAttribute(
'stats',
$id,
'value',
abs($value)
);
} else {
$dbForProject->increaseDocumentAttribute(
'stats',
$id,
'value',
$value
);
}
}
};
foreach ($this->periods as $period => $format) {
$time = 'inf' === $period ? null : date($format, time());
$id = \md5("{$time}_{$period}_{$key}");
$value = 0;
$diskValue = 0;
$previousValue = 0;
try {
$previousValue = ($dbForProject->getDocument('stats', $id))->getAttribute('value', 0);
} catch (\Exception $e) {
// No previous value
}
switch (count($data)) {
// Collection Level
case METRIC_COLLECTION_LEVEL_STORAGE:
Console::log('[' . DateTime::now() . '] Collection Level Storage Calculation [' . $key . ']');
$databaseInternalId = $data[0];
$collectionInternalId = $data[1];
try {
$value = $dbForProject->getSizeOfCollection('database_'.$databaseInternalId.'_collection_'.$collectionInternalId);
$diskValue = $dbForProject->getSizeOfCollectionOnDisk('database_'.$databaseInternalId.'_collection_'.$collectionInternalId);
} catch (\Exception $e) {
// Collection not found
if ($e->getMessage() !== 'Collection not found') {
throw $e;
}
}
// Compare with previous value
$diff = $value - $previousValue;
$diskDiff = $diskValue - $previousValue;
if ($diff === 0 && $diskDiff === 0) {
break;
}
// Update Collection
$updateMetric($dbForProject, $diff, $key, $period, $time);
$updateMetric($dbForProject, $diskDiff, $key . '_disk', $period, $time);
// Update Database
$databaseKey = str_replace(['{databaseInternalId}'], [$data[0]], METRIC_DATABASE_ID_STORAGE);
$updateMetric($dbForProject, $diff, $databaseKey, $period, $time);
$updateMetric($dbForProject, $diskDiff, $databaseKey . '_disk', $period, $time);
// Update Project
$projectKey = METRIC_DATABASES_STORAGE;
$updateMetric($dbForProject, $diff, $projectKey, $period, $time);
$updateMetric($dbForProject, $diskDiff, $projectKey . '_disk', $period, $time);
break;
// Database Level
case METRIC_DATABASE_LEVEL_STORAGE:
Console::log('[' . DateTime::now() . '] Database Level Storage Calculation [' . $key . ']');
$databaseInternalId = $data[0];
$collections = [];
try {
$collections = $dbForProject->find('database_' . $databaseInternalId);
} catch (\Exception $e) {
// Database not found
if ($e->getMessage() !== 'Collection not found') {
throw $e;
}
}
foreach ($collections as $collection) {
try {
$value += $dbForProject->getSizeOfCollection('database_'.$databaseInternalId.'_collection_'.$collection->getInternalId());
$diskValue += $dbForProject->getSizeOfCollectionOnDisk('database_'.$databaseInternalId.'_collection_'.$collection->getInternalId());
} catch (\Exception $e) {
// Collection not found
if ($e->getMessage() !== 'Collection not found') {
throw $e;
}
}
}
$diff = $value - $previousValue;
$diskDiff = $diskValue - $previousValue;
if ($diff === 0 && $diskDiff === 0) {
break;
}
// Update Database
$databaseKey = str_replace(['{databaseInternalId}'], [$data[0]], METRIC_DATABASE_ID_STORAGE);
$updateMetric($dbForProject, $diff, $databaseKey, $period, $time);
$updateMetric($dbForProject, $diskDiff, $databaseKey . '_disk', $period, $time);
// Update Project
$projectKey = METRIC_DATABASES_STORAGE;
$updateMetric($dbForProject, $diff, $projectKey, $period, $time);
$updateMetric($dbForProject, $diskDiff, $projectKey . '_disk', $period, $time);
break;
// Project Level
case METRIC_PROJECT_LEVEL_STORAGE:
Console::log('[' . DateTime::now() . '] Project Level Storage Calculation [' . $key . ']');
// Get all project databases
$databases = $dbForProject->find('database');
// Recalculate all databases
foreach ($databases as $database) {
$collections = $dbForProject->find('database_' . $database->getInternalId());
foreach ($collections as $collection) {
try {
$value += $dbForProject->getSizeOfCollection('database_'.$database->getInternalId().'_collection_'.$collection->getInternalId());
$diskValue += $dbForProject->getSizeOfCollectionOnDisk('database_'.$database->getInternalId().'_collection_'.$collection->getInternalId());
} catch (\Exception $e) {
// Collection not found
if ($e->getMessage() !== 'Collection not found') {
throw $e;
}
}
}
}
$diff = $value - $previousValue;
$diskDiff = $diskValue - $previousValue;
// Update Project
$projectKey = METRIC_DATABASES_STORAGE;
$updateMetric($dbForProject, $diff, $projectKey, $period, $time);
$updateMetric($dbForProject, $diskDiff, $projectKey . '_disk', $period, $time);
break;
}
}
$end = microtime(true);
console::log('[' . DateTime::now() . '] DB Storage Calculation [' . $key . '] took ' . (($end - $start) * 1000) . ' milliseconds');
}
}
@@ -28,6 +28,12 @@ class UsageDatabase extends Model
'default' => 0,
'example' => 0,
])
->addRule('storageTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total aggregated number of total storage used in bytes.',
'default' => 0,
'example' => 0,
])
->addRule('collections', [
'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of collections per period.',
@@ -42,6 +48,13 @@ class UsageDatabase extends Model
'example' => [],
'array' => true
])
->addRule('storage', [
'type' => Response::MODEL_METRIC,
'description' => 'Aggregated storage used in bytes per period.',
'default' => [],
'example' => [],
'array' => true
])
;
}
@@ -34,6 +34,12 @@ class UsageDatabases extends Model
'default' => 0,
'example' => 0,
])
->addRule('storageTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total aggregated number of total databases storage in bytes.',
'default' => 0,
'example' => 0,
])
->addRule('databases', [
'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of databases per period.',
@@ -55,6 +61,13 @@ class UsageDatabases extends Model
'example' => [],
'array' => true
])
->addRule('storage', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of the aggregated number of databases storage in bytes per period.',
'default' => [],
'example' => [],
'array' => true
])
;
}
@@ -28,6 +28,12 @@ class UsageProject extends Model
'default' => 0,
'example' => 0,
])
->addRule('databasesStorageTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total aggregated sum of databases storage size (in bytes).',
'default' => 0,
'example' => 0,
])
->addRule('usersTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total aggregated number of users.',
@@ -118,6 +124,13 @@ class UsageProject extends Model
'example' => [],
'array' => true
])
->addRule('databasesStorageBreakdown', [
'type' => Response::MODEL_METRIC_BREAKDOWN,
'description' => 'An array of the aggregated breakdown of storage usage by databases.',
'default' => [],
'example' => [],
'array' => true
])
->addRule('executionsMbSecondsBreakdown', [
'type' => Response::MODEL_METRIC_BREAKDOWN,
'description' => 'Aggregated breakdown in totals of execution mbSeconds by functions.',
+257 -3
View File
@@ -143,7 +143,7 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(20, count($response['body']));
$this->assertEquals(22, count($response['body']));
$this->validateDates($response['body']['network']);
$this->validateDates($response['body']['requests']);
$this->validateDates($response['body']['users']);
@@ -324,7 +324,7 @@ class UsageTest extends Scope
]
);
$this->assertEquals(20, count($response['body']));
$this->assertEquals(22, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']);
@@ -545,7 +545,7 @@ class UsageTest extends Scope
]
);
$this->assertEquals(20, count($response['body']));
$this->assertEquals(22, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals(1, count($response['body']['network']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
@@ -590,6 +590,260 @@ class UsageTest extends Scope
return $data;
}
public function testDatabaseStoragePrepare(): array
{
$response = $this->client->call(
Client::METHOD_POST,
'/databases',
array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()),
[
'databaseId' => 'unique()',
'name' => 'dbStorageStats',
]
);
$this->assertNotEmpty($response['body']['$id']);
$databaseId = $response['body']['$id'];
$response = $this->client->call(
Client::METHOD_POST,
'/databases/' . $databaseId . '/collections',
array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()),
[
'collectionId' => 'unique()',
'name' => 'collectionStorageStats',
'documentSecurity' => false,
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
]
);
$this->assertNotEmpty($response['body']['$id']);
$collectionId = $response['body']['$id'];
$response = $this->client->call(
Client::METHOD_POST,
'/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes' . '/string',
array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()),
[
'key' => 'data',
'size' => 100000,
'required' => true,
]
);
return [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
];
}
// /** @depends testDatabaseStoragePrepare */
// #[Retry(count: 1)]
// public function testDatabaseStorageStatsCreateDocument(array $data): array
// {
// $databaseId = $data['databaseId'];
// $collectionId = $data['collectionId'];
// $originalProjectMetrics = $this->client->call(
// Client::METHOD_GET,
// '/project/usage',
// $this->getConsoleHeaders(),
// [
// 'period' => '1d',
// 'startDate' => self::getToday(),
// 'endDate' => self::getTomorrow(),
// ]
// );
// $this->assertEquals(200, $originalProjectMetrics['headers']['status-code']);
// $this->assertArrayHasKey('databasesStorageTotal', $originalProjectMetrics['body']);
// $originalProjectMetrics = $originalProjectMetrics['body'];
// $originalDatabaseMetrics = $this->client->call(
// Client::METHOD_GET,
// '/databases/' . $databaseId . '/usage?range=30d',
// $this->getConsoleHeaders()
// );
// $this->assertEquals(200, $originalDatabaseMetrics['headers']['status-code']);
// $this->assertArrayHasKey('storageTotal', $originalDatabaseMetrics['body']);
// $originalDatabaseMetrics = $originalDatabaseMetrics['body'];
// // Create documents
// for ($i = 0; $i < 100; $i++) {
// $response = $this->client->call(
// Client::METHOD_POST,
// '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents',
// array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id']
// ], $this->getHeaders()),
// [
// 'documentId' => 'unique()',
// 'data' => ['data' => str_repeat('a', 10000)],
// ]
// );
// $this->assertEquals(201, $response['headers']['status-code']);
// }
// sleep(self::WAIT);
// for ($i = 0; $i < 3; $i++) {
// try {
// $newProjectMetrics = $this->client->call(
// Client::METHOD_GET,
// '/project/usage',
// $this->getConsoleHeaders(),
// [
// 'period' => '1d',
// 'startDate' => self::getToday(),
// 'endDate' => self::getTomorrow(),
// ]
// );
// $this->assertEquals(200, $newProjectMetrics['headers']['status-code']);
// $this->assertArrayHasKey('databasesStorageTotal', $newProjectMetrics['body']);
// $this->assertGreaterThan($originalProjectMetrics['databasesStorageTotal'], $newProjectMetrics['body']['databasesStorageTotal']);
// $newProjectMetrics = $newProjectMetrics['body'];
// $newDatabaseMetrics = $this->client->call(
// Client::METHOD_GET,
// '/databases/' . $databaseId . '/usage?range=30d',
// $this->getConsoleHeaders()
// );
// $this->assertEquals(200, $newDatabaseMetrics['headers']['status-code']);
// $this->assertArrayHasKey('storageTotal', $newDatabaseMetrics['body']);
// $this->assertGreaterThan($originalDatabaseMetrics['storageTotal'], $newDatabaseMetrics['body']['storageTotal']);
// $newDatabaseMetrics = $newDatabaseMetrics['body'];
// return [
// 'databaseId' => $databaseId,
// 'collectionId' => $collectionId,
// 'currentProjectMetrics' => $newProjectMetrics,
// 'currentDatabaseMetrics' => $newDatabaseMetrics,
// ];
// } catch (ExpectationFailedException $e) {
// if ($i === 2) {
// throw $e;
// }
// sleep(self::WAIT);
// continue;
// }
// }
// }
// /** @depends testDatabaseStorageStatsCreateDocument */
// #[Retry(count: 1)]
// public function testDatabaseStorageStatsDeleteDocument(array $data): array
// {
// $databaseId = $data['databaseId'];
// $collectionId = $data['collectionId'];
// $currentProjectMetrics = $data['currentProjectMetrics'];
// $currentDatabaseMetrics = $data['currentDatabaseMetrics'];
// $documents = $this->client->call(
// Client::METHOD_GET,
// '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents',
// array_merge([
// 'x-appwrite-project' => $this->getProject()['$id']
// ], $this->getHeaders()),
// [
// 'queries' => [
// Query::limit(50)->toString()
// ]
// ]
// );
// foreach ($documents['body']['documents'] as $document) {
// $response = $this->client->call(
// Client::METHOD_DELETE,
// '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents/' . $document['$id'],
// array_merge([
// 'x-appwrite-project' => $this->getProject()['$id']
// ], $this->getHeaders())
// );
// $this->assertEquals(204, $response['headers']['status-code']);
// }
// sleep(self::WAIT);
// for ($i = 0; $i < 3; $i++) {
// try {
// $newProjectMetrics = $this->client->call(
// Client::METHOD_GET,
// '/project/usage',
// $this->getConsoleHeaders(),
// [
// 'period' => '1d',
// 'startDate' => self::getToday(),
// 'endDate' => self::getTomorrow(),
// ]
// );
// $this->assertEquals(200, $newProjectMetrics['headers']['status-code']);
// $this->assertArrayHasKey('databasesStorageTotal', $newProjectMetrics['body']);
// $this->assertLessThan($currentProjectMetrics['databasesStorageTotal'], $newProjectMetrics['body']['databasesStorageTotal']);
// $newProjectMetrics = $newProjectMetrics['body'];
// $newDatabaseMetrics = $this->client->call(
// Client::METHOD_GET,
// '/databases/' . $databaseId . '/usage?range=30d',
// $this->getConsoleHeaders()
// );
// $this->assertEquals(200, $newDatabaseMetrics['headers']['status-code']);
// $this->assertArrayHasKey('storageTotal', $newDatabaseMetrics['body']);
// $this->assertLessThan($currentDatabaseMetrics['storageTotal'], $newDatabaseMetrics['body']['storageTotal']);
// $newDatabaseMetrics = $newDatabaseMetrics['body'];
// return [
// 'databaseId' => $databaseId,
// 'collectionId' => $collectionId,
// 'currentProjectMetrics' => $newProjectMetrics,
// 'currentDatabaseMetrics' => $newDatabaseMetrics,
// ];
// } catch (ExpectationFailedException $e) {
// if ($i === 2) {
// throw $e;
// }
// sleep(self::WAIT);
// continue;
// }
// }
// $newProjectMetrics = $this->client->call(
// Client::METHOD_GET,
// '/project/usage',
// $this->getConsoleHeaders(),
// [
// 'period' => '1d',
// 'startDate' => self::getToday(),
// 'endDate' => self::getTomorrow(),
// ]
// );
// }
/** @depends testDatabaseStats */
public function testPrepareFunctionsStats(array $data): array
@@ -224,7 +224,7 @@ class DatabasesConsoleClientTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(5, count($response['body']));
$this->assertEquals(7, count($response['body']));
$this->assertEquals('24h', $response['body']['range']);
$this->assertIsNumeric($response['body']['documentsTotal']);
$this->assertIsNumeric($response['body']['collectionsTotal']);