Skip to content

API Reference (Notifications)

kencoken edited this page Dec 2, 2014 · 2 revisions

Introduction

In addition to the base API, the CPU Visor Service ./cpuvisor_service also provides a PUB-SUB notification service via ZMQ using Google Protobuf messages. Notifications allow for different stages in the processing of a query to be monitored and responded to (e.g. an image has finished processing, training has completed etc.)

A sample Python client for notifications (which should be run on a separate ZMQ port to the main API) is provided: pyclient/visor_notifier.py and its usage is demonstrated also in test_client.py. In general, the API service and notification service are used together.

Notifications

Once a subscriber has subscribed to the notification service, they will receive updates in the form of protocol buffer VisorNotification objects (defined in src/proto/cpuvisor_srv.proto). These take the following form:

{
  type: <NotificationType>,
  id: <Parent query ID of notification (string)>,
  data: <Custom notification-specific data (string)>
}

Through the use of notifications, the non-blocking versions of the API function calls can be used, and the entire system operated in an asynchronous manner. It is highly recommended that the API is used in this way, rather than relying on the blocking API calls.

Supported Notification Types

The following notifications are currently supported:

NTFY_STATE_CHANGE


NTFY_IMAGE_PROCESSED


NTFY_ALL_IMAGES_PROCESSED

Clone this wiki locally