Skip to content

Callbacks

Bhaskar Maddala edited this page Oct 13, 2015 · 1 revision

Overview

Callbacks in Collins are of utmost importance and are used for Solr indexing of asset and asset log information. Callbacks are also required for the firehose

Architecture

While the meat of the implementation is in the package collins.callbacks, the models play a very important role in the implementation. Any model that extends trait BasicModel can indicate the need to fire callbacks on create and delete by providing an implementation for the methods createEventName and deleteEventName.

Models that extend trait AnormAdapter similarly can request to fire callback on update by providing an implemnetation for the methods updateEventName

Dispatch

Callbacks are dispatched via an actor configured by the akka property change_queue_processor in the production config. Callbacks can be configured to be invoked on an event name, this event name must match the name provided by the model overrides. For example the Asset model specifies the following event name

override protected val createEventName = Some("asset_create")
override protected val updateEventName = Some("asset_update")
override protected val deleteEventName = Some("asset_delete")

Callback can be configured via the configuration file to have a previous and current condition. These conditions can make use of any of the Boolean properties specified in AssetView. The common use case is to use the status values

def isIncomplete(): Boolean
def isNew(): Boolean
def isUnallocated(): Boolean
def isProvisioning(): Boolean
def isProvisioned(): Boolean
def isAllocated(): Boolean
def isCancelled(): Boolean
def isDecommissioned(): Boolean
def isMaintenance(): Boolean
Clone this wiki locally