Compare commits
No commits in common. "7937d182db6d8d19daf4466b39c76b6003e23766" and "3298602a23bd9c343664d8d4a18cb8b9780fef64" have entirely different histories.
7937d182db
...
3298602a23
20 changed files with 208 additions and 828 deletions
3
api.env
3
api.env
|
|
@ -8,9 +8,6 @@ APP_ALLOWED_ORIGINS=http://localhost:5173,
|
||||||
GRPC_SERVER_PORT=9050
|
GRPC_SERVER_PORT=9050
|
||||||
GRPC_CLIENT_PORT=9060
|
GRPC_CLIENT_PORT=9060
|
||||||
|
|
||||||
IMAGE_STORAGE_HOST=
|
|
||||||
IMAGE_STORAGE_PORT=
|
|
||||||
|
|
||||||
MEDIA_STORAGE_ENDPOINT=
|
MEDIA_STORAGE_ENDPOINT=
|
||||||
MEDIA_STORAGE_USER=
|
MEDIA_STORAGE_USER=
|
||||||
MEDIA_STORAGE_PASSWORD=
|
MEDIA_STORAGE_PASSWORD=
|
||||||
|
|
|
||||||
10
cmd/main.go
10
cmd/main.go
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"merch-parser-api/internal/api/user"
|
"merch-parser-api/internal/api/user"
|
||||||
"merch-parser-api/internal/app"
|
"merch-parser-api/internal/app"
|
||||||
"merch-parser-api/internal/grpcService"
|
"merch-parser-api/internal/grpcService"
|
||||||
"merch-parser-api/internal/imagesProvider"
|
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
"merch-parser-api/internal/mediaStorage"
|
"merch-parser-api/internal/mediaStorage"
|
||||||
"merch-parser-api/internal/provider/auth"
|
"merch-parser-api/internal/provider/auth"
|
||||||
|
|
@ -63,8 +62,6 @@ func main() {
|
||||||
"provider": mediaProvider,
|
"provider": mediaProvider,
|
||||||
}).Debug("Media storage | Minio client created")
|
}).Debug("Media storage | Minio client created")
|
||||||
|
|
||||||
imageProvider := imagesProvider.NewClient(c.ImageConf.Host + ":" + c.ImageConf.Port)
|
|
||||||
|
|
||||||
//deps providers
|
//deps providers
|
||||||
routerHandler := router.NewRouter(router.Deps{
|
routerHandler := router.NewRouter(router.Deps{
|
||||||
ApiPrefix: c.AppConf.ApiPrefix,
|
ApiPrefix: c.AppConf.ApiPrefix,
|
||||||
|
|
@ -94,10 +91,9 @@ func main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
merchModule := merch.NewHandler(merch.Deps{
|
merchModule := merch.NewHandler(merch.Deps{
|
||||||
DB: database,
|
DB: database,
|
||||||
Utils: utilsProvider,
|
Utils: utilsProvider,
|
||||||
Media: mediaProvider,
|
Media: mediaProvider,
|
||||||
ImageStorage: imageProvider,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//collect modules
|
//collect modules
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ type Config struct {
|
||||||
JWTConf JWTConfig
|
JWTConf JWTConfig
|
||||||
GrpcConf GrpcConfig
|
GrpcConf GrpcConfig
|
||||||
MediaConf MediaConfig
|
MediaConf MediaConfig
|
||||||
ImageConf ImageStorageConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
|
|
@ -49,11 +48,6 @@ type MediaConfig struct {
|
||||||
Secure string
|
Secure string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageStorageConfig struct {
|
|
||||||
Host string
|
|
||||||
Port string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
AppConf: AppConfig{
|
AppConf: AppConfig{
|
||||||
|
|
@ -93,10 +87,5 @@ func NewConfig() *Config {
|
||||||
Password: getEnv("MEDIA_STORAGE_PASSWORD", ""),
|
Password: getEnv("MEDIA_STORAGE_PASSWORD", ""),
|
||||||
Secure: getEnv("MEDIA_STORAGE_SECURE", ""),
|
Secure: getEnv("MEDIA_STORAGE_SECURE", ""),
|
||||||
},
|
},
|
||||||
|
|
||||||
ImageConf: ImageStorageConfig{
|
|
||||||
Host: getEnv("IMAGE_STORAGE_HOST", ""),
|
|
||||||
Port: getEnv("IMAGE_STORAGE_PORT", ""),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
36
docs/docs.go
36
docs/docs.go
|
|
@ -192,7 +192,7 @@ const docTemplate = `{
|
||||||
"BearerAuth": []
|
"BearerAuth": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на созданные картинки.",
|
"description": "Загрузить картинки по merch_uuid и query параметрам",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"multipart/form-data"
|
"multipart/form-data"
|
||||||
],
|
],
|
||||||
|
|
@ -202,7 +202,7 @@ const docTemplate = `{
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch images"
|
"Merch images"
|
||||||
],
|
],
|
||||||
"summary": "Загрузить картинку по merch_uuid",
|
"summary": "Загрузить картинки по merch_uuid и query параметрам",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -217,14 +217,23 @@ const docTemplate = `{
|
||||||
"name": "file",
|
"name": "file",
|
||||||
"in": "formData",
|
"in": "formData",
|
||||||
"required": true
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"thumbnail",
|
||||||
|
"full",
|
||||||
|
"all"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"description": "Image type: thumbnail, full or all",
|
||||||
|
"name": "imageType",
|
||||||
|
"in": "formData",
|
||||||
|
"required": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK"
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/imageStorage.UploadMerchImageResponse"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
|
|
@ -246,11 +255,11 @@ const docTemplate = `{
|
||||||
"BearerAuth": []
|
"BearerAuth": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Удалить (безвозвратно) картинки по merch_uuid",
|
"description": "Удалить (безвозвратно) картинки по merch_uuid и query параметрам",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch images"
|
"Merch images"
|
||||||
],
|
],
|
||||||
"summary": "Удалить (безвозвратно) картинки по merch_uuid",
|
"summary": "Удалить (безвозвратно) картинки по merch_uuid и query параметрам",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -759,17 +768,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"imageStorage.UploadMerchImageResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"fullImage": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.ImageLink": {
|
"merch.ImageLink": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@
|
||||||
"BearerAuth": []
|
"BearerAuth": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на созданные картинки.",
|
"description": "Загрузить картинки по merch_uuid и query параметрам",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"multipart/form-data"
|
"multipart/form-data"
|
||||||
],
|
],
|
||||||
|
|
@ -194,7 +194,7 @@
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch images"
|
"Merch images"
|
||||||
],
|
],
|
||||||
"summary": "Загрузить картинку по merch_uuid",
|
"summary": "Загрузить картинки по merch_uuid и query параметрам",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -209,14 +209,23 @@
|
||||||
"name": "file",
|
"name": "file",
|
||||||
"in": "formData",
|
"in": "formData",
|
||||||
"required": true
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"thumbnail",
|
||||||
|
"full",
|
||||||
|
"all"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"description": "Image type: thumbnail, full or all",
|
||||||
|
"name": "imageType",
|
||||||
|
"in": "formData",
|
||||||
|
"required": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK"
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/imageStorage.UploadMerchImageResponse"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request",
|
"description": "Bad Request",
|
||||||
|
|
@ -238,11 +247,11 @@
|
||||||
"BearerAuth": []
|
"BearerAuth": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Удалить (безвозвратно) картинки по merch_uuid",
|
"description": "Удалить (безвозвратно) картинки по merch_uuid и query параметрам",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Merch images"
|
"Merch images"
|
||||||
],
|
],
|
||||||
"summary": "Удалить (безвозвратно) картинки по merch_uuid",
|
"summary": "Удалить (безвозвратно) картинки по merch_uuid и query параметрам",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -751,17 +760,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"imageStorage.UploadMerchImageResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"fullImage": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merch.ImageLink": {
|
"merch.ImageLink": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,5 @@
|
||||||
basePath: /api/v2
|
basePath: /api/v2
|
||||||
definitions:
|
definitions:
|
||||||
imageStorage.UploadMerchImageResponse:
|
|
||||||
properties:
|
|
||||||
fullImage:
|
|
||||||
type: string
|
|
||||||
thumbnail:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
merch.ImageLink:
|
merch.ImageLink:
|
||||||
properties:
|
properties:
|
||||||
etag:
|
etag:
|
||||||
|
|
@ -278,7 +271,7 @@ paths:
|
||||||
- Merch
|
- Merch
|
||||||
/merch/images/{uuid}:
|
/merch/images/{uuid}:
|
||||||
delete:
|
delete:
|
||||||
description: Удалить (безвозвратно) картинки по merch_uuid
|
description: Удалить (безвозвратно) картинки по merch_uuid и query параметрам
|
||||||
parameters:
|
parameters:
|
||||||
- description: merch_uuid
|
- description: merch_uuid
|
||||||
in: path
|
in: path
|
||||||
|
|
@ -298,7 +291,7 @@ paths:
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
security:
|
security:
|
||||||
- BearerAuth: []
|
- BearerAuth: []
|
||||||
summary: Удалить (безвозвратно) картинки по merch_uuid
|
summary: Удалить (безвозвратно) картинки по merch_uuid и query параметрам
|
||||||
tags:
|
tags:
|
||||||
- Merch images
|
- Merch images
|
||||||
get:
|
get:
|
||||||
|
|
@ -335,8 +328,7 @@ paths:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
- multipart/form-data
|
- multipart/form-data
|
||||||
description: Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на
|
description: Загрузить картинки по merch_uuid и query параметрам
|
||||||
созданные картинки.
|
|
||||||
parameters:
|
parameters:
|
||||||
- description: Merch UUID
|
- description: Merch UUID
|
||||||
in: path
|
in: path
|
||||||
|
|
@ -348,13 +340,20 @@ paths:
|
||||||
name: file
|
name: file
|
||||||
required: true
|
required: true
|
||||||
type: file
|
type: file
|
||||||
|
- description: 'Image type: thumbnail, full or all'
|
||||||
|
enum:
|
||||||
|
- thumbnail
|
||||||
|
- full
|
||||||
|
- all
|
||||||
|
in: formData
|
||||||
|
name: imageType
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/imageStorage.UploadMerchImageResponse'
|
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
|
|
@ -365,7 +364,7 @@ paths:
|
||||||
$ref: '#/definitions/responses.ErrorResponse500'
|
$ref: '#/definitions/responses.ErrorResponse500'
|
||||||
security:
|
security:
|
||||||
- BearerAuth: []
|
- BearerAuth: []
|
||||||
summary: Загрузить картинку по merch_uuid
|
summary: Загрузить картинки по merch_uuid и query параметрам
|
||||||
tags:
|
tags:
|
||||||
- Merch images
|
- Merch images
|
||||||
/prices:
|
/prices:
|
||||||
|
|
|
||||||
4
go.mod
4
go.mod
|
|
@ -52,7 +52,7 @@ require (
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.18.1 // indirect
|
github.com/klauspost/compress v1.18.0 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
|
@ -79,5 +79,5 @@ require (
|
||||||
golang.org/x/sys v0.37.0 // indirect
|
golang.org/x/sys v0.37.0 // indirect
|
||||||
golang.org/x/text v0.30.0 // indirect
|
golang.org/x/text v0.30.0 // indirect
|
||||||
golang.org/x/tools v0.38.0 // indirect
|
golang.org/x/tools v0.38.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f // indirect
|
||||||
)
|
)
|
||||||
|
|
|
||||||
8
go.sum
8
go.sum
|
|
@ -89,8 +89,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
|
|
@ -217,8 +217,8 @@ golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 h1:M1rk8KBnUsBDg1oPGHNCxG4vc1f49epmTO7xscSajMk=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f h1:1FTH6cpXFsENbPR5Bu8NQddPSaUUE6NA2XdZdDSAJK4=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
|
||||||
google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A=
|
google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A=
|
||||||
google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c=
|
google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c=
|
||||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||||
|
|
|
||||||
|
|
@ -266,15 +266,16 @@ func (co *controller) getDistinctPrices(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Загрузить картинку по merch_uuid
|
// @Summary Загрузить картинки по merch_uuid и query параметрам
|
||||||
// @Description Загрузить картинку по merch_uuid. В ответ будут выданы ссылки на созданные картинки.
|
// @Description Загрузить картинки по merch_uuid и query параметрам
|
||||||
// @Tags Merch images
|
// @Tags Merch images
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Accept multipart/form-data
|
// @Accept multipart/form-data
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param uuid path string true "Merch UUID"
|
// @Param uuid path string true "Merch UUID"
|
||||||
// @Param file formData file true "Image file"
|
// @Param file formData file true "Image file"
|
||||||
// @Success 200 {object} imageStorage.UploadMerchImageResponse
|
// @Param imageType formData string true "Image type: thumbnail, full or all" Enums(thumbnail, full, all)
|
||||||
|
// @Success 200
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
// @Router /merch/images/{uuid} [post]
|
// @Router /merch/images/{uuid} [post]
|
||||||
|
|
@ -293,14 +294,13 @@ func (co *controller) uploadMerchImage(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//Uncomment for MinIO use
|
imageType := c.PostForm("imageType")
|
||||||
//imageType := c.PostForm("imageType")
|
types := map[string]struct{}{"thumbnail": {}, "full": {}, "all": {}}
|
||||||
//types := map[string]struct{}{"thumbnail": {}, "full": {}, "all": {}}
|
if _, allowed := types[imageType]; !allowed {
|
||||||
//if _, allowed := types[imageType]; !allowed {
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "imageType must be one of: thumbnail, full, all"})
|
||||||
// c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "imageType must be one of: thumbnail, full, all"})
|
log.WithError(err).Error("Merch | imageType must be one of: thumbnail, full, all")
|
||||||
// log.WithError(err).Error("Merch | imageType must be one of: thumbnail, full, all")
|
return
|
||||||
// return
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
file, err := c.FormFile("file")
|
file, err := c.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -312,17 +312,14 @@ func (co *controller) uploadMerchImage(c *gin.Context) {
|
||||||
ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
//Uncomment for MinIO use
|
err = co.service.uploadMerchImage(ctx, userUuid, merchUuid, imageType, file)
|
||||||
//err = co.service.uploadMerchImage(ctx, userUuid, merchUuid, imageType, file)
|
|
||||||
response, err := co.service.mtUploadMerchImage(ctx, userUuid, merchUuid, file)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
log.WithError(err).Error("Merch | Failed to upload merch image")
|
log.WithError(err).Error("Merch | Failed to upload merch image")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//c.Status(http.StatusOK)
|
c.Status(http.StatusOK)
|
||||||
c.JSON(http.StatusOK, response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Получить картинки по merch_uuid и query параметрам
|
// @Summary Получить картинки по merch_uuid и query параметрам
|
||||||
|
|
@ -336,53 +333,43 @@ func (co *controller) uploadMerchImage(c *gin.Context) {
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
// @Router /merch/images/{uuid} [get]
|
// @Router /merch/images/{uuid} [get]
|
||||||
func (co *controller) getMerchImage(c *gin.Context) {
|
func (co *controller) getMerchImage(c *gin.Context) {
|
||||||
//Uncomment for MinIO use
|
typeQuery := strings.ToLower(c.Query("type"))
|
||||||
|
if typeQuery == "" {
|
||||||
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "Image type query param is empty"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//typeQuery := strings.ToLower(c.Query("type"))
|
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
||||||
//if typeQuery == "" {
|
if err != nil {
|
||||||
// c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "Image type query param is empty"})
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
// return
|
log.WithError(err).Error("Merch | Failed to get user uuid from context")
|
||||||
//}
|
return
|
||||||
//
|
}
|
||||||
//userUuid, err := co.utils.GetUserUuidFromContext(c)
|
|
||||||
//if err != nil {
|
merchUuid := c.Param("uuid")
|
||||||
// c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
if merchUuid == "" {
|
||||||
// log.WithError(err).Error("Merch | Failed to get user uuid from context")
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "MerchUuid is empty"})
|
||||||
// return
|
log.WithError(err).Error("Merch | Failed to get single merch")
|
||||||
//}
|
return
|
||||||
//
|
}
|
||||||
//merchUuid := c.Param("uuid")
|
|
||||||
//if merchUuid == "" {
|
ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
||||||
// c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "MerchUuid is empty"})
|
defer cancel()
|
||||||
// log.WithError(err).Error("Merch | Failed to get single merch")
|
|
||||||
// return
|
link, err := co.service.getPublicImageLink(ctx, userUuid, merchUuid, typeQuery)
|
||||||
//}
|
if err != nil {
|
||||||
//
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
//ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
log.WithError(err).Error("Merch | Failed to get merch image")
|
||||||
//defer cancel()
|
return
|
||||||
//
|
}
|
||||||
//link, err := co.service.getPublicImageLink(ctx, userUuid, merchUuid, typeQuery)
|
c.JSON(http.StatusOK, link)
|
||||||
//if err != nil {
|
|
||||||
// c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
|
||||||
// log.WithError(err).Error("Merch | Failed to get merch image")
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if link.Link == "" {
|
|
||||||
// log.Debug("Merch | No image")
|
|
||||||
// c.Status(http.StatusNoContent)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//c.JSON(http.StatusOK, link)
|
|
||||||
c.JSON(http.StatusNotImplemented, gin.H{"msg": "Method deprecated. Request images from image storage."})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Удалить (безвозвратно) картинки по merch_uuid
|
// @Summary Удалить (безвозвратно) картинки по merch_uuid и query параметрам
|
||||||
// @Description Удалить (безвозвратно) картинки по merch_uuid
|
// @Description Удалить (безвозвратно) картинки по merch_uuid и query параметрам
|
||||||
// @Tags Merch images
|
// @Tags Merch images
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param uuid path string true "merch_uuid"
|
// @Param uuid path string true "merch_uuid"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Failure 400 {object} responses.ErrorResponse400
|
// @Failure 400 {object} responses.ErrorResponse400
|
||||||
// @Failure 500 {object} responses.ErrorResponse500
|
// @Failure 500 {object} responses.ErrorResponse500
|
||||||
|
|
@ -398,17 +385,14 @@ func (co *controller) deleteMerchImage(c *gin.Context) {
|
||||||
merchUuid := c.Param("uuid")
|
merchUuid := c.Param("uuid")
|
||||||
if merchUuid == "" {
|
if merchUuid == "" {
|
||||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "MerchUuid is empty"})
|
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: "MerchUuid is empty"})
|
||||||
log.WithError(err).Error("Merch | Failed to get merch uuid")
|
log.WithError(err).Error("Merch | Failed to get single merch")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
ctx, cancel := context.WithTimeout(c.Request.Context(), co.expires)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
//Uncomment for MinIO use
|
if err := co.service.deleteMerchImage(ctx, userUuid, merchUuid); err != nil {
|
||||||
//if err := co.service.deleteMerchImage(ctx, userUuid, merchUuid); err != nil {
|
|
||||||
|
|
||||||
if err := co.service.mtDeleteMerchImage(ctx, userUuid, merchUuid); err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||||
log.WithError(err).Error("Merch | Failed to delete merch image")
|
log.WithError(err).Error("Merch | Failed to delete merch image")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
is "merch-parser-api/proto/imageStorage"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -15,10 +14,9 @@ type Handler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
DB *gorm.DB
|
DB *gorm.DB
|
||||||
Utils interfaces.Utils
|
Utils interfaces.Utils
|
||||||
Media interfaces.MediaStorage
|
Media interfaces.MediaStorage
|
||||||
ImageStorage is.ImageStorageClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHandler(deps Deps) *Handler {
|
func NewHandler(deps Deps) *Handler {
|
||||||
|
|
@ -26,13 +24,7 @@ func NewHandler(deps Deps) *Handler {
|
||||||
expires := time.Minute * 5
|
expires := time.Minute * 5
|
||||||
|
|
||||||
r := NewRepo(deps.DB)
|
r := NewRepo(deps.DB)
|
||||||
s := newService(serviceDeps{
|
s := newService(r, deps.Media, packageBucketName, expires)
|
||||||
repo: r,
|
|
||||||
media: deps.Media,
|
|
||||||
bucketName: packageBucketName,
|
|
||||||
expires: expires,
|
|
||||||
imageStorage: deps.ImageStorage,
|
|
||||||
})
|
|
||||||
c := newController(s, deps.Utils, expires)
|
c := newController(s, deps.Utils, expires)
|
||||||
|
|
||||||
media := deps.Media
|
media := deps.Media
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ func (r *Repo) merchRecordExists(userUuid, merchUuid string) (bool, error) {
|
||||||
FROM merch
|
FROM merch
|
||||||
WHERE user_uuid = ?
|
WHERE user_uuid = ?
|
||||||
AND merch_uuid = ?
|
AND merch_uuid = ?
|
||||||
AND deleted_at IS NULL
|
|
||||||
);`, userUuid, merchUuid).Scan(&exists).Error
|
);`, userUuid, merchUuid).Scan(&exists).Error
|
||||||
|
|
||||||
return exists, err
|
return exists, err
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"io"
|
"io"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
is "merch-parser-api/proto/imageStorage"
|
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -21,28 +20,18 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
repo repository
|
repo repository
|
||||||
media interfaces.MediaStorage
|
media interfaces.MediaStorage
|
||||||
bucketName string
|
bucketName string
|
||||||
expires time.Duration
|
expires time.Duration
|
||||||
imageStorage is.ImageStorageClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceDeps struct {
|
func newService(repo repository, media interfaces.MediaStorage, bucketName string, expires time.Duration) *service {
|
||||||
repo repository
|
|
||||||
media interfaces.MediaStorage
|
|
||||||
bucketName string
|
|
||||||
expires time.Duration
|
|
||||||
imageStorage is.ImageStorageClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func newService(deps serviceDeps) *service {
|
|
||||||
return &service{
|
return &service{
|
||||||
repo: deps.repo,
|
repo: repo,
|
||||||
media: deps.media,
|
media: media,
|
||||||
bucketName: deps.bucketName,
|
bucketName: bucketName,
|
||||||
expires: deps.expires,
|
expires: expires,
|
||||||
imageStorage: deps.imageStorage,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,9 +210,6 @@ func (s *service) getDistinctPrices(userUuid, merchUuid, days string) (PricesRes
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// uploadMerchImage
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage. Use mtUploadMerchImage for merch-tracker images storage.
|
|
||||||
func (s *service) uploadMerchImage(ctx context.Context, userUuid, merchUuid, imageType string, file *multipart.FileHeader) error {
|
func (s *service) uploadMerchImage(ctx context.Context, userUuid, merchUuid, imageType string, file *multipart.FileHeader) error {
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -317,9 +303,6 @@ func (s *service) uploadMerchImage(ctx context.Context, userUuid, merchUuid, ima
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPublicImageLink
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage.
|
|
||||||
func (s *service) getPublicImageLink(ctx context.Context, userUuid, merchUuid, imageType string) (ImageLink, error) {
|
func (s *service) getPublicImageLink(ctx context.Context, userUuid, merchUuid, imageType string) (ImageLink, error) {
|
||||||
object, err := s.makeObject(userUuid, merchUuid, imageType)
|
object, err := s.makeObject(userUuid, merchUuid, imageType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -337,9 +320,6 @@ func (s *service) getPublicImageLink(ctx context.Context, userUuid, merchUuid, i
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPresignedImageLink
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage.
|
|
||||||
func (s *service) getPresignedImageLink(ctx context.Context, userUuid, merchUuid, imageType string) (ImageLink, error) {
|
func (s *service) getPresignedImageLink(ctx context.Context, userUuid, merchUuid, imageType string) (ImageLink, error) {
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -371,9 +351,6 @@ func (s *service) getPresignedImageLink(ctx context.Context, userUuid, merchUuid
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteMerchImage
|
|
||||||
// Deprecated.
|
|
||||||
// Use only with MinIO storage.
|
|
||||||
func (s *service) deleteMerchImage(ctx context.Context, userUuid, merchUuid string) error {
|
func (s *service) deleteMerchImage(ctx context.Context, userUuid, merchUuid string) error {
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -421,65 +398,3 @@ func (s *service) _uploadToStorage(params uploadImageParams) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// mtUploadMerchImage
|
|
||||||
// Upload new/rewrite existing image to merch-tracker images storage
|
|
||||||
func (s *service) mtUploadMerchImage(ctx context.Context, userUuid, merchUuid string, file *multipart.FileHeader) (*is.UploadMerchImageResponse, error) {
|
|
||||||
const uploadMerchImage = "Merch service | Upload merch image"
|
|
||||||
|
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
err = fmt.Errorf("no merch found for user %s with uuid %s", userUuid, merchUuid)
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
f, err := file.Open()
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
data, err := io.ReadAll(f)
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := s.imageStorage.UploadImage(ctx, &is.UploadMerchImageRequest{
|
|
||||||
ImageData: data,
|
|
||||||
UserUuid: userUuid,
|
|
||||||
MerchUuid: merchUuid,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Error(uploadMerchImage)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return response, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// mtDeleteMerchImage
|
|
||||||
// Delete all merch images for given user and merch uuid-s from merch-tracker images storage
|
|
||||||
func (s *service) mtDeleteMerchImage(ctx context.Context, userUuid, merchUuid string) error {
|
|
||||||
exists, err := s.repo.merchRecordExists(userUuid, merchUuid)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return fmt.Errorf("no merch found for user %s with uuid %s", userUuid, merchUuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
s.imageStorage.DeleteImage(ctx, &is.DeleteImageRequest{
|
|
||||||
UserUuid: userUuid,
|
|
||||||
MerchUuid: merchUuid,
|
|
||||||
})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,106 @@
|
||||||
package grpcService
|
package grpcService
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
"io"
|
||||||
"merch-parser-api/internal/interfaces"
|
"merch-parser-api/internal/interfaces"
|
||||||
|
"merch-parser-api/internal/shared"
|
||||||
pb "merch-parser-api/proto/taskProcessor"
|
pb "merch-parser-api/proto/taskProcessor"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type repoServer struct {
|
||||||
|
pb.UnimplementedTaskProcessorServer
|
||||||
|
taskProvider interfaces.TaskProvider
|
||||||
|
}
|
||||||
|
|
||||||
func NewGrpcServer(taskProvider interfaces.TaskProvider) *grpc.Server {
|
func NewGrpcServer(taskProvider interfaces.TaskProvider) *grpc.Server {
|
||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
|
|
||||||
repoSrv := &repoServer{
|
repoSrv := &repoServer{
|
||||||
taskProvider: taskProvider,
|
taskProvider: taskProvider,
|
||||||
}
|
}
|
||||||
pb.RegisterTaskProcessorServer(srv, repoSrv)
|
|
||||||
|
|
||||||
|
pb.RegisterTaskProcessorServer(srv, repoSrv)
|
||||||
return srv
|
return srv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *repoServer) RequestTask(_ *emptypb.Empty, stream pb.TaskProcessor_RequestTaskServer) error {
|
||||||
|
tasks, err := r.taskProvider.PrepareTasks()
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Request task error")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, task := range tasks {
|
||||||
|
if err = stream.Send(&pb.Task{
|
||||||
|
MerchUuid: task.MerchUuid,
|
||||||
|
OriginSurugayaLink: task.OriginSurugayaLink,
|
||||||
|
OriginMandarakeLink: task.OriginMandarakeLink,
|
||||||
|
}); err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Stream send error")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *repoServer) SendResult(stream pb.TaskProcessor_SendResultServer) error {
|
||||||
|
saveInterval := time.Second * 2
|
||||||
|
batch := make([]shared.TaskResult, 0)
|
||||||
|
|
||||||
|
ticker := time.NewTicker(saveInterval)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
if len(batch) > 0 {
|
||||||
|
err := r.taskProvider.InsertPrices(batch)
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Batch insert")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for {
|
||||||
|
response, err := stream.Recv()
|
||||||
|
if err == io.EOF {
|
||||||
|
log.Debug("gRPC EOF")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Receive")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
entry := shared.TaskResult{
|
||||||
|
MerchUuid: response.MerchUuid,
|
||||||
|
Origin: response.OriginName,
|
||||||
|
Price: response.Price,
|
||||||
|
}
|
||||||
|
|
||||||
|
batch = append(batch, entry)
|
||||||
|
log.WithField("response", entry).Debug("gRPC Server | Receive success")
|
||||||
|
}
|
||||||
|
|
||||||
|
close(done)
|
||||||
|
if len(batch) > 0 {
|
||||||
|
err := r.taskProvider.InsertPrices(batch)
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("err", err).Error("gRPC Server | Last data batch insert")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
package grpcService
|
|
||||||
|
|
||||||
import (
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
"io"
|
|
||||||
"merch-parser-api/internal/interfaces"
|
|
||||||
"merch-parser-api/internal/shared"
|
|
||||||
pb "merch-parser-api/proto/taskProcessor"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type repoServer struct {
|
|
||||||
pb.UnimplementedTaskProcessorServer
|
|
||||||
taskProvider interfaces.TaskProvider
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repoServer) RequestTask(_ *emptypb.Empty, stream pb.TaskProcessor_RequestTaskServer) error {
|
|
||||||
tasks, err := r.taskProvider.PrepareTasks()
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Request task error")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, task := range tasks {
|
|
||||||
if err = stream.Send(&pb.Task{
|
|
||||||
MerchUuid: task.MerchUuid,
|
|
||||||
OriginSurugayaLink: task.OriginSurugayaLink,
|
|
||||||
OriginMandarakeLink: task.OriginMandarakeLink,
|
|
||||||
}); err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Stream send error")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repoServer) SendResult(stream pb.TaskProcessor_SendResultServer) error {
|
|
||||||
saveInterval := time.Second * 2
|
|
||||||
batch := make([]shared.TaskResult, 0)
|
|
||||||
|
|
||||||
ticker := time.NewTicker(saveInterval)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
done := make(chan struct{})
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
if len(batch) > 0 {
|
|
||||||
err := r.taskProvider.InsertPrices(batch)
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Batch insert")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
for {
|
|
||||||
response, err := stream.Recv()
|
|
||||||
if err == io.EOF {
|
|
||||||
log.Debug("gRPC EOF")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Receive")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
entry := shared.TaskResult{
|
|
||||||
MerchUuid: response.MerchUuid,
|
|
||||||
Origin: response.OriginName,
|
|
||||||
Price: response.Price,
|
|
||||||
}
|
|
||||||
|
|
||||||
batch = append(batch, entry)
|
|
||||||
log.WithField("response", entry).Debug("gRPC Server | Receive success")
|
|
||||||
}
|
|
||||||
|
|
||||||
close(done)
|
|
||||||
if len(batch) > 0 {
|
|
||||||
err := r.taskProvider.InsertPrices(batch)
|
|
||||||
if err != nil {
|
|
||||||
log.WithField("err", err).Error("gRPC Server | Last data batch insert")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package imagesProvider
|
|
||||||
|
|
||||||
import (
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
|
||||||
is "merch-parser-api/proto/imageStorage"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Handler struct{}
|
|
||||||
|
|
||||||
func NewClient(address string) is.ImageStorageClient {
|
|
||||||
var opts []grpc.DialOption
|
|
||||||
insec := grpc.WithTransportCredentials(insecure.NewCredentials())
|
|
||||||
opts = append(opts, insec)
|
|
||||||
|
|
||||||
conn, err := grpc.NewClient(address, opts...)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"address": address,
|
|
||||||
}).Debug("gRPC | API client")
|
|
||||||
|
|
||||||
return is.NewImageStorageClient(conn)
|
|
||||||
}
|
|
||||||
|
|
@ -7,8 +7,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MinIO service replaced by imagesProvider
|
|
||||||
|
|
||||||
type MediaStorage interface {
|
type MediaStorage interface {
|
||||||
CheckBucketExists(bucketName string) (bool, error)
|
CheckBucketExists(bucketName string) (bool, error)
|
||||||
Upload(ctx context.Context, bucket, object string, reader io.Reader, size int64) error
|
Upload(ctx context.Context, bucket, object string, reader io.Reader, size int64) error
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,6 @@ func (s *Service) Upload(ctx context.Context, bucket, object string, reader io.R
|
||||||
func (s *Service) GetPublicLink(ctx context.Context, bucket, object string) (string, string, error) {
|
func (s *Service) GetPublicLink(ctx context.Context, bucket, object string) (string, string, error) {
|
||||||
stat, err := s.client.StatObject(ctx, bucket, object, minio.StatObjectOptions{})
|
stat, err := s.client.StatObject(ctx, bucket, object, minio.StatObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == minio.ToErrorResponse(err).Error() {
|
|
||||||
return "", "", nil
|
|
||||||
}
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"error": err,
|
"error": err,
|
||||||
"key": bucket + "/" + object,
|
"key": bucket + "/" + object,
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
syntax="proto3";
|
|
||||||
|
|
||||||
import "google/protobuf/empty.proto";
|
|
||||||
|
|
||||||
package imageStorage;
|
|
||||||
option go_package = "imageStorage/pkg/proto/imageStorage";
|
|
||||||
|
|
||||||
message UploadMerchImageRequest{
|
|
||||||
bytes imageData = 1;
|
|
||||||
string userUuid = 2;
|
|
||||||
string merchUuid = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UploadMerchImageResponse {
|
|
||||||
string fullImage = 1;
|
|
||||||
string thumbnail = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteImageRequest {
|
|
||||||
string userUuid = 1;
|
|
||||||
string merchUuid = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
service ImageStorage {
|
|
||||||
rpc UploadImage(UploadMerchImageRequest) returns (UploadMerchImageResponse);
|
|
||||||
rpc DeleteImage(DeleteImageRequest) returns (google.protobuf.Empty);
|
|
||||||
}
|
|
||||||
|
|
@ -1,261 +0,0 @@
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.36.8
|
|
||||||
// protoc v6.32.1
|
|
||||||
// source: imageStorage.proto
|
|
||||||
|
|
||||||
package imageStorage
|
|
||||||
|
|
||||||
import (
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
type UploadMerchImageRequest struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
ImageData []byte `protobuf:"bytes,1,opt,name=imageData,proto3" json:"imageData,omitempty"`
|
|
||||||
UserUuid string `protobuf:"bytes,2,opt,name=userUuid,proto3" json:"userUuid,omitempty"`
|
|
||||||
MerchUuid string `protobuf:"bytes,3,opt,name=merchUuid,proto3" json:"merchUuid,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) Reset() {
|
|
||||||
*x = UploadMerchImageRequest{}
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*UploadMerchImageRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[0]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use UploadMerchImageRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*UploadMerchImageRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_imageStorage_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) GetImageData() []byte {
|
|
||||||
if x != nil {
|
|
||||||
return x.ImageData
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) GetUserUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.UserUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageRequest) GetMerchUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.MerchUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type UploadMerchImageResponse struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
FullImage string `protobuf:"bytes,1,opt,name=fullImage,proto3" json:"fullImage,omitempty"`
|
|
||||||
Thumbnail string `protobuf:"bytes,2,opt,name=thumbnail,proto3" json:"thumbnail,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) Reset() {
|
|
||||||
*x = UploadMerchImageResponse{}
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[1]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*UploadMerchImageResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[1]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use UploadMerchImageResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*UploadMerchImageResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_imageStorage_proto_rawDescGZIP(), []int{1}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) GetFullImage() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.FullImage
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *UploadMerchImageResponse) GetThumbnail() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Thumbnail
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteImageRequest struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
UserUuid string `protobuf:"bytes,1,opt,name=userUuid,proto3" json:"userUuid,omitempty"`
|
|
||||||
MerchUuid string `protobuf:"bytes,2,opt,name=merchUuid,proto3" json:"merchUuid,omitempty"`
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) Reset() {
|
|
||||||
*x = DeleteImageRequest{}
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[2]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DeleteImageRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_imageStorage_proto_msgTypes[2]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DeleteImageRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DeleteImageRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_imageStorage_proto_rawDescGZIP(), []int{2}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) GetUserUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.UserUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DeleteImageRequest) GetMerchUuid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.MerchUuid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_imageStorage_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
const file_imageStorage_proto_rawDesc = "" +
|
|
||||||
"\n" +
|
|
||||||
"\x12imageStorage.proto\x12\fimageStorage\x1a\x1bgoogle/protobuf/empty.proto\"q\n" +
|
|
||||||
"\x17UploadMerchImageRequest\x12\x1c\n" +
|
|
||||||
"\timageData\x18\x01 \x01(\fR\timageData\x12\x1a\n" +
|
|
||||||
"\buserUuid\x18\x02 \x01(\tR\buserUuid\x12\x1c\n" +
|
|
||||||
"\tmerchUuid\x18\x03 \x01(\tR\tmerchUuid\"V\n" +
|
|
||||||
"\x18UploadMerchImageResponse\x12\x1c\n" +
|
|
||||||
"\tfullImage\x18\x01 \x01(\tR\tfullImage\x12\x1c\n" +
|
|
||||||
"\tthumbnail\x18\x02 \x01(\tR\tthumbnail\"N\n" +
|
|
||||||
"\x12DeleteImageRequest\x12\x1a\n" +
|
|
||||||
"\buserUuid\x18\x01 \x01(\tR\buserUuid\x12\x1c\n" +
|
|
||||||
"\tmerchUuid\x18\x02 \x01(\tR\tmerchUuid2\xb5\x01\n" +
|
|
||||||
"\fImageStorage\x12\\\n" +
|
|
||||||
"\vUploadImage\x12%.imageStorage.UploadMerchImageRequest\x1a&.imageStorage.UploadMerchImageResponse\x12G\n" +
|
|
||||||
"\vDeleteImage\x12 .imageStorage.DeleteImageRequest\x1a\x16.google.protobuf.EmptyB%Z#imageStorage/pkg/proto/imageStorageb\x06proto3"
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_imageStorage_proto_rawDescOnce sync.Once
|
|
||||||
file_imageStorage_proto_rawDescData []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_imageStorage_proto_rawDescGZIP() []byte {
|
|
||||||
file_imageStorage_proto_rawDescOnce.Do(func() {
|
|
||||||
file_imageStorage_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_imageStorage_proto_rawDesc), len(file_imageStorage_proto_rawDesc)))
|
|
||||||
})
|
|
||||||
return file_imageStorage_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_imageStorage_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
|
||||||
var file_imageStorage_proto_goTypes = []any{
|
|
||||||
(*UploadMerchImageRequest)(nil), // 0: imageStorage.UploadMerchImageRequest
|
|
||||||
(*UploadMerchImageResponse)(nil), // 1: imageStorage.UploadMerchImageResponse
|
|
||||||
(*DeleteImageRequest)(nil), // 2: imageStorage.DeleteImageRequest
|
|
||||||
(*emptypb.Empty)(nil), // 3: google.protobuf.Empty
|
|
||||||
}
|
|
||||||
var file_imageStorage_proto_depIdxs = []int32{
|
|
||||||
0, // 0: imageStorage.ImageStorage.UploadImage:input_type -> imageStorage.UploadMerchImageRequest
|
|
||||||
2, // 1: imageStorage.ImageStorage.DeleteImage:input_type -> imageStorage.DeleteImageRequest
|
|
||||||
1, // 2: imageStorage.ImageStorage.UploadImage:output_type -> imageStorage.UploadMerchImageResponse
|
|
||||||
3, // 3: imageStorage.ImageStorage.DeleteImage:output_type -> google.protobuf.Empty
|
|
||||||
2, // [2:4] is the sub-list for method output_type
|
|
||||||
0, // [0:2] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_imageStorage_proto_init() }
|
|
||||||
func file_imageStorage_proto_init() {
|
|
||||||
if File_imageStorage_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_imageStorage_proto_rawDesc), len(file_imageStorage_proto_rawDesc)),
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 3,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 1,
|
|
||||||
},
|
|
||||||
GoTypes: file_imageStorage_proto_goTypes,
|
|
||||||
DependencyIndexes: file_imageStorage_proto_depIdxs,
|
|
||||||
MessageInfos: file_imageStorage_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_imageStorage_proto = out.File
|
|
||||||
file_imageStorage_proto_goTypes = nil
|
|
||||||
file_imageStorage_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
|
||||||
// - protoc v6.32.1
|
|
||||||
// source: imageStorage.proto
|
|
||||||
|
|
||||||
package imageStorage
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.64.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion9
|
|
||||||
|
|
||||||
const (
|
|
||||||
ImageStorage_UploadImage_FullMethodName = "/imageStorage.ImageStorage/UploadImage"
|
|
||||||
ImageStorage_DeleteImage_FullMethodName = "/imageStorage.ImageStorage/DeleteImage"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ImageStorageClient is the client API for ImageStorage service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
type ImageStorageClient interface {
|
|
||||||
UploadImage(ctx context.Context, in *UploadMerchImageRequest, opts ...grpc.CallOption) (*UploadMerchImageResponse, error)
|
|
||||||
DeleteImage(ctx context.Context, in *DeleteImageRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type imageStorageClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewImageStorageClient(cc grpc.ClientConnInterface) ImageStorageClient {
|
|
||||||
return &imageStorageClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *imageStorageClient) UploadImage(ctx context.Context, in *UploadMerchImageRequest, opts ...grpc.CallOption) (*UploadMerchImageResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(UploadMerchImageResponse)
|
|
||||||
err := c.cc.Invoke(ctx, ImageStorage_UploadImage_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *imageStorageClient) DeleteImage(ctx context.Context, in *DeleteImageRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(emptypb.Empty)
|
|
||||||
err := c.cc.Invoke(ctx, ImageStorage_DeleteImage_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageStorageServer is the server API for ImageStorage service.
|
|
||||||
// All implementations must embed UnimplementedImageStorageServer
|
|
||||||
// for forward compatibility.
|
|
||||||
type ImageStorageServer interface {
|
|
||||||
UploadImage(context.Context, *UploadMerchImageRequest) (*UploadMerchImageResponse, error)
|
|
||||||
DeleteImage(context.Context, *DeleteImageRequest) (*emptypb.Empty, error)
|
|
||||||
mustEmbedUnimplementedImageStorageServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedImageStorageServer must be embedded to have
|
|
||||||
// forward compatible implementations.
|
|
||||||
//
|
|
||||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
||||||
// pointer dereference when methods are called.
|
|
||||||
type UnimplementedImageStorageServer struct{}
|
|
||||||
|
|
||||||
func (UnimplementedImageStorageServer) UploadImage(context.Context, *UploadMerchImageRequest) (*UploadMerchImageResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UploadImage not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedImageStorageServer) DeleteImage(context.Context, *DeleteImageRequest) (*emptypb.Empty, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteImage not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedImageStorageServer) mustEmbedUnimplementedImageStorageServer() {}
|
|
||||||
func (UnimplementedImageStorageServer) testEmbeddedByValue() {}
|
|
||||||
|
|
||||||
// UnsafeImageStorageServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to ImageStorageServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeImageStorageServer interface {
|
|
||||||
mustEmbedUnimplementedImageStorageServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterImageStorageServer(s grpc.ServiceRegistrar, srv ImageStorageServer) {
|
|
||||||
// If the following call pancis, it indicates UnimplementedImageStorageServer was
|
|
||||||
// embedded by pointer and is nil. This will cause panics if an
|
|
||||||
// unimplemented method is ever invoked, so we test this at initialization
|
|
||||||
// time to prevent it from happening at runtime later due to I/O.
|
|
||||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
||||||
t.testEmbeddedByValue()
|
|
||||||
}
|
|
||||||
s.RegisterService(&ImageStorage_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _ImageStorage_UploadImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(UploadMerchImageRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(ImageStorageServer).UploadImage(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: ImageStorage_UploadImage_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(ImageStorageServer).UploadImage(ctx, req.(*UploadMerchImageRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _ImageStorage_DeleteImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(DeleteImageRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(ImageStorageServer).DeleteImage(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: ImageStorage_DeleteImage_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(ImageStorageServer).DeleteImage(ctx, req.(*DeleteImageRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageStorage_ServiceDesc is the grpc.ServiceDesc for ImageStorage service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var ImageStorage_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "imageStorage.ImageStorage",
|
|
||||||
HandlerType: (*ImageStorageServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "UploadImage",
|
|
||||||
Handler: _ImageStorage_UploadImage_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "DeleteImage",
|
|
||||||
Handler: _ImageStorage_DeleteImage_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "imageStorage.proto",
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue