---
# System prepended metadata

title: Pantavisor Event System
tags: [proposal]

---

This document contains the plan to convert our main loop into an event based loop.

**IMPORTANT:** For now, this event system will not be implemented!

## Components

### Event Notifiers

The events will be sent both by the main loop and any other Pantavisor task that could be run in a different process.

### Event Listener

Then, they will be parsed and processed by the main loop so it can update its runtime data structures accordingly.

In the future, containers might also benefit from these events and become listeners to achieve a communication from Pantavisor to the containers unlike the one we already have in pv-ctrl, which is the other way around. Additionally, a library to process events from containers could be provided. 

### Broker

In order to redirect messages to the containers, the main loop will have to act as a broker that filters event messages from the notifiers.

The broker could offer the ability to register PIDs that are authorized to use the event system as notifiers.

## Message Format

The messages will be sent in JSON format. It will contain a source for identification and an arbitrary data JSON based on a type key:

```
{
    "#spec": "pvevent@1",
    "type": "type-of-data",
    "data": {
        ...
    }
}
```

For the prototype of the event message, we propose the following message types:


### Object Transfer

```
{
    "#spec": "pvevent@1",
    "type": "object-transfer",
    "data": {
        "completed": "100"
    }
}
```

### Start Containers

```
{
    "#spec": "pvevent@1",
    "type": "status-update",
    "data": {
        "name": "pvr-sdk",
        "status": "MOUNTED"
    }
}
```