[asterisk-dev] [Code Review] 4215: sorcery: Add additional observer capabilities.

Kevin Harwell reviewboard at asterisk.org
Tue Dec 2 18:17:25 CST 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4215/#review13868
-----------------------------------------------------------


Just a general question. I know these are "observers", but would it make any sense to have them return a pass/fail value or something.  So for instance, would there ever be a reason to stop a registration of something because the observer failed.  That functionality may not make much sense/be needed here though.  Thoughts?


branches/12/include/asterisk/sorcery.h
<https://reviewboard.asterisk.org/r/4215/#comment24361>

    would it make sense to have this part of the global observers since "wizard_registered" is?



branches/12/main/sorcery.c
<https://reviewboard.asterisk.org/r/4215/#comment24358>

    This can be removed as it will be called once the container's refcount reaches zero.



branches/12/main/sorcery.c
<https://reviewboard.asterisk.org/r/4215/#comment24359>

    This can be removed as well. Unless for some reason there is a need to remove all items while still potentially holding a reference someplace.



branches/12/main/sorcery.c
<https://reviewboard.asterisk.org/r/4215/#comment24360>

    This shouldn't be needed either.


- Kevin Harwell


On Dec. 1, 2014, 5:50 p.m., George Joseph wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4215/
> -----------------------------------------------------------
> 
> (Updated Dec. 1, 2014, 5:50 p.m.)
> 
> 
> Review request for Asterisk Developers and Joshua Colp.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> 
> Interface for the global sorcery observer
> 
> /*! \brief Callback after an instance is created */
> void (*instance_created)(const char *name, struct ast_sorcery *sorcery);
> 
> /*! \brief Callback after an wizard is registered */
> void (*wizard_registered)(const char *name, const struct ast_sorcery_wizard *wizard);
> 
> 
> Interface for the sorcery instance observer
> 
> /*! \brief Callback before an instance is destroyed */
> void (*instance_destroyed)(const char *name, struct ast_sorcery *sorcery);
> 
> /*! \brief Callback before instance is loaded/reloaded */
> void (*instance_loading)(const char *name, const struct ast_sorcery *sorcery,
>    int reloaded);
> 
> /*! \brief Callback after instance is loaded/reloaded */
> void (*instance_loaded)(const char *name, const struct ast_sorcery *sorcery,
>    int reloaded);
> 
> /*! \brief Callback after a wizard is mapped to an object_type */
> void (*wizard_mapped)(const char *name, struct ast_sorcery *sorcery,
>    const char *object_type, struct ast_sorcery_wizard *wizard, const char *wizard_args,
>    void *wizard_data);
> 
> /*! \brief Callback after any obect_type is registered */
> void (*object_type_registered)(const char *name, struct ast_sorcery *sorcery,
>    const char *object_type);
> 
> /*! \brief Callback before any obect_type is loaded/reloaded */
> void (*object_type_loading)(const char *name, const struct ast_sorcery *sorcery,
>    const char *object_type, int reloaded);
> 
> /*! \brief Callback after any obect_type is loaded/reloaded */
> void (*object_type_loaded)(const char *name, const struct ast_sorcery *sorcery,
>    const char *object_type, int reloaded);
> 
> 
> Interface for the sorcery wizard observer
> 
> /*! \brief Callback before a wizard is unregistered */
> void (*wizard_unregistered)(const char *name, const struct ast_sorcery_wizard *wizard);
> 
> /*! \brief Callback after a wizard is loaded/reloaded for any type */
> void (*wizard_loaded)(const char *name, const struct ast_sorcery_wizard *wizard,
>    const char *object_type, int reloaded);
> 
> 
> Add the following observer add/remove APIs
> 
> int ast_sorcery_global_observer_add(const struct ast_sorcery_global_observer *callbacks);
> void ast_sorcery_global_observer_remove(const struct ast_sorcery_global_observer *callbacks);
> int ast_sorcery_instance_observer_add(struct ast_sorcery *sorcery,
> 	const struct ast_sorcery_instance_observer *callbacks);
> void ast_sorcery_instance_observer_remove(struct ast_sorcery *sorcery,
> 	const struct ast_sorcery_instance_observer *callbacks);
> int ast_sorcery_wizard_observer_add(struct ast_sorcery_wizard *wizard,
> 	const struct ast_sorcery_wizard_observer *callbacks);
> void ast_sorcery_wizard_observer_remove(struct ast_sorcery_wizard *wizard,
> 	const struct ast_sorcery_wizard_observer *callbacks);
> 
> 
> Expose the following apply mapping APIs for future use...
> 
> enum ast_sorcery_apply_result __ast_sorcery_apply_wizard_mapping(struct ast_sorcery *sorcery,
> 		const char *type, const char *module, const char *name, const char *data, unsigned int caching);
> #define ast_sorcery_apply_wizard_mapping(sorcery, type, name, data, caching) \
> 	__ast_sorcery_apply_wizard_mapping((sorcery), (type), AST_MODULE, (name), (data), (caching));
> 
> 
> Diffs
> -----
> 
>   branches/12/tests/test_sorcery.c 428724 
>   branches/12/main/sorcery.c 428724 
>   branches/12/include/asterisk/test.h 428724 
>   branches/12/include/asterisk/sorcery.h 428724 
> 
> Diff: https://reviewboard.asterisk.org/r/4215/diff/
> 
> 
> Testing
> -------
> 
> All existing unit tests pass.
> Additional sorcery units tests were added for the new observers.
> Testsuite testing resulted in no new failures.
> 
> 
> Thanks,
> 
> George Joseph
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141203/c3cc19bc/attachment-0001.html>


More information about the asterisk-dev mailing list