2020-04-26 19:46:58 +02:00
|
|
|
import uuid
|
|
|
|
from django.db import models
|
|
|
|
from rtmp.models import Stream
|
|
|
|
|
|
|
|
|
|
|
|
class Identity(models.Model):
|
|
|
|
# models a concierge identity. every running concierge needs to have a
|
|
|
|
# unique identity that is being used for task claims, etc.
|
2020-04-26 22:25:58 +02:00
|
|
|
identity = models.UUIDField(unique=True, default=uuid.uuid4)
|
2020-04-26 19:46:58 +02:00
|
|
|
name = models.CharField(max_length=100)
|
2020-04-26 22:25:58 +02:00
|
|
|
notes = models.TextField(blank=True)
|
2020-04-26 19:46:58 +02:00
|
|
|
|
|
|
|
# heartbeat indicates last point in time that this identity was seen.
|
|
|
|
# some cronjob should scan the heartbeats and release all claims by
|
|
|
|
# identities that have not been seen in a while. this interval should
|
|
|
|
# be quite short so that the tasks can be claimed by other identities asap.
|
2020-04-26 22:25:58 +02:00
|
|
|
heartbeat = models.DateTimeField(blank=True, null=True)
|
2020-04-26 19:46:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Task(models.Model):
|
2020-04-26 22:25:58 +02:00
|
|
|
uuid = models.UUIDField(unique=True, default=uuid.uuid4)
|
2020-04-26 19:46:58 +02:00
|
|
|
stream = models.ForeignKey(Stream, on_delete=models.CASCADE)
|
|
|
|
type = models.CharField(max_length=100)
|
|
|
|
configuration = models.TextField()
|
2020-04-26 22:25:58 +02:00
|
|
|
claimed_by = models.ForeignKey(Identity, null=True, blank=True, on_delete=models.CASCADE)
|