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

Journal always gets default client #49

Closed
jankonas opened this issue Nov 10, 2023 · 3 comments
Closed

Journal always gets default client #49

jankonas opened this issue Nov 10, 2023 · 3 comments

Comments

@jankonas
Copy link
Contributor

I am doing some non-traditional stuff with caching and so I found out that the RedisJournal object always gets the autowired (default) redis client instead of the one from it's connection:

$builder->addDefinition($this->prefix('connection.' . $name . '.journal'))
	->setFactory(RedisJournal::class)
	->setAutowired(false);

$builder->addDefinition($this->prefix('connection.' . $name . '.storage'))
	->setFactory(RedisStorage::class)
	->setArguments([
		'client' => $builder->getDefinition($this->prefix('connection.' . $name . '.client')), // shouldn't this be in the Journal factory too?
		'journal' => $builder->getDefinition($this->prefix('connection.' . $name . '.journal')),
		'serializer' => $config->serializer,
	])
	->setAutowired($autowired);

It's a pretty straightforward fix, but I am not sure if it is really a bug or an intended behaviour.

@jankonas
Copy link
Contributor Author

Also because of this the extension is not working when there is no connection named default because the journal is missing autowired client:

Fatal error: Uncaught Nette\DI\ServiceCreationException: Service 'redis.connection.xxx.journal' (type of Contributte\Redis\Caching\RedisJournal): Service of type Predis\ClientInterface required by $client in RedisJournal::__construct() not found. Did you add it to configuration file? in /app/vendor/nette/di/src/DI/Resolver.php:635

@vitkutny
Copy link
Contributor

I have fixed this issue few days ago. Take a look at configuration in PR #47 , journal now does not require any autowired client – always uses correct client definition by name

@jankonas
Copy link
Contributor Author

You're right, I didn't notice new commits after last released version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants