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): DocumentDataProvider to allow external data sources #121

Open
Guikingone opened this issue Oct 24, 2021 · 4 comments
Open

(feat): DocumentDataProvider to allow external data sources #121

Guikingone opened this issue Oct 24, 2021 · 4 comments
Labels
enhancement New feature or request needs opinion Ask for the community opinion on a topic/enhancement

Comments

@Guikingone
Copy link

Guikingone commented Oct 24, 2021

Description

Hi everyone 👋🏻

Small suggestion here that can help the bundle supporting extra document data sources, for now, this bundle only support loading document data from entities (without asynchronous supports but more on this later), even if this is the de facto approach when it comes to data handling in Symfony application (thanks to Doctrine), we often use external services like Redis, Kafka and so on, these services contains data and we often need to search on it.

The idea here is to introduce the idea of DocumentDataProvider (or just _X_DataProvider) along with a DataProviderRegistry which allow to use the data providers and allow each provider to return an array that contains data that we can load into indexes.

Basic example

Ok, so, here's a small example:

final class FooDataProvider implements DataProviderInterface
{
    public function getData(): array
    {
        // Fetch data from external data source and return a valid array
    }

    public static function getIndex(): string // static is not a requirement
    {
        return 'foo';
    }
}

Following the same approach, an EntityDataProvider can be created to move the logic from the existing command to a dedicated class.

The final part is a DataProviderRegistry which contains and allow to access and interact with the data providers (sort them, filter them and many more) which can be injected in the command to remove some logic on it and ease both the debug and evolution phase.

Regarding the asynchronous support, when using Messenger and regarding #62, adding this layer can help introduce the asynchronous support by allowing to dispatch a message which can call the registry to persist data into MS.

I've already implemented a solution here but the final implementation can be improved 🙂

Other

--

Thanks for the feedback and have a great day 🙂

@Guikingone Guikingone changed the title (feat): DocumentDataProvider (feat): DocumentDataProvider to allow external data sources Oct 25, 2021
@curquiza
Copy link
Member

Hello @Guikingone thanks a lot for having taken the time to write this issue.
Since I'm not a Symfony user, I let people from the community to give their opinion 😄

@curquiza curquiza added enhancement New feature or request question Further information is requested needs opinion Ask for the community opinion on a topic/enhancement labels Oct 26, 2021
@norkunas
Copy link
Collaborator

norkunas commented Nov 9, 2021

I think it'd nice addition :)

@Guikingone
Copy link
Author

Hi 👋🏻

@curquiza If it's good for you, I can start working on a solution, submit a PR then we can see if it fit the bundle and improve the developer experience 🙂

@curquiza
Copy link
Member

Hello @Guikingone, thanks for your suggestion, I think we can start a work on it! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs opinion Ask for the community opinion on a topic/enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants