Skip to content

Commit 5ced3bd

Browse files
authored
added readme and license (#1)
1 parent 4aa82b1 commit 5ced3bd

3 files changed

Lines changed: 118 additions & 0 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
venv3
2+
.mypy_cache/
3+
.idea
4+
*.pyc
5+
.precommit_hashes
6+
*.egg-info
7+
*.generated_from_test.hpp
8+
sandbox-cpp-build
9+
sandbox/cpp/cmake-build-debug

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Parquery
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Mapry
2+
=====
3+
4+
!!! THIS IS WORK IN PROGRESS. PLEASE DO NOT USE YET !!!
5+
6+
Mapry generates polyglot code for de/serializing object graphs in JSON format.
7+
8+
**Use case**. We needed a yet another domain-specific language for system configuration. The existing solutions
9+
mostly focused on modeling the configuration as *object trees* in which the configuration is structured hierarchically
10+
with no cross-references between the objects. We found this structure to be hihgly limiting for most of the complex
11+
system configuration which required objects to be referenced among each other.
12+
13+
We wanted the serialization itself to be readable so that an operator can edit it using a simple text editor. JSON
14+
offered itself as a good fit there with a lot of existing assistance tools.
15+
16+
We decided against a NoSQL database as these add an administration burden which is justifyable for dynamic system, but
17+
we found that burden completely unnecessary for rather static structures such as configuration.
18+
19+
Hence we developed a generator that produces code to de/serialize **object graphs** from **readable JSON files**.
20+
21+
**Maintainability**. We wanted to facilitate maintainability of the system through static checks so that most errors
22+
in the object graphs are registered prior to the deployment in the production. These checks include strong typing,
23+
dangling references and certain value checks (*e.g.*, range checks, minimum number of elements in containers *etc*.).
24+
25+
The **schema** of the object graph is stored in a separate JSON file and defines all the data types used in the object
26+
graph including the object graph itself.
27+
28+
**Code readability over speed**. We wanted the generated code to be rather readable than fast.
29+
Though the users do not care about the implementation details most of the time, newcomers really like to peek under
30+
the hub. We found that its much easier for them to get up to speed when the generated code is well-readable.
31+
32+
This is particularly important when the code serialization tool permeates most of your system components.
33+
34+
**Supported languages**. Currently, Mapry speaks C++, Python and Go.
35+
36+
37+
We were not happy with the existing de/serializers:
38+
39+
* Proto3 and Cap'n proto can not handle object graphs (only object trees).
40+
* Flatbuffers do not handle JSON.
41+
* Boost serialization does not handle JSON nicely. Additionally, its XML format is not really human-readable.
42+
* ThorsSerializer produces unreadable JSON files.
43+
44+
Installation
45+
============
46+
47+
* Create a virtual environment:
48+
49+
.. code-block:: bash
50+
51+
python3 -m venv venv3
52+
53+
* Activate it:
54+
55+
.. code-block:: bash
56+
57+
source venv3/bin/activate
58+
59+
* Install mapry with pip:
60+
61+
.. code-block:: bash
62+
63+
pip3 install mapry
64+
65+
Development
66+
===========
67+
68+
* Check out the repository.
69+
70+
* In the repository root, create the virtual environment:
71+
72+
.. code-block:: bash
73+
74+
python3 -m venv venv3
75+
76+
* Activate the virtual environment:
77+
78+
.. code-block:: bash
79+
80+
source venv3/bin/activate
81+
82+
* Install the development dependencies:
83+
84+
.. code-block:: bash
85+
86+
pip3 install -e .[dev]
87+
88+
* Run `precommit.py` to execute pre-commit checks locally.

0 commit comments

Comments
 (0)