Skip to content

Commit

Permalink
Merge pull request #5 from ekhvalov/feat/week05
Browse files Browse the repository at this point in the history
Feat/week05
  • Loading branch information
ekhvalov committed Dec 16, 2023
2 parents a1d9543 + fd20c61 commit 3176310
Show file tree
Hide file tree
Showing 104 changed files with 9,672 additions and 348 deletions.
41 changes: 38 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ tasks:
cmds:
- task: deps:reset
vars:
SERVICE: postgres
SERVICES: postgres

deps:reset-kafka:
cmds:
- task: deps:reset
vars:
SERVICES: kafka zookeeper

deps:reset:
cmds:
- "{{.DOCKER_COMPOSE_CMD}} rm -fsv {{.SERVICE}}"
- "{{.DOCKER_COMPOSE_CMD}} up -d {{.SERVICE}}"
- for: { var: SERVICES }
cmd: "{{.DOCKER_COMPOSE_CMD}} rm -fsv {{.ITEM}}"
- for: { var: SERVICES }
cmd: "{{.DOCKER_COMPOSE_CMD}} up -d {{.ITEM}}"

deps:sentry-key:
dir: ./deploy/local # TODO: duplication
Expand Down Expand Up @@ -123,6 +131,7 @@ tasks:
vars:
TYPES: |-
ChatID
EventID
FailedJobID
JobID
MessageID
Expand All @@ -149,6 +158,8 @@ tasks:
task: gen:api-v1-e2e
vars:
TYPE: "{{.ITEM}}"
- task: gen:api-events
- task: gen:api-events-e2e

gen:api-v1:
internal: true
Expand All @@ -168,11 +179,35 @@ tasks:
DST: "{{.DIR}}/{{.TYPE}}.gen.go"
SRC: "./api/{{.TYPE}}.v1.swagger.yml"
PKG: "api{{.TYPE}}v1"

cmds:
- echo "[E2E] Generate {{.TYPE}} API..."
- "mkdir -p {{.DIR}}"
- "{{.TOOLS_DIR}}/oapi-codegen --old-config-style -generate types,client,spec -package {{.PKG}} {{.SRC}} > {{.DST}}"

gen:api-events:
internal: true
vars:
SRC: ./api/client.events.swagger.yml
DST_DIR: ./internal/server-client/events
DST: "{{.DST_DIR}}/events.gen.go"
PKG: clientevents
cmds:
- "mkdir -p {{.DST_DIR}}"
- "{{.TOOLS_DIR}}/oapi-codegen --old-config-style -generate skip-prune,types,spec -package {{.PKG}} -o {{.DST}} {{.SRC}}"

gen:api-events-e2e:
internal: true
vars:
SRC: ./api/client.events.swagger.yml
DST_DIR: ./tests/e2e/api/client/events
DST: "{{.DST_DIR}}/events.gen.go"
PKG: apiclientevents
cmds:
- echo "[E2E] Generate client events..."
- "mkdir -p {{.DST_DIR}}"
- "{{.TOOLS_DIR}}/oapi-codegen --old-config-style -generate skip-prune,types -package {{.PKG}} {{.SRC}} > {{.DST}}"

ent:new:
cmds:
- "{{.TOOLS_DIR}}/ent new --target {{.ENT_SCHEMA}} {{.CLI_ARGS}}"
Expand Down
114 changes: 114 additions & 0 deletions api/client.events.swagger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
openapi: 3.1.0
info:
title: Bank Support Chat Client Events
version: v1

servers:
- url: ws://localhost:8080/ws
description: Development server

paths:
/stub:
get:
description: It uses for generating events. Otherwise it doesn't.
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Event'

components:
schemas:
Event:
oneOf:
- $ref: "#/components/schemas/NewMessageEvent"
- $ref: "#/components/schemas/MessageSentEvent"
- $ref: "#/components/schemas/MessageBlockedEvent"
discriminator:
propertyName: eventType

NewMessageEvent:
required: [ eventId, messageId, requestId, eventType, body, createdAt, isService ]
properties:
eventId:
$ref: "#/components/schemas/EventID"
messageId:
$ref: "#/components/schemas/MessageID"
requestId:
$ref: "#/components/schemas/RequestID"
eventType:
$ref: "#/components/schemas/EventType"
authorId:
$ref: "#/components/schemas/AuthorID"
body:
type: string
createdAt:
type: string
format: date-time
isService:
type: boolean

MessageSentEvent:
required: [ eventId, messageId, requestId, eventType ]
properties:
eventId:
$ref: "#/components/schemas/EventID"
messageId:
$ref: "#/components/schemas/MessageID"
requestId:
$ref: "#/components/schemas/RequestID"
eventType:
$ref: "#/components/schemas/EventType"

MessageBlockedEvent:
required: [ eventId, messageId, requestId, eventType ]
properties:
eventId:
$ref: "#/components/schemas/EventID"
messageId:
$ref: "#/components/schemas/MessageID"
requestId:
$ref: "#/components/schemas/RequestID"
eventType:
$ref: "#/components/schemas/EventType"

EventType:
type: string
enum:
- NewMessageEvent
- MessageSentEvent
- MessageBlockedEvent

EventID:
type: string
format: uuid
x-go-type: types.EventID
x-go-name: ID
x-go-type-import:
path: "github.com/ekhvalov/bank-chat-service/internal/types"

AuthorID:
type: string
format: uuid
x-go-type: types.UserID
x-go-name: AuthorID
x-go-type-import:
path: "github.com/ekhvalov/bank-chat-service/internal/types"

RequestID:
type: string
format: uuid
x-go-type: types.RequestID
x-go-name: RequestID
x-go-type-import:
path: "github.com/ekhvalov/bank-chat-service/internal/types"

MessageID:
type: string
format: uuid
x-go-type: types.MessageID
x-go-name: MessageID
x-go-type-import:
path: "github.com/ekhvalov/bank-chat-service/internal/types"
Loading

0 comments on commit 3176310

Please sign in to comment.