Description
Although not directly related to the project itself, I'm reporting an attempt to instantiate a usable ObjectStore
within a Symfony project and a failure to extends an ObjectStore in this context.
Below service configuration provides a usable openstack_container
service:
parameters:
openstack_default_authurl: 'https://auth.cloud.ovh.net/v3'
openstack_default_region: UK1
openstack.authurl: '%env(default:openstack_default_authurl:string:OS_AUTH_URL)%'
openstack.region: '%env(default:openstack_default_region:string:OS_REGION_NAME)%'
openstack.username: '%env(string:OS_USERNAME)%'
openstack.password: '%env(string:OS_PASSWORD)%'
openstack.tenantId: '%env(string:OS_PROJECT_ID)%'
openstack.container: '%env(string:CONTAINER_NAME)%'
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
App\Service\FooBar:
lazy: true
arguments:
- '@openstack_container'
# - '@cached_openstack_container'
openstack_connection:
public: true
lazy: true
class: OpenStack\OpenStack
arguments:
-
authUrl: '%openstack.authurl%'
region: '%openstack.region%'
debugLog: true
user:
name: '%openstack.username%'
password: '%openstack.password%'
domain:
id: 'default'
scope:
project:
id: '%openstack.tenantId%'
logger: '@monolog.logger'
openstack_objectstore:
public: true
lazy: true
class: OpenStack\ObjectStore\v1\Service
factory: ['@openstack_connection', objectStoreV1]
openstack_container:
public: true
lazy: true
class: OpenStack\ObjectStore\v1\Models\Container
factory: ['@openstack_objectstore', getContainer]
arguments:
- '%openstack.container%'
Now I'd like to avoid the network round-trips of the object-store initialization when I only needs access to some container's metadata (which I can afford to cache).
I've a subclass extending Container
:
openstack_metadata_cache_storage:
class: Symfony\Component\Cache\Adapter\FilesystemAdapter
arguments: ['token', 36000, '%kernel.cache_dir%']
cached_openstack_container:
parent: openstack_container
class: App\Service\CachedOpenstackContainer
But that's where I'm getting an issue.
GuzzleHttp\ClientInterface
and OpenStack\Common\Api\ApiInterface
that OpenStack\ObjectStore\v1\Models\Container
expects and can't be initialized directly : Symfony factory+DI does not works for my subclass (lazy
or not).
How would you suggest to proceed?