Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat redis sync #4540

Closed
wants to merge 48 commits into from
Closed

Feat redis sync #4540

wants to merge 48 commits into from

Conversation

shimonewman
Copy link
Contributor

@shimonewman shimonewman commented Oct 20, 2022

  • Cache re-invoking issue

Copy link
Member

@eldadfux eldadfux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left my review, please read all comments before starting to adapt the PR as they kind of complete each other.

app/config/collections.php Outdated Show resolved Hide resolved
app/config/collections.php Outdated Show resolved Hide resolved
app/config/collections.php Show resolved Hide resolved
app/config/regions.php Outdated Show resolved Hide resolved
app/config/regions.php Outdated Show resolved Hide resolved
app/workers/syncsIn.php Outdated Show resolved Hide resolved
app/workers/syncsIn.php Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
…to feat-redis-sync

� Conflicts:
�	app/init.php
�	app/preload.php
�	composer.json
�	composer.lock
@shimonewman shimonewman changed the base branch from master to feat-db-pools-eldad October 25, 2022 09:35
@@ -0,0 +1,28 @@
<?php

return [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated before merging. No need for default region.

'syncs' => [
'key' => 'edge',
'name' => 'edge',
'subtitle' => 'Appwrite\'s cache edge sync Endpoint',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'subtitle' => 'Appwrite\'s cache edge sync Endpoint',
'subtitle' => 'TBD,

'key' => 'edge',
'name' => 'edge',
'subtitle' => 'Appwrite\'s cache edge sync Endpoint',
'description' => 'Cache edge sync Endpoint',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'description' => 'Cache edge sync Endpoint',
'description' => 'TBD',

->action(function (Request $request) {

$token = $request->getHeader('authorization');
$token = str_replace(["Bearer"," "], "", $token);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we missing here a space that needs to be removed?
Authorization: Bearer {token}

Comment on lines 46 to 65
$fallbackForRedis = AppwriteURL::unparse([
'scheme' => 'redis',
'host' => App::getEnv('_APP_REDIS_HOST', 'redis'),
'port' => App::getEnv('_APP_REDIS_PORT', '6379'),
'user' => App::getEnv('_APP_REDIS_USER', ''),
'pass' => App::getEnv('_APP_REDIS_PASS', ''),
]);

$connection = App::getEnv('_APP_CONNECTIONS_QUEUE', $fallbackForRedis);
$dsns = explode(',', $connection ?? '');

if (empty($dsns)) {
Console::error("No Dsn found");
}

$dsn = explode('=', $dsns[0]);
$dsn = $dsn[1] ?? '';
$dsn = new DSN($dsn);

$client = new SyncIn('syncIn', new QueueRedis($dsn->getHost(), $dsn->getPort()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how we should implement it. By doing this, you create a new Redis connection on every API call. This should be handled as a resource that can use dependency injection.

app/tasks/sync-edge.php Outdated Show resolved Hide resolved
}

global $register;
global $dsn;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use dependency injection, even if need to copy-paste. We are working on a mechanism for share dependencies between http, realtime, workers, cli.

app/workers/sync-In.php Outdated Show resolved Hide resolved
* @throws Structure
* @throws Exception
*/
function handle($dbForConsole, $regions, $stack): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very generic name. Let's try to find a better one.

app/workers/sync-out.php Outdated Show resolved Hide resolved
…t-redis-sync

� Conflicts:
�	.env
�	Dockerfile
�	app/cli.php
�	app/init.php
�	app/preload.php
�	app/worker.php
�	composer.json
�	composer.lock
�	src/Appwrite/Platform/Tasks/Maintenance.php
�	src/Appwrite/Platform/Tasks/sync-edge.php
…t-redis-sync

� Conflicts:
�	app/config/regions.php
�	app/init.php
�	composer.lock
�	docker-compose.yml
…t-redis-sync

� Conflicts:
�	composer.lock
�	docker-compose.yml
@shimonewman shimonewman changed the base branch from feat-db-pools-eldad to feat-db-pools December 19, 2022 12:41
@christyjacob4 christyjacob4 deleted the branch cl-1.2.x May 23, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants