Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added filas-aula-2/Evidences/CouldNotProcess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filas-aula-2/Evidences/InvalidCoupon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filas-aula-2/Evidences/Processed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filas-aula-2/Evidences/Resultado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions filas-aula-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Desafio 02

Foram criadas as filas e exchanges para o RabbitMQ, sendo que, após os testes foram obtidos os seguintes resultados:

### Execução completa do lote:
![](Evidences/Resultado.png)

### Cenário de sucesso (Processed):

![](Evidences/Processed.png)

### Cenário de falha (Cupom inválido):

![](Evidences/InvalidCoupon.png)

### Cenário de falha (Connection error - could not process):

![](Evidences/CouldNotProcess.png)
13 changes: 13 additions & 0 deletions filas-aula-2/a/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.15

WORKDIR /go/src/fullcycle

COPY templates .

# Install go dependencies
RUN go get github.com/joho/godotenv && \
go get github.com/wesleywillians/go-rabbitmq/queue

RUN GOOS=linux go build

ENTRYPOINT [ "./fullcycle" ]
9 changes: 9 additions & 0 deletions filas-aula-2/b/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.15.3

WORKDIR /go/src/fullcycle

COPY . .

RUN GOOS=linux go build b.go

ENTRYPOINT [ "./b" ]
11 changes: 6 additions & 5 deletions filas-aula-2/b/b.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package main

import (
"encoding/json"
"github.com/joho/godotenv"
uuid "github.com/satori/go.uuid"
"github.com/streadway/amqp"
"github.com/wesleywillians/go-rabbitmq/queue"
"io/ioutil"
"log"
"net/http"
"net/url"
"github.com/joho/godotenv"
uuid "github.com/google/uuid"
"github.com/streadway/amqp"
"github.com/wesleywillians/go-rabbitmq/queue"
)

type Result struct {
Expand All @@ -23,7 +23,8 @@ type Order struct {
}

func NewOrder() Order {
return Order{ID: uuid.NewV4()}
id := uuid.New();
return Order{ID: id}
}

const (
Expand Down
11 changes: 11 additions & 0 deletions filas-aula-2/b/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/codeedu/avancadev-micrservice-1dia

go 1.15

require (
github.com/joho/godotenv v1.3.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/satori/go.uuid v1.2.0
github.com/wesleywillians/go-rabbitmq v0.0.0-20201027193450-55e6a80937af
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
)
9 changes: 9 additions & 0 deletions filas-aula-2/c/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.15

WORKDIR /go/src/fullcycle

COPY . .

RUN GOOS=linux go build

ENTRYPOINT [ "./fullcycle" ]
2 changes: 1 addition & 1 deletion filas-aula-2/c/c.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ func home(w http.ResponseWriter, r *http.Request) {

fmt.Fprintf(w, string(jsonResult))

}
}
31 changes: 30 additions & 1 deletion filas-aula-2/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
version: '3'

volumes:
rabbitdata:
driver: local

services:

rabbit:
image: "rabbitmq:3-management"
hostname: 'rabbithost'
environment:
RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG"
RABBITMQ_DEFAULT_USER: "rabbitmq"
RABBITMQ_DEFAULT_PASS: "rabbitmq"
RABBITMQ_DEFAULT_VHOST: "/"
ports:
- "15672:15672"
- "5672:5672"
- "5672:5672"
volumes:
- rabbitdata:/var/lib/rabbitmq
restart: on-failure

microservice-a:
build: ./a
ports:
- 9090:9090
depends_on:
- rabbit
restart: on-failure

microservice-b:
build:
context: ./b
depends_on:
- rabbit
restart: on-failure

microservice-c:
build: ./c
ports:
- 9092:9092
restart: on-failure
64 changes: 0 additions & 64 deletions microsservicos-aula-1/a/a.go

This file was deleted.

98 changes: 0 additions & 98 deletions microsservicos-aula-1/a/templates/home.html

This file was deleted.

70 changes: 0 additions & 70 deletions microsservicos-aula-1/b/b.go

This file was deleted.

Loading