Models
Models for the dasf-broker-django app.
Models:
|
A message sent to the broker. |
|
A topic for producing and consuming requests via websocket |
|
A topic that accepts responses for messages. |
Classes:
|
A manager for broker topics. |
|
A queryset for broker topics. |
- class dasf_broker.models.BrokerMessage(*args, **kwargs)
Bases:
ModelA message sent to the broker.
- Parameters:
id (BigAutoField) – Primary key: ID
message_id (UUIDField) – Message id. Message ID
context (IntegerField) – Context. Message context for messages from a producer.
content (JSONField) – Content. The content of the message.
date_created (DateTimeField) – Date created. The date and time when the message has been created
Relationship fields:
- Parameters:
topic (
ForeignKeytoBrokerTopic) – Topic. The topic the message was published for. (related name:brokermessage)user (
ForeignKeytoUser) – User. The user who produced the message. (related name:brokermessage)delivered_to (
ManyToManyFieldtoUser) – Delivered to. To whom has this message been delivered already? (related name:brokermessage_set_delivered)
Reverse relationships:
- Parameters:
responsetopic (Reverse
ManyToManyFieldfromResponseTopic) – All response topics of this broker message (related name ofsource_messages)
Miscellaneous:
Model Fields:
Type:
JSONFieldType:
IntegerFieldType:
DateTimeFieldType:
BigAutoFieldType:
UUIDFieldType:
ForeignKeytoBrokerTopicType:
ForeignKeytoUserAttributes:
Type:
ManyToManyFieldtoUserTest if the message has been delivered to all consumers.
Is this message a response to a DASF request?
Type: Reverse
ManyToManyFieldfromResponseTopicInternal field, use
topicinstead.Internal field, use
userinstead.Methods:
get_next_by_date_created(*[, field, is_next])Finds next instance based on
date_created.get_previous_by_date_created(*[, field, is_next])Finds previous instance based on
date_created.send()Send the message via the websocket.
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- content
Type:
JSONFieldContent. The content of the message.
A wrapper for a deferred-loading field. When the value is read from this
- context
Type:
IntegerFieldContext. Message context for messages from a producer.
A wrapper for a deferred-loading field. When the value is read from this
- date_created
Type:
DateTimeFieldDate created. The date and time when the message has been created
A wrapper for a deferred-loading field. When the value is read from this
- delivered_to
Type:
ManyToManyFieldtoUserDelivered to. To whom has this message been delivered already? (related name:
brokermessage_set_delivered)Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- get_next_by_date_created(*, field=<django.db.models.DateTimeField: date_created>, is_next=True, **kwargs)
Finds next instance based on
date_created. Seeget_next_by_FOO()for more information.
- get_previous_by_date_created(*, field=<django.db.models.DateTimeField: date_created>, is_next=False, **kwargs)
Finds previous instance based on
date_created. Seeget_previous_by_FOO()for more information.
- id
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- message_id
Type:
UUIDFieldMessage id. Message ID
A wrapper for a deferred-loading field. When the value is read from this
- objects = <django.db.models.Manager object>
- responsetopic_set
Type: Reverse
ManyToManyFieldfromResponseTopicAll response topics of this broker message (related name of
source_messages)Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- send()
Send the message via the websocket.
- topic
Type:
ForeignKeytoBrokerTopicTopic. The topic the message was published for. (related name:
brokermessage)Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
- user
Type:
ForeignKeytoUserUser. The user who produced the message. (related name:
brokermessage)Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
- class dasf_broker.models.BrokerTopic(*args, **kwargs)
Bases:
ModelA topic for producing and consuming requests via websocket
- Parameters:
id (BigAutoField) – Primary key: ID
slug (SlugField) – Slug. Unique identifier for the topic.
is_public (BooleanField) – Is public. Can everyone publish data to this topic?
date_created (DateTimeField) – Date created. The date and time when the message has been created
last_ping (DateTimeField) – Last ping. When has the topic last been pinged?
last_pong (DateTimeField) – Last pong. When has the topic last replyed on a ping?
supports_dasf (BooleanField) – Supports dasf. Does this topic support the DASF messaging protocoll?
store_messages (CharField) – Store messages. Should messages be stored?
garbage_collect_on (DateTimeField) – Garbage collect on. Specify a time when this topic should be removed from the database.
api_info (JSONField) –
Api info
metadata field to allow additional attributes for topics.
Reverse relationships:
- Parameters:
brokermessage (Reverse
ForeignKeyfromBrokerMessage) – All broker messages of this broker topic (related name oftopic)responsetopic (Reverse
OneToOneFieldfromResponseTopic) – The response topic of this broker topic (related name ofbrokertopic_ptr)responsetopics (Reverse
ForeignKeyfromResponseTopic) – All responsetopics of this broker topic (related name ofis_response_for)
Miscellaneous:
Classes:
StoreMessageChoices(value)Choices for storing messages.
Model Fields:
Type:
JSONFieldType:
DateTimeFieldType:
DateTimeFieldType:
BigAutoFieldType:
BooleanFieldType:
DateTimeFieldType:
DateTimeFieldType:
SlugFieldType:
CharFieldType:
BooleanFieldAttributes:
Get the online/offline status for the topic.
Type: Reverse
ForeignKeyfromBrokerMessageGet the store message rule for this topic.
Is this topic a responsetopic?
Type: Reverse
OneToOneFieldfromResponseTopicType: Reverse
ForeignKeyfromResponseTopicMethods:
build_websocket_url(request[, route])create_and_send_message(user, content)Create and send a message for the user
get_next_by_date_created(*[, field, is_next])Finds next instance based on
date_created.get_outstanding_messages([user])Get the messages that still need to be send.
get_previous_by_date_created(*[, field, is_next])Finds previous instance based on
date_created.get_store_messages_display(*[, field])Shows the label of the
store_messages.get_websocket_url(request)Get the websocket url for this topic.
ping()Create a ping message and send it to the consumer.
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- class StoreMessageChoices(value)
Bases:
TextChoicesChoices for storing messages.
Attributes:
- CACHE = 'cache'
- CACHEALL = 'cacheall'
- DISABLED = 'disabled'
- STORE = 'store'
- availability
Get the online/offline status for the topic.
This value can be
True,FalseorNone:- None
The status is unknown. This occurs when the last ping was more than two minutes ago or the topic has never, been pinged.
- False
The was no pong yet or the last pong was before the last ping and the last ping was less than two minutes ago.
- True
The topic is online, i.e. we received a pong after the last ping
- brokermessage_set
Type: Reverse
ForeignKeyfromBrokerMessageAll broker messages of this broker topic (related name of
topic)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- property consumers: models.QuerySet[User]
- create_and_send_message(user: User, content: Dict)
Create and send a message for the user
- date_created
Type:
DateTimeFieldDate created. The date and time when the message has been created
A wrapper for a deferred-loading field. When the value is read from this
- property effective_store_messages: StoreMessageChoices
Get the store message rule for this topic.
- garbage_collect_on
Type:
DateTimeFieldGarbage collect on. Specify a time when this topic should be removed from the database.
A wrapper for a deferred-loading field. When the value is read from this
- get_next_by_date_created(*, field=<django.db.models.DateTimeField: date_created>, is_next=True, **kwargs)
Finds next instance based on
date_created. Seeget_next_by_FOO()for more information.
- get_outstanding_messages(user: User | None = None) models.QuerySet[BrokerMessage]
Get the messages that still need to be send.
- Parameters:
user (Optional[User]) – The user for whom to send the messages. If None, the messages will be returned that have not yet been acknowledged at all.
- Returns:
A QuerySet of messages
- Return type:
models.QuerySet[BrokerMessage]
- get_previous_by_date_created(*, field=<django.db.models.DateTimeField: date_created>, is_next=False, **kwargs)
Finds previous instance based on
date_created. Seeget_previous_by_FOO()for more information.
- get_store_messages_display(*, field=<django.db.models.CharField: store_messages>)
Shows the label of the
store_messages. Seeget_FOO_display()for more information.
- id
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- is_public
Type:
BooleanFieldIs public. Can everyone publish data to this topic?
A wrapper for a deferred-loading field. When the value is read from this
- last_ping
Type:
DateTimeFieldLast ping. When has the topic last been pinged?
A wrapper for a deferred-loading field. When the value is read from this
- last_pong
Type:
DateTimeFieldLast pong. When has the topic last replyed on a ping?
A wrapper for a deferred-loading field. When the value is read from this
- objects = <dasf_broker.models.BrokerTopicManager object>
- ping()
Create a ping message and send it to the consumer.
- property producers: models.QuerySet[User]
- responsetopic
Type: Reverse
OneToOneFieldfromResponseTopicThe response topic of this broker topic (related name of
brokertopic_ptr)Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
- responsetopics
Type: Reverse
ForeignKeyfromResponseTopicAll responsetopics of this broker topic (related name of
is_response_for)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- slug
Type:
SlugFieldSlug. Unique identifier for the topic.
A wrapper for a deferred-loading field. When the value is read from this
- property status_viewers: models.QuerySet[User]
- store_messages
Type:
CharFieldStore messages. Should messages be stored?
Choices:
Nonedisabledcachecacheallstore
A wrapper for a deferred-loading field. When the value is read from this
- supports_dasf
Type:
BooleanFieldSupports dasf. Does this topic support the DASF messaging protocoll?
A wrapper for a deferred-loading field. When the value is read from this
- class dasf_broker.models.BrokerTopicManager(*args, **kwargs)
Bases:
ManagerFromBrokerTopicQuerySetA manager for broker topics.
- class dasf_broker.models.BrokerTopicQuerySet(model=None, query=None, using=None, hints=None)
Bases:
QuerySetA queryset for broker topics.
Methods:
filter_offline(*args)Query all online broker topics.
filter_online(*args, **kwargs)Query all online broker topics.
filter_unknown_availability(*args)Query all topics where the availability is unknown.
- filter_offline(*args)
Query all online broker topics.
- filter_online(*args, **kwargs)
Query all online broker topics.
- filter_unknown_availability(*args)
Query all topics where the availability is unknown.
- class dasf_broker.models.ResponseTopic(*args, **kwargs)
Bases:
BrokerTopicA topic that accepts responses for messages.
- Parameters:
id (BigAutoField) – Primary key: ID
slug (SlugField) – Slug. Unique identifier for the topic.
is_public (BooleanField) – Is public. Can everyone publish data to this topic?
date_created (DateTimeField) – Date created. The date and time when the message has been created
last_ping (DateTimeField) – Last ping. When has the topic last been pinged?
last_pong (DateTimeField) – Last pong. When has the topic last replyed on a ping?
supports_dasf (BooleanField) – Supports dasf. Does this topic support the DASF messaging protocoll?
store_messages (CharField) – Store messages. Should messages be stored?
garbage_collect_on (DateTimeField) – Garbage collect on. Specify a time when this topic should be removed from the database.
api_info (JSONField) –
Api info
metadata field to allow additional attributes for topics.
Relationship fields:
- Parameters:
brokertopic_ptr (
OneToOneFieldtoBrokerTopic) – Primary key: Brokertopic ptr (related name:responsetopic)is_response_for (
ForeignKeytoBrokerTopic) – Is response for. Is this topic used only once for a single response? (related name:responsetopics)source_messages (
ManyToManyFieldtoBrokerMessage) – Source messages. Messages from the producer to the reference topic. (related name:responsetopic)
Reverse relationships:
- Parameters:
brokermessage (Reverse
ForeignKeyfromBrokerMessage) – All broker messages of this broker topic (related name oftopic)responsetopics (Reverse
ForeignKeyfromResponseTopic) – All responsetopics of this broker topic (related name ofis_response_for)
Miscellaneous:
Model Fields:
Type:
OneToOneFieldtoBrokerTopicType:
ForeignKeytoBrokerTopicAttributes:
Internal field, use
brokertopic_ptrinstead.Internal field, use
is_response_forinstead.Is this topic a responsetopic?
Type:
ManyToManyFieldtoBrokerMessage- exception DoesNotExist
Bases:
DoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- brokertopic_ptr: BrokerTopic
Type:
OneToOneFieldtoBrokerTopicPrimary key: Brokertopic ptr (related name:
responsetopic)Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
- brokertopic_ptr_id
Internal field, use
brokertopic_ptrinstead.
- is_response_for
Type:
ForeignKeytoBrokerTopicIs response for. Is this topic used only once for a single response? (related name:
responsetopics)Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
- is_response_for_id
Internal field, use
is_response_forinstead.
- source_messages
Type:
ManyToManyFieldtoBrokerMessageSource messages. Messages from the producer to the reference topic. (related name:
responsetopic)Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager