Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
4cbc3b21
Commit
4cbc3b21
authored
5 months ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
добавлены команды запуска
parent
806d3698
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+36
-4
36 additions, 4 deletions
Makefile
Taskfile.yaml
+38
-1
38 additions, 1 deletion
Taskfile.yaml
with
74 additions
and
5 deletions
Makefile
+
36
−
4
View file @
4cbc3b21
...
...
@@ -8,6 +8,8 @@ ALLPROTO?=$(shell find -L $(PROTODIR) -name '*.proto' )
# Убираем status.proto нужен только для front
PROTOFILES
=
$(
filter-out
$(
PROTODIR
)
/status/status.proto,
$(
ALLPROTO
))
PROTOGOFILES
=
$(
PROTOFILES:.proto
=
.pb.go
)
PROTOGOGWFILES
=
$(
PROTOFILES:.proto
=
.gw.go
)
PROTOSWAGGERFILES
=
$(
PROTOFILES:.proto
=
.swagger.json
)
PROTOGOGRPCFILES
=
$(
PROTOFILES:.proto
=
_grpc.pb.go
)
ACCESSLOGGING
=
$(
shell find
-name
"logging_middleware.go"
-type
f
)
...
...
@@ -16,13 +18,43 @@ SERVICETELEMETRY=$(shell find -name "telemetry_middleware.go" -type f)
SERVICEMIDDLEWARE
=
$(
shell find
-name
"middleware.go"
-type
f
)
SERVICERECOVERING
=
$(
shell find
-name
"recovering_middleware.go"
-type
f
)
# Генерация grpc-клиентов для go
proto
:
protoc-check protoc-gen-go-check $(PROTOGOFILES)
@
echo
"Generate Go from proto files"
GOOGLEAPIS_PATH
:=
$(
shell find ~/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@
*
-type
d
-name
googleapis |
head
-n
1
)
# Генерация go grpc клиентов
proto
:
$(PROTOGOFILES)
@
echo
"Generate Go gRPC from proto files"
@
find
$(
PROTODIR
)
-name
'*.proto'
%.pb.go
:
%.proto
@
protoc
-I
=
$(
PROTODIR
)
--experimental_allow_proto3_optional
--go_out
=
$(
DSTDIR
)
--go-grpc_out
=
$(
DSTDIR
)
--go_opt
=
paths
=
source_relative
--go-grpc_opt
=
paths
=
source_relative
"
$<
"
@
protoc
-I
=
$(
PROTODIR
)
--experimental_allow_proto3_optional
\
--proto_path
=
$(
GOOGLEAPIS_PATH
)
\
--go_out
=
$(
DSTDIR
)
\
--go-grpc_out
=
$(
DSTDIR
)
\
--go_opt
=
paths
=
source_relative
\
--go-grpc_opt
=
paths
=
source_relative
"
$<
"
# Генерация gateway
gateway
:
$(PROTOGOGWFILES)
@
echo
"Generate gRPC-Gateway"
@
find
$(
PROTODIR
)
-name
'*.proto'
%.gw.go
:
%.proto
@
protoc
-I
=
$(
PROTODIR
)
--experimental_allow_proto3_optional
\
--proto_path
=
$(
GOOGLEAPIS_PATH
)
\
--grpc-gateway_out
=
$(
DSTDIR
)
\
--grpc-gateway_opt
=
paths
=
source_relative
\
--grpc-gateway_opt
=
standalone
=
true
\
--grpc-gateway_opt
=
generate_unbound_methods
=
true
"
$<
"
# Генерация swagger/OpenAPI
swagger
:
$(PROTOSWAGGERFILES)
@
echo
"Generate OpenAPI/Swagger docs"
@
find
$(
PROTODIR
)
-name
'*.proto'
%.swagger.json
:
%.proto
@
protoc
-I
=
$(
PROTODIR
)
--experimental_allow_proto3_optional
\
--proto_path
=
$(
GOOGLEAPIS_PATH
)
\
--openapiv2_out
=
$(
DSTDIR
)
"
$<
"
proto-clean
:
@
rm
-r
$(
DSTDIR
)
/
*
...
...
This diff is collapsed.
Click to expand it.
Taskfile.yaml
+
38
−
1
View file @
4cbc3b21
...
...
@@ -5,6 +5,8 @@ vars:
PBDIR
:
proto
DATE
:
sh
:
date -Idate
GOOGLEAPIS_PATH
:
sh
:
find ~/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@* -type d -name googleapis | head -n
1
tasks
:
tools:brew
:
...
...
@@ -17,6 +19,8 @@ tasks:
-
brew install mockery
-
brew install protoc-gen-go
-
brew install protoc-gen-go-grpc
-
brew install protoc-gen-grpc-gateway
-
brew install protoc-gen-openapiv2
# Тесты
...
...
@@ -136,8 +140,41 @@ tasks:
gen:proto:file
:
desc
:
"
Преобразует
переданный
.proto
файл
в
код
на
языке
Go
для
работы
с
сообщениями
protobuf
и
сервисами
gRPC."
cmds
:
-
protoc -I={{ .PROTODIR }} --experimental_allow_proto3_optional --go_out={{ .PBDIR }} --go-grpc_out={{ .PBDIR }} --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative {{ .FILE }}
-
protoc -I={{ .PROTODIR }}
--proto_path={{ .GOOGLEAPIS_PATH }}
--experimental_allow_proto3_optional --go_out={{ .PBDIR }} --go-grpc_out={{ .PBDIR }} --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative {{ .FILE }}
gen:gateway
:
desc
:
"
Генерирует
gRPC-Gateway
код
для
всех
.proto
файлов"
sources
:
-
"
{{
.PROTODIR
}}/**/*.proto"
-
exclude
:
"
{{
.PROTODIR
}}/status/status.proto"
cmds
:
-
for
:
sources
task
:
gen:gateway:file
vars
:
FILE
:
"
{{
.ITEM
}}"
silent
:
true
gen:gateway:file
:
desc
:
"
Генерирует
gRPC-Gateway
код
для
переданного
.proto
файла"
cmds
:
-
protoc -I={{ .PROTODIR }} --proto_path={{ .GOOGLEAPIS_PATH }} --experimental_allow_proto3_optional --grpc-gateway_out={{ .PBDIR }} --grpc-gateway_opt=paths=source_relative --grpc-gateway_opt=standalone=true --grpc-gateway_opt=generate_unbound_methods=true {{ .FILE }}
gen:swagger
:
desc
:
"
Генерирует
OpenAPI/Swagger
документацию
для
всех
.proto
файлов"
sources
:
-
"
{{
.PROTODIR
}}/**/*.proto"
-
exclude
:
"
{{
.PROTODIR
}}/status/status.proto"
cmds
:
-
for
:
sources
task
:
gen:swagger:file
vars
:
FILE
:
"
{{
.ITEM
}}"
silent
:
true
gen:swagger:file
:
desc
:
"
Генерирует
OpenAPI/Swagger
JSON
для
переданного
.proto
файла"
cmds
:
-
protoc -I={{ .PROTODIR }} --proto_path={{ .GOOGLEAPIS_PATH }} --experimental_allow_proto3_optional --openapiv2_out={{ .PBDIR }} {{ .FILE }}
gen:middleware
:
desc
:
"
Генерирует
middleware
для
всех
пакетов"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment