Skip to content

Instantly share code, notes, and snippets.

@dghubble
Last active December 29, 2015 00:38
Show Gist options
  • Save dghubble/7586922 to your computer and use it in GitHub Desktop.
Save dghubble/7586922 to your computer and use it in GitHub Desktop.
Echoer generated Go code (go-thrift with -go.rpcstyle=true option)
// This file is automatically generated. Do not modify.
package echoer_thrift
type EchoArgs struct {
Message string `thrift:"1,required" json:"Message"`
}
type EchoReply struct {
Echo string `thrift:"1,required" json:"Echo"`
}
type MultiplyArgs struct {
A int64 `thrift:"1,required" json:"A"`
B int64 `thrift:"2,required" json:"B"`
}
type MultiplyReply struct {
Product int64 `thrift:"1,required" json:"Product"`
Error string `thrift:"2,required" json:"Error"`
}
type RPCClient interface {
Call(method string, request interface{}, response interface{}) error
}
type EchoerThrift interface {
Echo(argz *EchoArgs, reply *EchoReply) error
Multiply(argz *MultiplyArgs, reply *MultiplyReply) error
}
type EchoerThriftServer struct {
Implementation EchoerThrift
}
func (s *EchoerThriftServer) Echo(req *EchoerThriftEchoRequest, res *EchoerThriftEchoResponse) error {
res.Value = new(EchoReply)
err := s.Implementation.Echo(req.Argz, res.Value)
return err
}
func (s *EchoerThriftServer) Multiply(req *EchoerThriftMultiplyRequest, res *EchoerThriftMultiplyResponse) error {
res.Value = new(MultiplyReply)
err := s.Implementation.Multiply(req.Argz, res.Value)
return err
}
type EchoerThriftEchoRequest struct {
Argz *EchoArgs `thrift:"1,required" json:"argz"`
}
type EchoerThriftEchoResponse struct {
Value *EchoReply `thrift:"0,required" json:"value"`
}
type EchoerThriftMultiplyRequest struct {
Argz *MultiplyArgs `thrift:"1,required" json:"argz"`
}
type EchoerThriftMultiplyResponse struct {
Value *MultiplyReply `thrift:"0,required" json:"value"`
}
type EchoerThriftClient struct {
Client RPCClient
}
func (s *EchoerThriftClient) Echo(argz *EchoArgs, reply *EchoReply) error {
req := &EchoerThriftEchoRequest{
Argz: argz,
}
res := &EchoerThriftEchoResponse{Value: reply}
err := s.Client.Call("Echo", req, res)
return err
}
func (s *EchoerThriftClient) Multiply(argz *MultiplyArgs, reply *MultiplyReply) error {
req := &EchoerThriftMultiplyRequest{
Argz: argz,
}
res := &EchoerThriftMultiplyResponse{Value: reply}
err := s.Client.Call("Multiply", req, res)
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment