Skip to content

[Lock] Add LockFactoryInterface #39634

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

Closed
wants to merge 7 commits into from

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Dec 27, 2020

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? yes
Tickets
License MIT
Doc PR

I saw that the LockFactory does not have an interface. And the RateLimit component has a config option to "Add your own lock factory".

This PR includes a BC break to our experimental RateLimiter component. But it is a super minor so I am okey with it.

@jderusse
Copy link
Member

no strong opinion about this. I created a LockFactoryInyerface in the original PR (#21093) But removed afterwards (I don't remember who suggested it. Probably @nicolas-grekas if I remember well...)

The factory is pretty simple and I never needed another implementation or decoration. Do you have a use-case in mind?

@Nyholm
Copy link
Member Author

Nyholm commented Dec 27, 2020

The rate limiter provides bundle config like:

framework:
  rate_limiter:
    acme:
      lock_factory: # Any service that is an instance of LockFactory

It does not make much sense to have a config value where you pretty much have only one valid config.

Same thing with the constructor of RateLimiterFactory. The third argument should be null or an object of the LockFactory class. The dependency inversion principle says that it should be an interface instead.

So no, apart from these more or less academical reasons, I dont have a use-case.

@jderusse
Copy link
Member

It does not make much sense to have a config value where you pretty much have only one valid config.

hmm, the factory take a store in argument. You may have instance of the Factory in the DIC.

framework:
    lock:
        foo: redis://localhost
        bar: flock

provides 2 factories

@Nyholm
Copy link
Member Author

Nyholm commented Dec 27, 2020

Yes, sure, you may have multiple lock factories which all would be different objects of LockFactory. But that is still missing my point of dependency inversion.

@nicolas-grekas nicolas-grekas added this to the 5.x milestone Dec 27, 2020
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

No issue on my side.
We should deprecate the LockFactory alias and add one for the new interface also.

@Nyholm
Copy link
Member Author

Nyholm commented Dec 27, 2020

The PR is updated. There is a lot of deprecated service names and aliases.

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

I've never felt I needed a different implementation of the lock factory. The factory is just a tiny bit of glue code around the store. I don't oppose this change, but I think the current way of not having an interface is just fine.

@Nyholm
Copy link
Member Author

Nyholm commented Dec 27, 2020

I've never felt I needed a different implementation of the lock factory. The factory is just a tiny bit of glue code around the store. I don't oppose this change, but I think the current way of not having an interface is just fine.

I agree that this change is mostly academical.

@derrabus
Copy link
Member

By the way, I think we can remove the "BC Break" label. You've changed the constructor signature in a compatible way and the lock factory is assigned to a private variable and is never exposed.

@fabpot
Copy link
Member

fabpot commented Dec 28, 2020

I think it was me not wanting this interface and I haven't changed my mind. "academic" reasons are probably the worst :)

@Nyholm
Copy link
Member Author

Nyholm commented Dec 30, 2020

"academic" reasons are probably the worst :)

Hm... I disagree with that.

Thank you for reviewing and for the feedback.

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

Successfully merging this pull request may close these issues.

6 participants