serverlessCqrsPython
Welcome to the exercises for CQRS in Python.
JSON in Python is case sensitive. By convention, I have named all class variables in python in camel case starting with an upper case letter. For example, the hotel identifier is HotelId, the reservation identifier is ReservationId. The JSON text you send to the API **must** match the case of the class variables or serialization will fail. An important caveat for Python.
Once you have checked out the code, you will need the following set up on your workstation:
-
A local installation of EventStoreDB from https://www.eventstore.com/ is required to run this project. Make sure that the event store database is installed and running. This can be verified by loading http://localhost:2113/web/index.html#/ The default username/password is admin/changeit. Commands cannot be issued to the hotel reservation system without an active event store. There are 2 methods of installing event store.
- A docker-compose.yml file has also been provided in the repositories root directory. Execute the command
docker-compose up
in the root directory if you have docker installed. - You can find installation instructions for Event Store Db at https://www.eventstore.com/.
- A docker-compose.yml file has also been provided in the repositories root directory. Execute the command
-
Python 3, I suggest python 3.7, available from https://realpython.com/installing-python/#how-to-install-python-on-linux for Linux or the windows store https://www.microsoft.com/en-ca/p/python-37/9nj46sx7x90p for Windows.
-
pip, the python package installer. Type
pip help
at a command line to see if it's already installed after installing python. pip can be installed using the instructions at https://phoenixnap.com/kb/install-pip-windows for Windows or https://pip.pypa.io/en/stable/installing/ for Linux -
An IDE, I've used both pycharm and Visual Studio Code to develop this repository.
- Azure Functions - you can run the examples as an Azure Function, but you must install the Azure functions core tools. If you choose Azure functions, you will have to run and debug using Visual Studio Code. Instructions for debugging and running Azure Functions can be found at https://docs.microsoft.com/en-us/azure/developer/python/tutorial-vs-code-serverless-python-04
- pycharm from jet brains can also be used, as the code can be run as a flask app
-
Install dependencies, if you use pycharm or Visual Studio Code, the IDE will install all required python libraries. The IDE will not install Azure functions core tools, you must do this step yourself.
-
You can install the dependencies from the command line. In the exercises serverlessCqrsPython directory, using the provided
requirements.txt
file and pip by entering the commandpip install -r requirements.txt
Running the code through the IDE is the easiest way to get started. pycharm should modify all path's so that the libraries developed for this module are found. The Azure functions module appends to the system path to ensure that all python classes can be found. If you're a purist and want to run everything from the command line, you will have to modify your PYTHONPATH environment variable to include the root directory of the excercise you are currently working on.