Towards implementation of a rich type system for microservices-based systems
Larisa Safina Innopolis University, 2015
1
Agenda 1. 2. 3. 4. 5.
Project area: Microservices Project area: Jolie programming language Problem statement Adding the choice data type Conclusions and future work
2
Project area: Microservices • • • • • •
Componentization via Services Organized around Business Capabilities Decentralized Data Management Culture of automation Design for failure Evolutionary Design
Type system Native types and subtypes Linked types Undefined types
type car_request: void { .name: string .id: {?} } type customer: void { .name: string .age?: int .cars*: car_request }
9
Interpreter architecture
Fabrizio Montesi. Jolie: a Service-oriented Programming Language. Master’s thesis
10
Jolie Interpreting Algorithm 1. 2. 3. 4.
Command line arguments are read, and the components needed for parsing are started; The source code in input is parsed and an Abstract Syntax Tree (AST) is produced; Well-formedness, semantic checks and optimizations are performed on the AST; The AST is used in order to generate the OOIT and initialize the Communication Core and Runtime Environment components; 5. The Runtime Environment calls the run method of the root node in the OOIT (which corresponds to the main procedure).
11
Problem statement Lack of useful data types in Jolie • Choice types • Regular expressions • etc...
12
Adding new data type. Type choice • Choice type in XML Choice type in Jolie type animal: cat | dog
13
Adding new data type. New programming examples • Working with existent types type numeric: int | double | void Linked types: type linked_type: string type linked_choice: linked_type | raw Subtypes: person_info: void { .id: string | int }
14
Adding new data type. Changes in interpreter Adding choice type to AST
15
Adding new data type. Changes in interpreter • Extending parser: – Scanner – OLParser – OLParserTreeOptimizer – Semantic verifier Extending runtime facilities Additions to building object-oriented interpretation tree process Addition to message types
16
Adding new data type. New programming examples Making functions generic type choice: string | int fun_choice(choice)(choice) fun_choice(request)(response){ response = request }
17
Adding new data type. New programming examples Program behaviour differs based on the type of arguments passed type person: personSSN | personCCN type personSSN:void {.ssn:int} type personCCN:void {.ccn:string} pay(person)(response) { if ( is_defined( person.ssn ) ) { // ask the person registry.. } else { // contact the bank.. } }
18
Adding new data type. Yet Another Example type Old-Software-Corp: void {. name: string address: string } type New-Software-Corp: void {. name: void { .firstname: string .lastname: string address: string phone: int } type corporation: Old-Software-Corp | New-Software-Corp
19
Conclusions and future work Conclusions • Adding choice operator provide more flexibility Future work Fixing Jolie tools regarding new types system Adding regular expressions
20
References 1. Martin Fowler and James Lewis, “Microservices” http://martinfowler.com/articles/microservices.html 1. Jolie programming language documentation http://www.jolie-lang.org/documentation 1. Fabrizio Montesi. Jolie: a Service-oriented Programming Language. 2. XML Schema choice element http://www.w3schools.com/schema/el_choice.asp
21
Thank you! Questions?
22
Backlog
23
Jolie BNF Program ::= Deployment Behaviour Deployment ::= DeploymentInstruction∗ Behaviour ::= BehaviouralBlock∗ main { Process } BehaviouralBlock∗ BehaviouralBlock ::= define id { Process } | init { Process } Process ::= . . . | InputStatement | OutputStatement InputStatement ::= op(x) (One-Way) | op(x)(y) { Process } (Request-Response) OutputStatement ::= op@OPort(x) (Notification) | op@OPort(x)(y) (Solicit-Response)
24
Jolie Type System DeploymentInstruction ::= . . . | type id : TypeDefinition TypeDefinition ::= . . . | NativeType | NativeType { SubTypeList } | NativeType { ? } (Untyped subnodes ) | id (Type link) | undefined (Shortcut for any:{?}) NativeType ::= int | double | string | raw | void | any
SubTypeList ::= SubType | SubType SubTypeList SubType ::= .id Cardinality : TypeDefinition Cardinality ::= [ int , int ] (Range) | [ int , * ] (Lower-bound) |* (Shortcut for [0,*]) |? (Shortcut for25 [0,1])
Jolie Parser
26
Jolie Type Definition TypeDefinition (jolie.lang.parse.ast.types): • TypeInlineDefinition for expressing native types; • TypeDefinitionLink for linked types; • TypeDefinitionUndefined for undefined types.
27
Jolie Parse Process 1. Scanner reads input and create token objects based on the ones defined in enum. 2. OLParser takes created tokens, checks them by the grammar rules and generate corresponding syntax node (jolie.lang.parse.ast.OLSyntaxNode) in abstract syntax tree (AST). 3. OLParseTreeOptimizer (jolie.lang.parse.OLParseTreeOptimizer) takes ready AST and optimize it by reducing the number of nodes or transforming the code to more efficient versions. 4. SemanticVerifier (jolie.lang.parse.SemanticVerifier) checks if the code well-formed and semantically correct.
Loading⦠Page 1. Whoops! There was a problem loading more pages. Retrying... Akses Larisa Safina.pdf. Akses Larisa Safina.pdf. Open. Extract. Open with.
safe systems! (how?) Victor Rivera The Event-B Method. Page 3 of 15. AKSES Victor Rivera.pdf. AKSES Victor Rivera.pdf. Open. Extract. Open with. Sign In.