. . .

Brewer


Introduction

Brewer service provides multiple endpoints to generate Spring Boot microservice projects. It uses the meta data information from YAMBAS and is build on top of the Swagger service generator. Brewer also provides the possibility to generate an Open API specification of a service and deploy a service or it's library to a repository (the Innkeeper service).


Port

8180

Context path

/brewer

Host

http://localhost:8180/brewer

Component interactions

images/download/attachments/95834844/Grafiken-Service-Doc_Brewer.png

The above diagram represents interactions between actors and components where Brewer is involved within the ApiOmat cloud. In this diagram you can see the developer as an actor, the three services Brewer, Innkeeper and YAMBAS as components and the discovery service Consul. Each service interacts with the Consul discovery to register itself and retrieves information to communicate with each other. Brewer uses Consul to register himself and retrieve information to communicate with Innkeeper and YAMBAS.

At the upper level you have the developer interaction to Brewer. A developer can request Brewer for a specific service to generate a Spring Boot microservice project, get its Swagger OpenAPI specification or also deploy the service artifact as Spring Boot project or as lightweight library.

Brewer is interacting with YAMBAS to retrieve the meta data information of a service, its class, attributes and its dependencies to other services.

Lastly Brewer is interacting with Innkeeper, the repository service, in case that a developer wants to deploy a generated service artifact directly, or when the developer wants to generate a service with the merging feature that retrieves and merges existing artifacts from Innkeeper.

Installation

Please refer to the [Brewer] Installation.

Usage

Generate a Spring Boot service project

Default port of the Brewer service is 8180. As the Brewer service requests YAMBAS, make sure your YAMBAS instance is registered to Consul and healthy before using generation endpoints.

To generate a Spring Boot project for a service "MyService" in version "1.0.0", using Brewer started on localhost with the default port 8180, do the following request (replace username & password with your YAMBAS authentication information, local_dir_path with the local directory in which you want to generate the zip and zip_name with the name you want for the generated zip) :

curl http://<brewerHostAndPort>/brewer/ms/MyService/v/1.0.0 -u "<CUSTOMER_NAME>:<CUSTOMER_PASSWORD>" > <local_dir_path>/<zip_name>.zip

Generate with deployment to Innkeeper (Repository service)

As for now the only repository option to automatically deploy generated services binary and sources is ApiOmat hosting service Innkeeper.

Brewer has specific configuration options to communicate with Innkeeper, please make sure that the Innkeeper service matches the correct configuration before trying to deploy:

Configuration key

Value

Description

apiomat.service.discovery.uses.Innkeeper.version

1.0.0

Version or version range of the service as registered in Consul, for version filtering.

apiomat.service.discovery.uses.Innkeeper.name

Innkeeper

Name of the service as registered in Consul, this should be set to "Innkeeper".

brewer.repositoryservice.pathprefix

/hosting

Context path of Innkeeper, for service to service communication usage.

brewer.repositoryservice.name

Innkeeper

Name of the service as registered in Consul, for service to service communication usage.

Spring Boot project

A specific endpoint is available to automatically deploy the generated service to Innkeeper. To generate and deploy a Spring Boot project for a service "MyService" in version "1.0.0", using Brewer started on localhost with default port 8180, make the following request (replace username & password with your YAMBAS authentication information, local_dir_path with the local directory in which you want to generate the zip and zip_name with the name you want for the generated zip) :

curl -X PUT http://<brewerHostAndPort>/brewer/ms/MyService/v/1.0.0/deployToHost -u "<CUSTOMER_NAME>:<CUSTOMER_PASSWORD>"

Library for external dependency purpose

A specific endpoint is available to automatically deploy the generated service as a light weight library to Innkeeper, to be used as dependency in other services. To generate and deploy a Spring Boot project for a service "MyService" in version "1.0.0", using Brewer started on localhost with default port 8180, make the following request (replace username & password with your YAMBAS authentication information, local_dir_path with the local directory in which you want to generate the zip and zip_name with the name you want for the generated zip) :

curl -X PUT http://<brewerHostAndPort>/brewer/MyService/v/1.0.0/lib/deployToHost-u "<CUSTOMER_NAME>:<CUSTOMER_PASSWORD>"

Merging feature

When generating a Spring Boot project, it is possible to enable or disable merging of generated and existing sources by setting a "merge" attribute to the request (defaults to true, accepted values are true or false). For the merge, Brewer will try to retrieve the existing sources from Innkeeper and create a project containing both, the generated mandatory classes as well as the classes from the existing artifact. Example for the generation of a Spring Boot project with the merging option set to false :

curl -X PUT http://<brewerHostAndPort>/brewer/ms/MyService/v/1.0.0/deployToHost?merge=false -u "<CUSTOMER_NAME>:<CUSTOMER_PASSWORD>"

Generate open-api specification

Brewer provides the possibility to generate and retrieve the Open API specification of a service. You can generate it and put the content in a file by simply calling the following endpoint :

curl http://<brewerHostAndPort>/brewer/{serviceName}/v/{serviceVersion}/swagger.json -u "<CUSTOMER_NAME>:<CUSTOMER_PASSWORD>" > <local_dir_path>/<open_api_filename>