SearchApiTypesenseService is not a proper service

Created on 4 January 2022, almost 3 years ago
Updated 24 March 2024, 8 months ago

Problem/Motivation

SearchApiTypesenseService is registered as a service, search_api_typesense.api, however it doesn't correctly work as a service.

It can't be used until its setAuthorization() is called. Without that, any call to its methods will crash because connection() tries to create a client factory without authorisation.

Once setAuthorization() has been called, the SearchApiTypesenseService is tied to a particular backend. You can change it to another backend by calling setAuthorization() again, but because services are singletons, it means that you always have to call it as another call could potentially have changed the authorisation details on the service!

I'm not quite sure what a better pattern would be, but this class itself shouldn't be a service.

Maybe something like the way logger channels have a factory class which is a service -- https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Logger%21...

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024