Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] kitgen code generation #308

Closed
wants to merge 1 commit into from
Closed

[WIP] kitgen code generation #308

wants to merge 1 commit into from

Conversation

peterbourgon
Copy link
Member

@peterbourgon peterbourgon commented Jul 3, 2016

The idea is to kitgen path/to/some.go, have it parse out a type Service interface, and generate

  • service.go: a no-op implementation: type dummyService struct{} + all methods
  • endpoints.go: request and response structs, plus endpoint constructors, for each method
  • transport.go: one or more default transport bindings

Ideally, also

  • middlewares.go: with default logging and instrumenting middlewares
  • client/client.go: a skeleton for a client package
  • cmd/mysvc/main.go: a skeleton main.go

So far

  • Parsing path/to/some.go and extracting declarations
  • Template and codegen for service.go
  • Template and codegen for endpoints.go
  • Template and codegen for transport.go (should have flags for different transports)
  • Template and codegen for middlewares.go
  • Template and codegen for client/client.go
  • Template and codegen for cmd/mysvc/main.go (should figure out how to name the thing better)
  • Properly tested :)

@Morgahl
Copy link

Morgahl commented Jul 3, 2016

Quite a bit of thought has gone into the following package by Ayiga (Theodore on the Gopher's Slack)

https://github.com/Ayiga/go-kit-middlewarer

I'm using it quite successfully in my own environment currently.

@peterbourgon
Copy link
Member Author

@curlymon Yep! I'm aware; I'll probably end up using a lot of that stuff verbatim. I just need to explore the space a little on my own, first.

@Morgahl
Copy link

Morgahl commented Jul 3, 2016 via email

@germanvazquez-rfk
Copy link

@peterbourgon was you able to make any progress on this?

@peterbourgon
Copy link
Member Author

It's next in the queue. I don't have an ETA.

@cihangir
Copy link
Contributor

Hi, i have started a project a while back ago and i am generating code for go-kit. You can see an example service here

Everything under example folder, generated from this json schema

Only implementation of business logic should go under service. Code is generated and left with defaults to developer.

It also generates JS client, go client lib, database DDL for postgres and other bunch of stuff that some of them are not directly related with go-kit

I would love to help on the implementation of kitgen.

@peterbourgon
Copy link
Member Author

@cihangir Yes, I've seen it, and I thank you for that work :) I've been studying it as I go along. My needs are considerably simpler, at least to start, and are enumerated in the top of the issue. If you want to discuss how to contribute here, please drop by Gophers Slack #gokit and we can figure something out! :)

@hasAdamr
Copy link

hasAdamr commented Nov 4, 2016

Hi, I also have been working on a Go-kit service generator called Truss.

You run truss on protobuf files with a grpc service and it will generate a service using the .pb.go structs as the service input and output structs. You can also add http annotations to get http transport with query, path, and json body support.

Let me know what you think, and thanks so much for starting Go-kit to make this possible.

@peterbourgon
Copy link
Member Author

I'm afraid this work will need to be rebooted if/when I'm able to start it up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants