WSGI¶
Reference documentation for the WSGI framework implemented in DMS.
Protocols¶
Client¶
Clients use JSON encoding to send their requests to the server.
Client XMLHttpRequests must adhere to the framework format specification.
A message consists of two parts: an enveloppe (header) and a content (body). The header has pre-defined (key, value) pairs interpreted by the framework. The body can be any content relevant to the application.
The enveloppe fields serialize and compress are used to indicate how the client expects its response.
Specification:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified"
vc:minVersion="1.1">
<xs:complexType name="header_t">
<xs:all>
<xs:element default="msgpack" name="serialize">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="msgpack"/>
<xs:enumeration value="json"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element default="lz4" name="compress">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="lz4"/>
<xs:enumeration value="gzip"/>
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
<xs:complexType name="message_t">
<xs:all>
<xs:element name="header" type="header_t"/>
<xs:element name="body" type="xs:anyType"/>
</xs:all>
</xs:complexType>
<xs:element name="message" type="message_t"/>
</xs:schema>
Example:
{
"header": {
"compress": "lz4",
"serialize": "msgpack"
},
"body": {
"time_range": [
"2020-04-14 07:00",
"2020-04-14 14:00"
],
"xargs": {
"parallel": false,
"reduce": false,
"lttb": ["fixed" , 1000] # "fixed" or "scaled",
"kind": "time",
"decimate": 60
}
}
}
DMS wrappers
Javascript <wsgi-client> webcomponent
Python
Server¶
The DMS server is consists of a web server with the following capabilties
serving http content to web browser clients using Nginx (1).
The pages are built using the Google Polymer framework to create custom webcomponents (2).
serving XmlHttpRequest using uWSGI
Response to clients adhere to the framework format specification.
A response consists of a status code. error message, and response content. The response is serialized and compressed using parameters defined in the client header request.
Originally used Apache.
We are planning to migrate over more popular frameworks e.g., React or Angular.
Specification:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified"
vc:minVersion="1.1">
<xs:complexType name="header_t">
<xs:all>
<xs:element name="status" type="xs:int"> </xs:element>
<xs:element name="message" type="xs:string"> </xs:element>
</xs:all>
</xs:complexType>
<xs:complexType name="response_t">
<xs:all>
<xs:element name="header" type="header_t"/>
<xs:element name="body" type="xs:anyType"/>
</xs:all>
</xs:complexType>
<xs:element name="response" type="response_t"/>
</xs:schema>
Examples:
on-success
{
"header": {
"status": 0,
"message": ""
},
"body": {
"foo": "bar"
}
}
on-error
{
"header": {
"status": -1,
"message": "An error occured."
},
"body": null
}