[Patchew-devel] [PATCH 12/16] maintainer: Add MessageQueued and MessageDropping events

Fam Zheng posted 16 patches 5 years, 9 months ago
[Patchew-devel] [PATCH 12/16] maintainer: Add MessageQueued and MessageDropping events
Posted by Fam Zheng 5 years, 9 months ago
These events are not used internally but is an interesting point where
users can receive notifications when the watched queue is updated.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 mods/maintainer.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/mods/maintainer.py b/mods/maintainer.py
index 665b074..6b09057 100644
--- a/mods/maintainer.py
+++ b/mods/maintainer.py
@@ -16,7 +16,7 @@ from mod import PatchewModule
 from api.models import Message, Queue, WatchedQuery
 from django.shortcuts import render
 from api.search import SearchEngine
-from event import register_handler
+from event import declare_event, register_handler, emit_event
 
 class MaintainerModule(PatchewModule):
     """ Project maintainer related tasks """
@@ -25,6 +25,12 @@ class MaintainerModule(PatchewModule):
 
     def __init__(self):
         register_handler("ResultUpdate", self.on_result_update)
+        declare_event("MessageQueued",
+                      message="Message added",
+                      queue="The updated queue")
+        declare_event("MessageDropping",
+                      message="Message to be dropped",
+                      queue="Message is about to be dropping from a queue")
 
     def _add_to_queue(self, user, m, queue):
         for x in [m] + list(m.get_patches()):
-- 
2.17.2

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
Re: [Patchew-devel] [PATCH 12/16] maintainer: Add MessageQueued and MessageDropping events
Posted by Paolo Bonzini 5 years, 9 months ago
On 21/11/18 03:08, Fam Zheng wrote:
> These events are not used internally but is an interesting point where
> users can receive notifications when the watched queue is updated.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  mods/maintainer.py | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/mods/maintainer.py b/mods/maintainer.py
> index 665b074..6b09057 100644
> --- a/mods/maintainer.py
> +++ b/mods/maintainer.py
> @@ -16,7 +16,7 @@ from mod import PatchewModule
>  from api.models import Message, Queue, WatchedQuery
>  from django.shortcuts import render
>  from api.search import SearchEngine
> -from event import register_handler
> +from event import declare_event, register_handler, emit_event
>  
>  class MaintainerModule(PatchewModule):
>      """ Project maintainer related tasks """
> @@ -25,6 +25,12 @@ class MaintainerModule(PatchewModule):
>  
>      def __init__(self):
>          register_handler("ResultUpdate", self.on_result_update)
> +        declare_event("MessageQueued",
> +                      message="Message added",
> +                      queue="The updated queue")
> +        declare_event("MessageDropping",
> +                      message="Message to be dropped",
> +                      queue="Message is about to be dropping from a queue")
>  
>      def _add_to_queue(self, user, m, queue):
>          for x in [m] + list(m.get_patches()):
> 

Missing code to emit the event?...

Paolo

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel