# Developing Microservice-Based Applications Using the Silvera Domain-Specific Language
## 3 Silvera
### Silvera Abstract Syntax  
In this section, we present the abstract syntax of the Silvera language. Silvera's abstract syntax is specified in the form of a metamodel. The simplified version of the metamodel, for brevity, is presented in Figures 1 and 2. The main concept of the Silvera metamodel is the _Model_, which consists of one or more modules (_Module_). A module enables users to logically organize their Silvera code. Each module can consist of declarations of microservices (_ServiceDecl_), API gateways (_APIGateway_), service registries (_ServiceRegistryDecl_), configuration servers (_ConfigServerDecl_), dependencies (_Dependency_), message pool (_MessagePool_), or message brokers (_MessageBroker_). Each declaration can be identified by its name which is unique at the module level. The unique identifier for a declaration within the model is its fully qualified name (FQN), which is calculated by the following formula:  
\[<module\_path>.<module\_name>.<declaration\_name> \tag{1}\]  
A module can reference declarations from another module by importing it. For each microservice, it is possible to define its name, API, deployment strategy, communication style, whether the microservice should be registered within a service registry, and whether it should draw external configuration data from a configuration server. \begin{table}
\begin{tabular}{p{142.3 pt} p{142.3 pt}} \hline \hline
**Pattern Name** & **Description** \\ \hline \multirow{2}{*}{_Interpreter_} & DSL constructs are recognized and interpreted using a standard fetch-decode-execute cycle. This approach is appropriate for languages having a dynamic character or if execution speed is not an issue [48]. \\ \hline \multirow{2}{*}{_Compiler/application generator_} & DSL constructs are translated to base language constructs and library cells. A complete static analysis can be performed on the DSL program/specification [48]. \\ \hline \multirow{2}{*}{_Embedding_} & DSL constructs are embedded in an existing GPL (the host language) by defining new abstract data types and operators [48]. \\ \hline \multirow{2}{*}{_Extensible compiler/ interpreter_} & A GPL compiler/interpreter is extended with domain-specific optimization rules and/or domain-specific code generation. While interpreters are usually relatively easy to extend, extending compilers is hard unless they were designed with extension in mind [48]. \\ \hline \multirow{2}{*}{_Commercial-Off-The-Shelf (COTS)_} & Existing tools and/or notations are applied to a specific domain [48]. \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Implementation phase patterns considered during the implementation phase. Figure 1: The simplified version of the Silvera metamodel (part 1). Figure 2: The simplified version of the Silvera metamodel (part 2). The API (_APIDDecl_) declaration consists of function definitions and the definition of service-specific objects used for modeling microservice business entities. Each function definition consists of a function name, function parameters, return type, and annotation (optional), whereas the definition of the service-specific object (_TypeDef_) is given by its name and one or more fields (_TypeField_). Every field has its name and a data type, but can also have a special ID attribute, which is used to identify fields during serialization and deserialization of messages in a binary format and to ensure backward compatibility for newer versions of the API. For that reason, once assigned, an ID attribute should not be changed. In Silvera, each microservice has a particular communication style. Communication style defines a protocol used to send and receive messages. Currently, it is possible to choose between _RPC-based_ and _messaging-based_ communication styles. The format of messages that can be sent and received from a microservice is defined by its API. Microservices that use RPC to call methods from other microservices must define those microservices as dependencies.