Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Callback for failure on document persist #37

Open
web-dev opened this issue Dec 6, 2011 · 3 comments
Open

Callback for failure on document persist #37

web-dev opened this issue Dec 6, 2011 · 3 comments

Comments

@web-dev
Copy link

web-dev commented Dec 6, 2011

When documents are persisted, having the ability to specify a callback that is called on failure to persist a particular document would be immensely helpful.

This would allow developers to manage the conflicts automatically using code; or by providing users feedback of the conflict and letting them manage it.

I propose something like the following:

$documentManager->persist($document, function($error)
{
    // Error management logic
});

If this were implemented as an optional parameter this would remain compatible with code using the existing api.

My question is: Were I to implement this feature and send a PR, would it be accepted?

@beberlei
Copy link
Member

beberlei commented Dec 6, 2011

Feature is good. But API should be an event that is fired on the event manager like onFlush/prePersist and such

Von meinem iPhone gesendet

Am 06.12.2011 um 19:46 schrieb [email protected]:

When documents are persisted, having the ability to specify a callback that is called on failure to persist a particular document would be immensely helpful.

This would allow developers to manage the conflicts automatically using code; or by providing users feedback of the conflict and letting them manage it.

I propose something like the following:

$documentManager->persist($document, function($error)
{
// Error management logic
});

If this were implemented as an optional parameter this would remain compatible with code using the existing api.

My question is: Were I to implement this feature and send a PR, would it be accepted?


Reply to this email directly or view it on GitHub:
#37

@web-dev
Copy link
Author

web-dev commented Dec 7, 2011

Is there a reason why this should be an event rather than something that can be injected on persist?

If an even manager is used then distinguishing the event for a particular document (especially when there may not be an identifier) could be difficult.

Perhaps I could implement something that emits both a generic event and also allows you to define a callback specific to a document?

@saem
Copy link
Contributor

saem commented Sep 28, 2012

The context within which the failure occurred likely knows best how to deal with resolving the issue, not some generic callback.

Even if it can't be put on the persist call due to BC issues, it should somehow be injectable by the caller, rather than the subject or callee.

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

No branches or pull requests

2 participants