fullcycle_clean_architecture

command module
v0.0.0-...-663e15f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

CI and Test

Desafio Clean Architecture

Olá devs! Agora é a hora de botar a mão na massa. Para este desafio, você precisará criar o usecase de listagem das orders. Esta listagem precisa ser feita com:

  • Endpoint REST (GET /order)
  • Service ListOrders com GRPC
  • Query ListOrders GraphQL Não esqueça de criar as migrações necessárias e o arquivo api.http com a request para criar e listar as orders.

Para a criação do banco de dados, utilize o Docker (Dockerfile / docker-compose.yaml), com isso ao rodar o comando docker compose up tudo deverá subir, preparando o banco de dados. Inclua um README.md com os passos a serem executados no desafio e a porta em que a aplicação deverá responder em cada serviço.

Requisitos

Arquitetura do projeto

img.png

github.com/dyammarcano/fullcycle_clean_architecture
├───cmd
├───internal
│   ├───adapter
│   │   ├───grpc
│   │   └───http
│   ├───domain
│   ├───repository
│   │   └───migrations
│   └───usecase
└───pkg
│   ├───config
│   ├───grpc
│   │   ├───pb
│   │   └───proto
│   ├───logger
│   └───util
├── main.go
├── Dockerfile
├── docker-compose.yaml
└── README.md

Executando o projeto

NOTA:

Certifique-se de que você tenha o Docker instalado na sua máquina y que o serviço do Docker esteja em execução.

Alen disso, é preciso ter instalada alguma ferramenta para interagir com gRPC, poder ser:

  1. Clone o repositório
$ git clone github.com/dyammarcano/fullcycle_clean_architecture.git
  1. Acesse a pasta do projeto
$ cd fullcycle_clean_architecture
  1. Executar o projeto
# Comando para gerar as images e subir os containers com o banco de dados
$  docker-compose up --build
  1. Acesse o endereço http://localhost:8080/graphql para acessar a ‘interface’ do GraphQL Playground

img_1.png

  1. Acesse o endereço http://localhost:8080/order para acessar a ‘interface’ http

img_2.png

  1. Acesse o endereço 127.0.0.1:8081 para acessar a ‘interface’ do gRPC

img_3.png img_4.png

Endpoints

  • GraphQL Playground: http://localhost:8080/graphql
  • gRPC: http://localhost:8081/
  • REST: http://localhost:8080/order

GraphQL Query

query ListOrders {
  listOrders {
    amount
    id
    item
  }
}

gRPC Client

Para testar o gRPC, você pode usar o evans

$ evans -r -p 8081 repl
127.0.0.1:8081> show package
+-------------------------+
|         PACKAGE         |
+-------------------------+
| fullcycle               |
| grpc.reflection.v1      |
| grpc.reflection.v1alpha |
+-------------------------+
127.0.0.1:8081> package fullcycle
fullcycle@127.0.0.1:8081> show service
+--------------+------------+-------------------+--------------------+
|   SERVICE    |    RPC     |   REQUEST TYPE    |   RESPONSE TYPE    |
+--------------+------------+-------------------+--------------------+
| OrderService | ListOrders | ListOrdersRequest | ListOrdersResponse |
+--------------+------------+-------------------+--------------------+
fullcycle@127.0.0.1:8081> show message
+--------------------+
|      MESSAGE       |
+--------------------+
| ListOrdersRequest  |
| ListOrdersResponse |
+--------------------+
fullcycle@127.0.0.1:8081> desc ListOrdersRequest
+-------+------+----------+
| FIELD | TYPE | REPEATED |
+-------+------+----------+
+-------+------+----------+
fullcycle@127.0.0.1:8081> desc ListOrdersResponse
+--------+----------------------+----------+
| FIELD  |         TYPE         | REPEATED |
+--------+----------------------+----------+
| orders | TYPE_MESSAGE (Order) | true     |
+--------+----------------------+----------+
fullcycle@127.0.0.1:8081> service OrderService
fullcycle.OrderService@127.0.0.1:8081> call ListOrders {}
{
  "orders": [
    {
      "amount": 50,
      "id": 1,
      "item": "Nike Dunk Low"
    },
  ...
  ]
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL