@@ -72,6 +72,10 @@ struct aws_host_resolution_config {
7272 void * impl_data ;
7373};
7474
75+ struct aws_host_listener ;
76+
77+ struct aws_host_listener_options ;
78+
7579/** should you absolutely disdain the default implementation, feel free to implement your own. */
7680struct aws_host_resolver_vtable {
7781 /** clean up everything you allocated, but not resolver itself. */
@@ -95,6 +99,13 @@ struct aws_host_resolver_vtable {
9599 struct aws_host_resolver * resolver ,
96100 const struct aws_string * host_name ,
97101 uint32_t flags );
102+
103+ /** creates and adds a listener to the host resolver. */
104+ struct aws_host_listener * (
105+ * add_host_listener )(struct aws_host_resolver * resolver , const struct aws_host_listener_options * options );
106+
107+ /** removes a host listener from the host resolver and frees it. */
108+ int (* remove_host_listener )(struct aws_host_resolver * resolver , struct aws_host_listener * listener );
98109};
99110
100111struct aws_host_resolver {
@@ -211,6 +222,51 @@ AWS_IO_API size_t aws_host_resolver_get_host_address_count(
211222 const struct aws_string * host_name ,
212223 uint32_t flags );
213224
225+ /* Callback for receiving new host addresses from a listener. Memory for the new address list is only guaranteed to
226+ * exist during the callback, and must be copied if the caller needs it to persist after. */
227+ typedef void (aws_host_listener_resolved_address_fn )(
228+ /* Listener that owns this callback. */
229+ struct aws_host_listener * listener ,
230+
231+ /* Array list of aws_host_address structures. To get an item:
232+ *
233+ * struct aws_host_address *host_address = NULL;
234+ * aws_array_list_get_at_ptr(new_address_list, (void **)&host_address, address_index);
235+ * */
236+ const struct aws_array_list * new_address_list ,
237+
238+ /* User data that was specified when adding the listener. */
239+ void * user_data );
240+
241+ /* Callback for when the listener has completed its clean up. */
242+ typedef void (aws_host_listener_shutdown_fn )(void * user_data );
243+
244+ struct aws_host_listener_options {
245+
246+ /* Name of the host to listen for notifications from. */
247+ struct aws_byte_cursor host_name ;
248+
249+ /* Callback for when an address is resolved for the specified host. */
250+ aws_host_listener_resolved_address_fn * resolved_address_callback ;
251+
252+ /* Callback for when a listener has completely shutdown. */
253+ aws_host_listener_shutdown_fn * shutdown_callback ;
254+
255+ /* User data to be passed into each callback. */
256+ void * user_data ;
257+ };
258+
259+ /* Create and add a listener to the host resolver using the specified options. */
260+ AWS_IO_API struct aws_host_listener * aws_host_resolver_add_host_listener (
261+ struct aws_host_resolver * resolver ,
262+ const struct aws_host_listener_options * options );
263+
264+ /* Remove the specified listener from the host resolver, triggering clean up of the listener. Note: this may not happen
265+ * synchronously, and it is necessary to wait for the listener's shutdown callback to trigger. */
266+ AWS_IO_API int aws_host_resolver_remove_host_listener (
267+ struct aws_host_resolver * resolver ,
268+ struct aws_host_listener * listener );
269+
214270AWS_EXTERN_C_END
215271
216272#endif /* AWS_IO_HOST_RESOLVER_H */
0 commit comments