# Developing Microservice-Based Applications Using the Silvera Domain-Specific Language
## 3 Silvera
### Silvera Concrete Syntax
#### 3.3.2 Service Registry Declaration
The _config_ module contains classes used to define how the generated microservice application will communicate with a message broker. These classes are: (i) the _KafkaConfig_ class that defines how the application is registered within the Kafka cluster, and (ii) the _MessageDeserializer_ class that defines how messages received as JSON objects will be transformed into message objects defined in the _messages_ module. _MessageDeserializer_ is optional and will be generated only if the application consumes messages from the message broker. The _controller_ module contains a class that specifies the REST API of the generated microservice application. The class contains methods that belong to both the public and internal API of the microservice. Methods from the internal API are private and cannot be accessed from the outside. In addition to the modules mentioned above, _pom.xml_ and _bootstrap.properties_ files are generated for each microservice. The file _bootstrap.properties_ is used to setup Spring Boot applications, whereas Maven uses _pom.xml_ files to manage dependencies. API gateways and service registries are also generated as separate Spring Boot applications. The API gateway is generated as a _Zuul Proxy_ (Netlix Zuul--[[https://github.com/Netflix/zuul](https://github.com/Netflix/zuul)]([https://github.com/Netflix/zuul](https://github.com/Netflix/zuul)) (accessed on 24 December 2021)) server. _Zuul_ is a gateway service developed by Netflix, and it provides dynamic routing, monitoring, resiliency, security, etc. Generated code for the API gateway is simple because it contains only one class with the main function and the _application.properties_ file, which defines how the API gateway will perform request routing and whether it will contact the service registry to retrieve the URL of the corresponding microservice. The service registry is also a simple application, with one class with the main function and the _bootstrap.properties_ file. The built-in code generator produces a special run script and a _Docker_ file (if the deployment host is set to the container) for each microservice, API gateway, or service registry. The run script utilizes _Maven_ to produce and run the jar file. #### 3.4.3 Customization Support

Silvera allows users to register new AEP or code generators as plugins. Both are registered in the same way, so for brevity, we will only describe the registration process for the new code generator. A custom code generator needs to be implemented in Python. Silvera uses the pkg _resources module from setuptools (Python's _setuptools_ module--[[https://setuptools.readthedocs.io/en/latest/](https://setuptools.readthedocs.io/en/latest/)]([https://setuptools.readthedocs.io/en/latest/](https://setuptools.readthedocs.io/en/latest/)) (accessed on 24 December 2021)) and its concept of extension point to declaratively specify the registration of the new code generator. Extensions are defined within the project's setup.py module. All Python projects installed in the environment that declare the extension point will be discoverable dynamically. The registration of a new code generator is performed in two steps. The first step is to create an instance of the GeneratorDesc class. An instance of the GeneratorDesc class contains information about the code generator's target language, description, and the reference towards the function that should be called to perform code generation. As shown in Listing 9, this function has three parameters: Decl object, a path to the directory where code will be generated, and a flag that shows whether the code generator is run in debug mode. ```
1 fromsilvera.generator.gen_regimportGeneratorDesc
2
3 defgenerate(decl,output_dir,debug):
4\"\"\"Entrypointfunctionforcodegenerator. 5
6 Args:
7 decl(Decl):canbedeclarationofserviceregistryorconfig
8 server. 9 output_dir(str):outputdirectory. 10 debug(bool):Trueifdebugmodeactivated.Falseotherwise.