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

Support of other ORM's #99

Open
konrad-czernecki-esky opened this issue Aug 8, 2024 · 3 comments
Open

Support of other ORM's #99

konrad-czernecki-esky opened this issue Aug 8, 2024 · 3 comments

Comments

@konrad-czernecki-esky
Copy link

konrad-czernecki-esky commented Aug 8, 2024

Hi, currently we can't use this library with the doctrine/mongodb-odm, even though MongoDB is quite a popular database in the PHP world.

It would be nice to have native support in the library or at least the possibility to do the integration on your own (maybe some interfaces available in the messenger-monitor-bundle library that can be implemented and will allow us to use other ORM than doctrine/orm)

@andrew-demb
Copy link

maybe some interfaces available in the messenger-monitor-bundle library that can be implemented and will allow us to use other ORM than doctrine/orm

Here it is https://github.com/zenstruck/messenger-monitor-bundle/blob/v0.4.0/src/History/Storage.php

@konrad-czernecki-esky
Copy link
Author

konrad-czernecki-esky commented Aug 12, 2024

I did not know about it, thanks!

I've tried it, but I've noticed a few problems:

  1. You have to write mapping of ProcessedMessage and Results because "doctrinemongodb-odm" does not map fields automatically
  2. Mapping cannot be done using attributes, because properties are private in ProcessedMessage, so I had to use XML mapping
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mongo-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
                        xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
                http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
    <mapped-superclass name="Zenstruck\Messenger\Monitor\History\Model\ProcessedMessage">
        <field name="runId" type="int"/>
        <field name="attempt" type="int"/>
        <field name="type" type="string"/>
        <field name="description" type="string" nullable="true"/>
        <field name="dispatchedAt" type="date_immutable"/>
        <field name="receivedAt" type="date_immutable"/>
        <field name="finishedAt" type="date_immutable"/>
        <field name="memoryUsage" type="int"/>
        <field name="transport" type="string"/>
        <field name="tags" type="string" nullable="true"/>
        <field name="failureType" type="string" nullable="true"/>
        <field name="failureMessage" type="string" nullable="true"/>
        <embed-one field="results" target-document="Zenstruck\Messenger\Monitor\History\Model\Results" />
    </mapped-superclass>
</doctrine-mongo-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mongo-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
                        xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
                        http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">

    <embedded-document name="Zenstruck\Messenger\Monitor\History\Model\Results">
        <field name="data" type="hash" />
    </embedded-document>

</doctrine-mongo-mapping>

@kbond
Copy link
Member

kbond commented Nov 10, 2024

I'd like to first add mongodb support to zenstruck/collection. That would make this much easier.

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

No branches or pull requests

3 participants