Review Board 1.7.16


Add a _remove method for routes on a message_router.

Review Request #2591 - Created June 4, 2013 and submitted

Jason Parker
/trunk/
Reviewers
asterisk-dev
dlee
Asterisk
Requested on review 2586.

Convert router routes to ao2_containers and add a way of removing them.
Stuff didn't crash when I unloaded my module that removes routes.  Messages still got routed through AMI.

Diff revision 2

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

1 2 3
1 2 3

  1. /trunk/include/asterisk/stasis_message_router.h: Loading...
  2. /trunk/main/stasis_message_router.c: Loading...
/trunk/include/asterisk/stasis_message_router.h
Revision 390386 New Change
[20] 44 lines
[+20]
45
/*! \brief Stasis message routing object */
45
/*! \brief Stasis message routing object */
46
struct stasis_message_router;
46
struct stasis_message_router;
47

    
   
47

   
48
/*!
48
/*!
49
 * \brief Create a new message router object.
49
 * \brief Create a new message router object.

    
   
50
 *
50
 * \param topic Topic to subscribe route to.
51
 * \param topic Topic to subscribe route to.

    
   
52
 *
51
 * \return New \ref stasis_message_router.
53
 * \return New \ref stasis_message_router.
52
 * \return \c NULL on error.
54
 * \return \c NULL on error.

    
   
55
 *
53
 * \since 12
56
 * \since 12
54
 */
57
 */
55
struct stasis_message_router *stasis_message_router_create(
58
struct stasis_message_router *stasis_message_router_create(
56
	struct stasis_topic *topic);
59
	struct stasis_topic *topic);
57

    
   
60

   
58
/*!
61
/*!
59
 * \brief Unsubscribe the router from the upstream topic.
62
 * \brief Unsubscribe the router from the upstream topic.
60
 *
63
 *
61
 * \param router Router to unsubscribe.
64
 * \param router Router to unsubscribe.

    
   
65
 *
62
 * \since 12
66
 * \since 12
63
 */
67
 */
64
void stasis_message_router_unsubscribe(struct stasis_message_router *router);
68
void stasis_message_router_unsubscribe(struct stasis_message_router *router);
65

    
   
69

   
66
/*!
70
/*!
67
 * \brief Unsubscribe the router from the upstream topic, blocking until the
71
 * \brief Unsubscribe the router from the upstream topic, blocking until the
68
 * final message has been processed.
72
 * final message has been processed.
69
 *
73
 *
70
 * See stasis_unsubscribe_and_join() for info on when to use this
74
 * See stasis_unsubscribe_and_join() for info on when to use this
71
 * vs. stasis_message_router_unsubscribe().
75
 * vs. stasis_message_router_unsubscribe().
72
 *
76
 *
73
 * \param router Router to unsubscribe.
77
 * \param router Router to unsubscribe.

    
   
78
 *
74
 * \since 12
79
 * \since 12
75
 */
80
 */
76
void stasis_message_router_unsubscribe_and_join(
81
void stasis_message_router_unsubscribe_and_join(
77
	struct stasis_message_router *router);
82
	struct stasis_message_router *router);
78

    
   
83

   
79
/*!
84
/*!
80
 * \brief Returns whether \a router has received its final message.
85
 * \brief Returns whether \a router has received its final message.
81
 *
86
 *
82
 * \param router Router.
87
 * \param router Router.

    
   
88
 *
83
 * \return True (non-zero) if stasis_subscription_final_message() has been
89
 * \return True (non-zero) if stasis_subscription_final_message() has been
84
 *         received.
90
 *         received.
85
 * \return False (zero) if waiting for the end.
91
 * \return False (zero) if waiting for the end.
86
 */
92
 */
87
int stasis_message_router_is_done(struct stasis_message_router *router);
93
int stasis_message_router_is_done(struct stasis_message_router *router);
88

    
   
94

   
89
/*!
95
/*!
90
 * \brief Add a route to a message router.
96
 * \brief Add a route to a message router.

    
   
97
 *
91
 * \param router Router to add the route to.
98
 * \param router Router to add the route to.
92
 * \param message_type Type of message to route.
99
 * \param message_type Type of message to route.
93
 * \param callback Callback to forard messages of \a message_type to.
100
 * \param callback Callback to forard messages of \a message_type to.
94
 * \param data Data pointer to pass to \a callback.
101
 * \param data Data pointer to pass to \a callback.

    
   
102
 *

    
   
103
 * \retval 0 on success

    
   
104
 * \retval -1 on failure

    
   
105
 *
95
 * \since 12
106
 * \since 12
96
 */
107
 */
97
int stasis_message_router_add(struct stasis_message_router *router,
108
int stasis_message_router_add(struct stasis_message_router *router,
98
			      struct stasis_message_type *message_type,
109
			      struct stasis_message_type *message_type,
99
			      stasis_subscription_cb callback,
110
			      stasis_subscription_cb callback,
100
			      void *data);
111
			      void *data);
101

    
   
112

   
102
/*!
113
/*!

    
   
114
 * \brief Remove a route from a message router.

    
   
115
 *

    
   
116
 * \param router Router to remove the route from.

    
   
117
 * \param message_type Type of message to route.

    
   
118
 *

    
   
119
 * \retval 0 on success

    
   
120
 * \retval -1 on failure

    
   
121
 *

    
   
122
 * \since 12

    
   
123
 */

    
   
124
int stasis_message_router_remove(struct stasis_message_router *router,

    
   
125
			      struct stasis_message_type *message_type);

    
   
126

   

    
   
127
/*!
103
 * \brief Sets the default route of a router.
128
 * \brief Sets the default route of a router.

    
   
129
 *
104
 * \param router Router to set the default route of.
130
 * \param router Router to set the default route of.
105
 * \param callback Callback to forard messages which otherwise have no home.
131
 * \param callback Callback to forard messages which otherwise have no home.
106
 * \param data Data pointer to pass to \a callback.
132
 * \param data Data pointer to pass to \a callback.

    
   
133
 *

    
   
134
 * \retval 0 on success

    
   
135
 * \retval -1 on failure

    
   
136
 *
107
 * \since 12
137
 * \since 12
108
 */
138
 */
109
int stasis_message_router_set_default(struct stasis_message_router *router,
139
int stasis_message_router_set_default(struct stasis_message_router *router,
110
				      stasis_subscription_cb callback,
140
				      stasis_subscription_cb callback,
111
				      void *data);
141
				      void *data);
112

    
   
142

   
113
#endif /* _ASTERISK_STASIS_MESSAGE_ROUTER_H */
143
#endif /* _ASTERISK_STASIS_MESSAGE_ROUTER_H */
/trunk/main/stasis_message_router.c
Revision 390386 New Change
 
  1. /trunk/include/asterisk/stasis_message_router.h: Loading...
  2. /trunk/main/stasis_message_router.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.