From 5086c79fbe6f91c91688e8e881cc1d01ada221f0 Mon Sep 17 00:00:00 2001 From: C1325543 Matheus Romano Braga Date: Mon, 13 Jun 2022 16:20:05 -0300 Subject: [PATCH 1/5] feat: update documenttion --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++-- controllers/home.go | 2 +- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 12f1084..07a1e17 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# featws-ruller +[![Go Reference](https://pkg.go.dev/badge/github.com/abu-lang/goabu.svg)](https://pkg.go.dev/github.com/bancodobrasil/featws-ruller) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/bancodobrasil/featws-ruller/blob/develop/LICENSE) +# Featws Ruller +- The featws-ruller project is an implmentation of the [grule-rule-engine](https://github.com/hyperjumptech/grule-rule-engine), used to evalute rulesheets(.grl) ## Required Software - You must have the **Go Programming Language** installed in your machine to run this project. You can get the official download [here](https://go.dev/doc/install). @@ -7,7 +10,68 @@ ## Initializate the project - Clone this project to your local machine. -- On _main.go_ folder (*../featws-ruller/main.go*), open your local terminal and type the command `go run main.go`. +- On _main.go_ folder (*../featws-ruller/main.go*), open your local terminal and type the command `go run main.go` or by build and run the executable `go build && ./featws-ruler.exe`. + +## Testing diferents rulesheets +- Check if you have in your workspace the **featws-transpiler** and copy the path from .grl file for the new case, you can find that on the cases _tests_ -> cases +- Now just replace the env variable "FEATWS_RULLER_DEFAULT_RULES" on .env file on ruller, with the new path, and run like the instructions above. + +## Testing rulesheet with resolvers +- To test if the resolver are loaded, you have to set the **featws-resolver-bridge** URL, on the .env file to. + +## Load a rulesheet from remote source +- To load a rulesheet from a remote soure, just change the .env variable "FEATWS_RULLER_RESOURCE_LOADER_URL" pointed to your URL. + + +# Using main endpoints +_By default the port will be :8000_ +- GET **http://localhost:YOURSETTEDPORT/** + - Will return simple message to client such as: "FeatWS Ruller Works!!!" + +- POST **http://localhost:YOURSEETEDPORT/api/v1/eval** + - On this end point you must have to pass a body, witch is the parameters setted by rulesheet folder on the featws-transpiler. Using case 0001 for example the body should be: + ```json + { + "mynumber": "45" + } + ``` + - Sending the request, response should be something like that: (this response difined by .featws file on ruleshet folder, in that case is false because the condition is mynumber > 12) + ```json + { + "myboolfeat": false + } + ``` +- GET **http://localhost:YOURSEETEDPORT/swagger/index.html** + - On your browser, you can see the swagger documentation of the api. + +- GET **http://localhost:YOURSEETEDPORT/health/live?full=1** + - This endpoint will check the live status of the application, just like that: + ```json + { + "goroutine-threshold": "OK" + } + ``` + +- GET **http://localhost:YOURSEETEDPORT/health/ready?full=1** + - This endpoint will check the ready status of the services used by ruller project + ```json + { + "goroutine-threshold": "OK", + "resolver-bridge": "OK", + "resource-loader": "OK" + } + ``` + + + + + + + + + + + diff --git a/controllers/home.go b/controllers/home.go index f13adf5..0672911 100644 --- a/controllers/home.go +++ b/controllers/home.go @@ -9,7 +9,7 @@ import ( //HomeHandler ... func HomeHandler() gin.HandlerFunc { return func(c *gin.Context) { - c.String(http.StatusOK, "FeatWS Works!!!") + c.String(http.StatusOK, "FeatWS Ruller Works!!!") } } From a6e35378288921afea7f58f76ec72bb65d8dc201 Mon Sep 17 00:00:00 2001 From: EduardaCastro Date: Tue, 14 Jun 2022 11:34:38 -0300 Subject: [PATCH 2/5] feat: update documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07a1e17..e055b8b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Initializate the project - Clone this project to your local machine. -- On _main.go_ folder (*../featws-ruller/main.go*), open your local terminal and type the command `go run main.go` or by build and run the executable `go build && ./featws-ruler.exe`. +- On _main.go_ folder (*../featws-ruller/main.go*), open your local terminal and type the command `go run main.go`, if your OS is windows, you can by build and run the executable `go build && ./featws-ruler.exe`, or if your OS is mac, type the command `go build -o ruller && ./ruller $@`. ## Testing diferents rulesheets - Check if you have in your workspace the **featws-transpiler** and copy the path from .grl file for the new case, you can find that on the cases _tests_ -> cases From 5d7a61091dadcdb925fb55659464e71acc59eec5 Mon Sep 17 00:00:00 2001 From: EduardaCastro Date: Sun, 19 Jun 2022 20:57:42 -0300 Subject: [PATCH 3/5] feat: translate documentation to portuguese --- README-PTBR.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 README-PTBR.md diff --git a/README-PTBR.md b/README-PTBR.md new file mode 100644 index 0000000..d1f9668 --- /dev/null +++ b/README-PTBR.md @@ -0,0 +1,58 @@ +[![Go Reference](https://pkg.go.dev/badge/github.com/abu-lang/goabu.svg)](https://pkg.go.dev/github.com/bancodobrasil/featws-ruller) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/bancodobrasil/featws-ruller/blob/develop/LICENSE) + +# Featws Ruller +- O projeto featws-ruller é uma implementação do [grule-rule-engine](https://github.com/hyperjumptech/grule-rule-engine), usado para aveliar planilhas de regaras (.grl). + +## Software Necessário +- Será necessário ter instalado em sua máquina a **Linguagem de Programação Go** para rodar o projeto. Você pode fazer o download na pádina oficial [aqui](https://go.dev/doc/install). +- Clone o repositório **featws-transpiler** para a sua máquina local e tenha verifique se o projeto transpiler e ruller estão na mesma pasta.Você pode achar o repositorio do featws-transpiler [aqui](https://github.com/bancodobrasil/featws-transpiler). + +## Inicializando o Projeto +- Clone o projeto para sua máquina local. +- Com a pasta do projeto aberto (*../featws-ruller/main.go*), abra o arquivo _main.go_ e o terminal integrado, digite o comando `go run main.go`. Se voce utiliza o sistema OS ou windows, voce tambem pode dar build e executar o projeto com os comandos: `go build && ./featws-ruler.exe`, caso use windows, ou `go build -o ruller && ./ruller $@` se utiliza Mac. + +## Testando diferentes folhas de regras +- Verifique se voce possui em seu workspace o **featws-transpiler** e copie o caminho do arquivo .grl para o novo caso a ser testado. Você pode encontrar isso nos casos _tests_ -> cases. +- Agora basta substituir a variável env "FEATWS_RULLER_DEFAULT_RULES" no arquivo .env na regra, pelo novo caminho, e executar conforme as instruções acima. + +## Folha de regras de teste com resolvers +- Para testar se o resolver está carregado, você deve definir a URL **featws-resolver-bridge** no arquivo .env. + +## Carregando uma folha de regras de uma fonte remota +- Para carregar uma planilha de uma fonte remota, basta alterar a variável .env "FEATWS_RULLER_RESOURCE_LOADER_URL" apontada para sua URL. + +# Usando principais endpoints +_Por padrão a porta utilizada será a :8000_ +- GET **http://localhost:SUAPORTAESCOLHIDA/** + - Retornará uma mensagem simples ao cliente, como: "FeatWS Ruller Works!!!" + +- POST **http://localhost:SUAPORTAESCOLHIDA/api/v1/eval** + - Neste ponto final você deve ter que passar um corpo, que são os parâmetros definidos pela pasta rulesheet no featws-transpiler. Usando o case 0001, por exemplo, o corpo deve ser: + ```json + { + "mynumber": "45" + } + ``` + - Após a solicitação ter sido enviada, a resposta deve ser algo assim: (essa resposta é definida pelo arquivo .featws na pasta ruleshet, nesse caso é false porque a condição é meunúmero> 12) + ```json + { + "myboolfeat": false + } + ``` +- GET **http://localhost:SUAPORTAESCOLHIDA/swagger/index.html** + - No seu navegador, você pode ver a documentação do swagger da api. + +- GET **http://localhost:SUAPORTAESCOLHIDA/health/live?full=1** + - Este endpoint verificará o status ativo do aplicação: + +- GET **http://localhost:SUAPORTAESCOLHIDA/health/ready?full=1** + - Este endpoint verificará o status se o serviços está pronto para ser usado ​​pelo projeto da ruller. + + ```json + { + "goroutine-threshold": "OK", + "resolver-bridge": "OK", + "resource-loader": "OK" + } + ``` \ No newline at end of file From 8b6d95a6eb00f8c20cd38a51b5371c1908def49e Mon Sep 17 00:00:00 2001 From: C1325543 Matheus Romano Braga Date: Wed, 15 Jun 2022 11:35:33 -0300 Subject: [PATCH 4/5] fix: unit test on controller --- controllers/home_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/home_test.go b/controllers/home_test.go index 4ac4956..ed1515c 100644 --- a/controllers/home_test.go +++ b/controllers/home_test.go @@ -35,7 +35,7 @@ func TestHomeHandler(t *testing.T) { } gotBody := r.Body.String() - expectedBody := "FeatWS Works!!!" + expectedBody := "FeatWS Ruller Works!!!" if gotBody != expectedBody { t.Error("got error on request homeHandler func") From f914f854a13b34261dcd3d86b133a70d1e1226a1 Mon Sep 17 00:00:00 2001 From: EduardaCastro Date: Sun, 19 Jun 2022 21:05:21 -0300 Subject: [PATCH 5/5] feat: translate documentation to portuguese