Comments (5)
Now, this cmd will gen
/pb
dir to /pkg/grpc:kit g s hello -t grpc
but sometimes, put
pb
dir in root dir of project is a common practice.
so, could I ask you to add a flag to specify the location of thepb
directory? thanks in advance.
Hello, thanks for your suggestion. The go-kit should support some transport protocols, such http , grpc, thrift and so on. So, putting pb dir in root dir of project is not a better way for the project generated by kit, I think :)
from kit.
The go-kit should support some transport protocols, such http , grpc, thrift and so on.
That is surely right.
I mean provide a new flag --pb_path
specify pb path only works when transport is grpc, Isn't it have to be more flexible?
And, In order to improve efficiency, in the last two hours, I have basically completed the update of this function. Just see effects below:
$ kit g service hello -t grpc --help
Initiate a service
Usage:
kit generate service [flags]
Aliases:
service, s
Flags:
-w, --dmw Generate default middleware for service and endpoint
--endpoint-mdw If set a default Logging and Tracking middleware will be created and attached to the endpoint
--gorilla Generate http using gorilla mux
-h, --help help for service
-m, --methods stringArray Specify methods to be generated
-p, --pb_path string The path of pb dir store <-------------------------------------
--svc-mdw If set a default Logging and Instrumental middleware will be created and attached to the service
-t, --transport string The transport you want your service to be initiated with (default "http")
Global Flags:
-d, --debug If you want to see the debug logs.
-b, --folder string If you want to specify the base folder of the project.
-f, --force Force overide existing files without asking.
Use --pb_path
or -p
:
kit g service hello -t grpc -p hello/
This will do:
Create pb dir in the hello/
, this is relatively path to root dir of hello project;
surely, absolute path is supported.
If --pb_path
or -p
not provided, there will put pb
dir in /pkg/grpc
, just as old.
Thanks to read :)
from kit.
If a team choosed gRPC as their rpc method, then they don't care about HTTP or other RPC methods,
So it is very important to choose the path to the pb
directory.
from kit.
The go-kit should support some transport protocols, such http , grpc, thrift and so on.
That is surely right.
I mean provide a new flag--pb_path
specify pb path only works when transport is grpc, Isn't it have to be more flexible?And, In order to improve efficiency, in the last two hours, I have basically completed the update of this function. Just see effects below:
$ kit g service hello -t grpc --help Initiate a service Usage: kit generate service [flags] Aliases: service, s Flags: -w, --dmw Generate default middleware for service and endpoint --endpoint-mdw If set a default Logging and Tracking middleware will be created and attached to the endpoint --gorilla Generate http using gorilla mux -h, --help help for service -m, --methods stringArray Specify methods to be generated -p, --pb_path string The path of pb dir store <------------------------------------- --svc-mdw If set a default Logging and Instrumental middleware will be created and attached to the service -t, --transport string The transport you want your service to be initiated with (default "http") Global Flags: -d, --debug If you want to see the debug logs. -b, --folder string If you want to specify the base folder of the project. -f, --force Force overide existing files without asking.
Use
--pb_path
or-p
:kit g service hello -t grpc -p hello/
This will do:
Create pb dir in thehello/
, this is relatively path to root dir of hello project;
surely, absolute path is supported.If
--pb_path
or-p
not provided, there will putpb
dir in/pkg/grpc
, just as old.Thanks to read :)
That is a good job ! ๐ Could you submit a PR for it ? :)
from kit.
If developer provides a valid pa path by flag --pb_path
, he has to provide pb import path by flag --pb_import_path
, Because the path to import pb will so difficult to determinate at that time, so it only be pass it by flag directly.
Usage
$ kit g s --help
Initiate a service
Usage:
kit generate service [flags]
Aliases:
service, s
Flags:
(ignored some flags...)
-i, --pb_import_path string Specify path to import pb
-p, --pb_path string Specify path to store pb dir
-t, --transport string The transport you want your service to be initiated with (default "http")
(ignored global flags...)
Use this two flags(--pb_path
must be with --pb_import_path
):
$pwd
/root/kit
$kit n s hello
# create a service method, then continue
$kit g s hello -t grpc -p hello -i hello/pb
Check generated structure:
[root@localhost kit]# tree hello/
hello/
โโโ cmd
โย ย โโโ main.go
โย ย โโโ service
โย ย โโโ service_gen.go
โย ย โโโ service.go
โโโ go.mod
โโโ pb <------------------------- pb dir be here now, instead of /pkg/grpc/pb
โย ย โโโ compile.sh
โย ย โโโ hello.pb.go
โย ย โโโ hello.proto
โโโ pkg
โโโ endpoint
โย ย โโโ endpoint_gen.go
โย ย โโโ endpoint.go
โโโ grpc
โย ย โโโ handler_gen.go <------ `hello/pb` will be used as pb import path
โย ย โโโ handler.go <------ `hello/pb` will be used as pb import path
โโโ service
โโโ middleware.go
โโโ service.go
7 directories, 13 files
Then generate client file:
$kit g c hello -t grpc -i hello/pb
Check generated client dir structure:
[root@localhost kit]# tree hello/client/
hello/client/
โโโ grpc
โโโ grpc.go <------ `hello/pb` will be used as pb import path
Thanks.
from kit.
Related Issues (20)
- A typo HOT 1
- Why not encode/decode endpoint req&rsp as a pointer type? HOT 3
- real life files structure HOT 3
- Does the tool require an operating system? HOT 3
- Incorect import when using go modules with full project name HOT 2
- ERRO[0000] exit status 1 HOT 4
- ERRO[0000] exit status 1 HOT 20
- what does stringArray mean? HOT 4
- New a service with snake case name inccluding - but output is _ HOT 1
- choose a protoc-gen-go version HOT 1
- translate README.md to Chinese
- hello, there are some bugs when I used "kit g s hello --dmw" command. HOT 7
- ๅฐๆ็ซ ็งป่ณ้กน็ฎๅ ็ปดๆค HOT 3
- I am new to go and would like to understand what the _gen files are for?
- Crashed when running command "docker-compose up" HOT 2
- Issue for creating one gRPC service as client for other gRPC service
- how to use http get method in http/handler
- command not found: kit HOT 1
- Add support to generate from .proto only
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kit.