README ¶
Proteus examples
This example shows how to use proteus for a typical use case. Imagine you have your Go models and you need to generate some .proto
files to match that models.
It has some entities like the ones you could have on a database.
To generate the .proto
you can use the proteus
binary:
proteus proto -p github.com/src-d/proteus/example \
-f $GOPATH/src/github.com/src-d/proteus/example/protos \
--verbose
The generated file will be in:
$GOPATH/src/github.com/src-d/proteus/example/protos/github.com/proteus/example/generated.proto
You can also use make regenerate
Documentation ¶
Overview ¶
Package example is a generated protocol buffer package.
It is generated from these files:
gopkg.in/src-d/proteus.v1/example/protos/gopkg.in/src-d/proteus.v1/example/generated.proto
It has these top-level messages:
Category MyDuration MyTime Price Product GetAlphaTimeRequest GetDurationForLengthRequest GetDurationForLengthCtxRequest GetOmegaTimeRequest GetPhoneRequest RandomCategoryRequest RandomNumberRequest RandomNumberResponse
Index ¶
- Variables
- func NewExampleServiceServer() *exampleServiceServer
- func RandomBool() bool
- func RandomCategory() categories.CategoryOptions
- func RandomNumber(mean, std float64) float64
- func RegisterExampleServiceServer(s *grpc.Server, srv ExampleServiceServer)
- type Category
- func (*Category) Descriptor() ([]byte, []int)
- func (m *Category) Marshal() (dAtA []byte, err error)
- func (m *Category) MarshalTo(dAtA []byte) (int, error)
- func (*Category) ProtoMessage()
- func (m *Category) ProtoSize() (n int)
- func (m *Category) Reset()
- func (c *Category) String() string
- func (m *Category) Unmarshal(dAtA []byte) error
- type Color
- type ExampleServiceClient
- type ExampleServiceServer
- type GetAlphaTimeRequest
- func (*GetAlphaTimeRequest) Descriptor() ([]byte, []int)
- func (m *GetAlphaTimeRequest) Marshal() (dAtA []byte, err error)
- func (m *GetAlphaTimeRequest) MarshalTo(dAtA []byte) (int, error)
- func (*GetAlphaTimeRequest) ProtoMessage()
- func (m *GetAlphaTimeRequest) ProtoSize() (n int)
- func (m *GetAlphaTimeRequest) Reset()
- func (m *GetAlphaTimeRequest) String() string
- func (m *GetAlphaTimeRequest) Unmarshal(dAtA []byte) error
- type GetDurationForLengthCtxRequest
- func (*GetDurationForLengthCtxRequest) Descriptor() ([]byte, []int)
- func (m *GetDurationForLengthCtxRequest) GetArg1() int64
- func (m *GetDurationForLengthCtxRequest) Marshal() (dAtA []byte, err error)
- func (m *GetDurationForLengthCtxRequest) MarshalTo(dAtA []byte) (int, error)
- func (*GetDurationForLengthCtxRequest) ProtoMessage()
- func (m *GetDurationForLengthCtxRequest) ProtoSize() (n int)
- func (m *GetDurationForLengthCtxRequest) Reset()
- func (m *GetDurationForLengthCtxRequest) String() string
- func (m *GetDurationForLengthCtxRequest) Unmarshal(dAtA []byte) error
- type GetDurationForLengthRequest
- func (*GetDurationForLengthRequest) Descriptor() ([]byte, []int)
- func (m *GetDurationForLengthRequest) GetArg1() int64
- func (m *GetDurationForLengthRequest) Marshal() (dAtA []byte, err error)
- func (m *GetDurationForLengthRequest) MarshalTo(dAtA []byte) (int, error)
- func (*GetDurationForLengthRequest) ProtoMessage()
- func (m *GetDurationForLengthRequest) ProtoSize() (n int)
- func (m *GetDurationForLengthRequest) Reset()
- func (m *GetDurationForLengthRequest) String() string
- func (m *GetDurationForLengthRequest) Unmarshal(dAtA []byte) error
- type GetOmegaTimeRequest
- func (*GetOmegaTimeRequest) Descriptor() ([]byte, []int)
- func (m *GetOmegaTimeRequest) Marshal() (dAtA []byte, err error)
- func (m *GetOmegaTimeRequest) MarshalTo(dAtA []byte) (int, error)
- func (*GetOmegaTimeRequest) ProtoMessage()
- func (m *GetOmegaTimeRequest) ProtoSize() (n int)
- func (m *GetOmegaTimeRequest) Reset()
- func (m *GetOmegaTimeRequest) String() string
- func (m *GetOmegaTimeRequest) Unmarshal(dAtA []byte) error
- type GetPhoneRequest
- func (*GetPhoneRequest) Descriptor() ([]byte, []int)
- func (m *GetPhoneRequest) Marshal() (dAtA []byte, err error)
- func (m *GetPhoneRequest) MarshalTo(dAtA []byte) (int, error)
- func (*GetPhoneRequest) ProtoMessage()
- func (m *GetPhoneRequest) ProtoSize() (n int)
- func (m *GetPhoneRequest) Reset()
- func (m *GetPhoneRequest) String() string
- func (m *GetPhoneRequest) Unmarshal(dAtA []byte) error
- type Model
- type MyDuration
- func (*MyDuration) Descriptor() ([]byte, []int)
- func (m *MyDuration) Marshal() (dAtA []byte, err error)
- func (m *MyDuration) MarshalTo(dAtA []byte) (int, error)
- func (*MyDuration) ProtoMessage()
- func (m *MyDuration) ProtoSize() (n int)
- func (m *MyDuration) Reset()
- func (m *MyDuration) String() string
- func (m *MyDuration) Unmarshal(dAtA []byte) error
- type MyTime
- func (*MyTime) Descriptor() ([]byte, []int)
- func (m *MyTime) Marshal() (dAtA []byte, err error)
- func (m *MyTime) MarshalTo(dAtA []byte) (int, error)
- func (*MyTime) ProtoMessage()
- func (m *MyTime) ProtoSize() (n int)
- func (m *MyTime) Reset()
- func (m *MyTime) String() string
- func (m *MyTime) Unmarshal(dAtA []byte) error
- type Price
- func (*Price) Descriptor() ([]byte, []int)
- func (m *Price) Marshal() (dAtA []byte, err error)
- func (m *Price) MarshalTo(dAtA []byte) (int, error)
- func (*Price) ProtoMessage()
- func (m *Price) ProtoSize() (n int)
- func (m *Price) Reset()
- func (m *Price) String() string
- func (m *Price) Unmarshal(dAtA []byte) error
- type Prices
- type Product
- func (*Product) Descriptor() ([]byte, []int)
- func (m *Product) Marshal() (dAtA []byte, err error)
- func (m *Product) MarshalTo(dAtA []byte) (int, error)
- func (*Product) ProtoMessage()
- func (m *Product) ProtoSize() (n int)
- func (m *Product) Reset()
- func (m *Product) String() string
- func (m *Product) Unmarshal(dAtA []byte) error
- type RandomCategoryRequest
- func (*RandomCategoryRequest) Descriptor() ([]byte, []int)
- func (m *RandomCategoryRequest) Marshal() (dAtA []byte, err error)
- func (m *RandomCategoryRequest) MarshalTo(dAtA []byte) (int, error)
- func (*RandomCategoryRequest) ProtoMessage()
- func (m *RandomCategoryRequest) ProtoSize() (n int)
- func (m *RandomCategoryRequest) Reset()
- func (m *RandomCategoryRequest) String() string
- func (m *RandomCategoryRequest) Unmarshal(dAtA []byte) error
- type RandomNumberRequest
- func (*RandomNumberRequest) Descriptor() ([]byte, []int)
- func (m *RandomNumberRequest) GetArg1() float64
- func (m *RandomNumberRequest) GetArg2() float64
- func (m *RandomNumberRequest) Marshal() (dAtA []byte, err error)
- func (m *RandomNumberRequest) MarshalTo(dAtA []byte) (int, error)
- func (*RandomNumberRequest) ProtoMessage()
- func (m *RandomNumberRequest) ProtoSize() (n int)
- func (m *RandomNumberRequest) Reset()
- func (m *RandomNumberRequest) String() string
- func (m *RandomNumberRequest) Unmarshal(dAtA []byte) error
- type RandomNumberResponse
- func (*RandomNumberResponse) Descriptor() ([]byte, []int)
- func (m *RandomNumberResponse) GetResult1() float64
- func (m *RandomNumberResponse) Marshal() (dAtA []byte, err error)
- func (m *RandomNumberResponse) MarshalTo(dAtA []byte) (int, error)
- func (*RandomNumberResponse) ProtoMessage()
- func (m *RandomNumberResponse) ProtoSize() (n int)
- func (m *RandomNumberResponse) Reset()
- func (m *RandomNumberResponse) String() string
- func (m *RandomNumberResponse) Unmarshal(dAtA []byte) error
- type Tags
- type Type
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") )
View Source
var Type_name = map[int32]string{
0: "PUBLIC",
1: "PRIVATE",
2: "CUSTOM",
}
Type will be transformed into an enum.
View Source
var Type_value = map[string]int32{
"PUBLIC": 0,
"PRIVATE": 1,
"CUSTOM": 2,
}
Functions ¶
func NewExampleServiceServer ¶
func NewExampleServiceServer() *exampleServiceServer
func RandomBool ¶
func RandomBool() bool
func RandomCategory ¶
func RandomCategory() categories.CategoryOptions
func RandomNumber ¶
func RegisterExampleServiceServer ¶
func RegisterExampleServiceServer(s *grpc.Server, srv ExampleServiceServer)
Types ¶
type Category ¶
type Category struct { Model Name string Type Type Color Color Options categories.CategoryOptions }
func (*Category) Descriptor ¶
func (*Category) ProtoMessage ¶
func (*Category) ProtoMessage()
type Color ¶
type Color string
Color does not have proteus:generate in a comment, so all fields of type Color will be treated as just string, not as an enum.
type ExampleServiceClient ¶
type ExampleServiceClient interface { GetAlphaTime(ctx context.Context, in *GetAlphaTimeRequest, opts ...grpc.CallOption) (*MyTime, error) GetDurationForLength(ctx context.Context, in *GetDurationForLengthRequest, opts ...grpc.CallOption) (*MyDuration, error) GetDurationForLengthCtx(ctx context.Context, in *GetDurationForLengthCtxRequest, opts ...grpc.CallOption) (*MyDuration, error) GetOmegaTime(ctx context.Context, in *GetOmegaTimeRequest, opts ...grpc.CallOption) (*MyTime, error) GetPhone(ctx context.Context, in *GetPhoneRequest, opts ...grpc.CallOption) (*Product, error) RandomCategory(ctx context.Context, in *RandomCategoryRequest, opts ...grpc.CallOption) (*gopkg_in_srcd_proteus_v1_example_categories.CategoryOptions, error) RandomNumber(ctx context.Context, in *RandomNumberRequest, opts ...grpc.CallOption) (*RandomNumberResponse, error) }
func NewExampleServiceClient ¶
func NewExampleServiceClient(cc *grpc.ClientConn) ExampleServiceClient
type ExampleServiceServer ¶
type ExampleServiceServer interface { GetAlphaTime(context.Context, *GetAlphaTimeRequest) (*MyTime, error) GetDurationForLength(context.Context, *GetDurationForLengthRequest) (*MyDuration, error) GetDurationForLengthCtx(context.Context, *GetDurationForLengthCtxRequest) (*MyDuration, error) GetOmegaTime(context.Context, *GetOmegaTimeRequest) (*MyTime, error) GetPhone(context.Context, *GetPhoneRequest) (*Product, error) RandomCategory(context.Context, *RandomCategoryRequest) (*gopkg_in_srcd_proteus_v1_example_categories.CategoryOptions, error) RandomNumber(context.Context, *RandomNumberRequest) (*RandomNumberResponse, error) }
type GetAlphaTimeRequest ¶
type GetAlphaTimeRequest struct { }
func (*GetAlphaTimeRequest) Descriptor ¶
func (*GetAlphaTimeRequest) Descriptor() ([]byte, []int)
func (*GetAlphaTimeRequest) Marshal ¶
func (m *GetAlphaTimeRequest) Marshal() (dAtA []byte, err error)
func (*GetAlphaTimeRequest) MarshalTo ¶
func (m *GetAlphaTimeRequest) MarshalTo(dAtA []byte) (int, error)
func (*GetAlphaTimeRequest) ProtoMessage ¶
func (*GetAlphaTimeRequest) ProtoMessage()
func (*GetAlphaTimeRequest) ProtoSize ¶ added in v1.3.0
func (m *GetAlphaTimeRequest) ProtoSize() (n int)
func (*GetAlphaTimeRequest) Reset ¶
func (m *GetAlphaTimeRequest) Reset()
func (*GetAlphaTimeRequest) String ¶
func (m *GetAlphaTimeRequest) String() string
func (*GetAlphaTimeRequest) Unmarshal ¶
func (m *GetAlphaTimeRequest) Unmarshal(dAtA []byte) error
type GetDurationForLengthCtxRequest ¶ added in v1.3.3
type GetDurationForLengthCtxRequest struct {
Arg1 int64 `protobuf:"varint,1,opt,name=arg1,proto3" json:"arg1,omitempty"`
}
func (*GetDurationForLengthCtxRequest) Descriptor ¶ added in v1.3.3
func (*GetDurationForLengthCtxRequest) Descriptor() ([]byte, []int)
func (*GetDurationForLengthCtxRequest) GetArg1 ¶ added in v1.3.3
func (m *GetDurationForLengthCtxRequest) GetArg1() int64
func (*GetDurationForLengthCtxRequest) Marshal ¶ added in v1.3.3
func (m *GetDurationForLengthCtxRequest) Marshal() (dAtA []byte, err error)
func (*GetDurationForLengthCtxRequest) MarshalTo ¶ added in v1.3.3
func (m *GetDurationForLengthCtxRequest) MarshalTo(dAtA []byte) (int, error)
func (*GetDurationForLengthCtxRequest) ProtoMessage ¶ added in v1.3.3
func (*GetDurationForLengthCtxRequest) ProtoMessage()
func (*GetDurationForLengthCtxRequest) ProtoSize ¶ added in v1.3.3
func (m *GetDurationForLengthCtxRequest) ProtoSize() (n int)
func (*GetDurationForLengthCtxRequest) Reset ¶ added in v1.3.3
func (m *GetDurationForLengthCtxRequest) Reset()
func (*GetDurationForLengthCtxRequest) String ¶ added in v1.3.3
func (m *GetDurationForLengthCtxRequest) String() string
func (*GetDurationForLengthCtxRequest) Unmarshal ¶ added in v1.3.3
func (m *GetDurationForLengthCtxRequest) Unmarshal(dAtA []byte) error
type GetDurationForLengthRequest ¶ added in v1.2.0
type GetDurationForLengthRequest struct {
Arg1 int64 `protobuf:"varint,1,opt,name=arg1,proto3" json:"arg1,omitempty"`
}
func (*GetDurationForLengthRequest) Descriptor ¶ added in v1.2.0
func (*GetDurationForLengthRequest) Descriptor() ([]byte, []int)
func (*GetDurationForLengthRequest) GetArg1 ¶ added in v1.2.0
func (m *GetDurationForLengthRequest) GetArg1() int64
func (*GetDurationForLengthRequest) Marshal ¶ added in v1.2.0
func (m *GetDurationForLengthRequest) Marshal() (dAtA []byte, err error)
func (*GetDurationForLengthRequest) MarshalTo ¶ added in v1.2.0
func (m *GetDurationForLengthRequest) MarshalTo(dAtA []byte) (int, error)
func (*GetDurationForLengthRequest) ProtoMessage ¶ added in v1.2.0
func (*GetDurationForLengthRequest) ProtoMessage()
func (*GetDurationForLengthRequest) ProtoSize ¶ added in v1.3.0
func (m *GetDurationForLengthRequest) ProtoSize() (n int)
func (*GetDurationForLengthRequest) Reset ¶ added in v1.2.0
func (m *GetDurationForLengthRequest) Reset()
func (*GetDurationForLengthRequest) String ¶ added in v1.2.0
func (m *GetDurationForLengthRequest) String() string
func (*GetDurationForLengthRequest) Unmarshal ¶ added in v1.2.0
func (m *GetDurationForLengthRequest) Unmarshal(dAtA []byte) error
type GetOmegaTimeRequest ¶
type GetOmegaTimeRequest struct { }
func (*GetOmegaTimeRequest) Descriptor ¶
func (*GetOmegaTimeRequest) Descriptor() ([]byte, []int)
func (*GetOmegaTimeRequest) Marshal ¶
func (m *GetOmegaTimeRequest) Marshal() (dAtA []byte, err error)
func (*GetOmegaTimeRequest) MarshalTo ¶
func (m *GetOmegaTimeRequest) MarshalTo(dAtA []byte) (int, error)
func (*GetOmegaTimeRequest) ProtoMessage ¶
func (*GetOmegaTimeRequest) ProtoMessage()
func (*GetOmegaTimeRequest) ProtoSize ¶ added in v1.3.0
func (m *GetOmegaTimeRequest) ProtoSize() (n int)
func (*GetOmegaTimeRequest) Reset ¶
func (m *GetOmegaTimeRequest) Reset()
func (*GetOmegaTimeRequest) String ¶
func (m *GetOmegaTimeRequest) String() string
func (*GetOmegaTimeRequest) Unmarshal ¶
func (m *GetOmegaTimeRequest) Unmarshal(dAtA []byte) error
type GetPhoneRequest ¶
type GetPhoneRequest struct { }
func (*GetPhoneRequest) Descriptor ¶
func (*GetPhoneRequest) Descriptor() ([]byte, []int)
func (*GetPhoneRequest) Marshal ¶
func (m *GetPhoneRequest) Marshal() (dAtA []byte, err error)
func (*GetPhoneRequest) ProtoMessage ¶
func (*GetPhoneRequest) ProtoMessage()
func (*GetPhoneRequest) ProtoSize ¶ added in v1.3.0
func (m *GetPhoneRequest) ProtoSize() (n int)
func (*GetPhoneRequest) Reset ¶
func (m *GetPhoneRequest) Reset()
func (*GetPhoneRequest) String ¶
func (m *GetPhoneRequest) String() string
func (*GetPhoneRequest) Unmarshal ¶
func (m *GetPhoneRequest) Unmarshal(dAtA []byte) error
type MyDuration ¶ added in v1.2.0
func GetDurationForLength ¶ added in v1.2.0
func GetDurationForLength(meters int64) *MyDuration
func GetDurationForLengthCtx ¶ added in v1.3.3
func GetDurationForLengthCtx(ctx context.Context, meters int64) (*MyDuration, error)
func (*MyDuration) Descriptor ¶ added in v1.2.0
func (*MyDuration) Descriptor() ([]byte, []int)
func (*MyDuration) Marshal ¶ added in v1.2.0
func (m *MyDuration) Marshal() (dAtA []byte, err error)
func (*MyDuration) MarshalTo ¶ added in v1.2.0
func (m *MyDuration) MarshalTo(dAtA []byte) (int, error)
func (*MyDuration) ProtoMessage ¶ added in v1.2.0
func (*MyDuration) ProtoMessage()
func (*MyDuration) ProtoSize ¶ added in v1.3.0
func (m *MyDuration) ProtoSize() (n int)
func (*MyDuration) Reset ¶ added in v1.2.0
func (m *MyDuration) Reset()
func (*MyDuration) String ¶ added in v1.2.0
func (m *MyDuration) String() string
func (*MyDuration) Unmarshal ¶ added in v1.2.0
func (m *MyDuration) Unmarshal(dAtA []byte) error
type MyTime ¶
func GetAlphaTime ¶
func GetAlphaTime() MyTime
func GetOmegaTime ¶
func (*MyTime) Descriptor ¶
func (*MyTime) ProtoMessage ¶
func (*MyTime) ProtoMessage()
type Price ¶ added in v1.3.1
func (*Price) Descriptor ¶ added in v1.3.1
func (*Price) ProtoMessage ¶ added in v1.3.1
func (*Price) ProtoMessage()
type Product ¶
type Product struct { Model Name string Price Prices Tags Tags CategoryID int64 PrimaryCategoryID int8 // Category will not be generated because we explicitly said so. Category Category `proteus:"-"` }
func (*Product) Descriptor ¶
func (*Product) ProtoMessage ¶
func (*Product) ProtoMessage()
type RandomCategoryRequest ¶
type RandomCategoryRequest struct { }
func (*RandomCategoryRequest) Descriptor ¶
func (*RandomCategoryRequest) Descriptor() ([]byte, []int)
func (*RandomCategoryRequest) Marshal ¶
func (m *RandomCategoryRequest) Marshal() (dAtA []byte, err error)
func (*RandomCategoryRequest) MarshalTo ¶
func (m *RandomCategoryRequest) MarshalTo(dAtA []byte) (int, error)
func (*RandomCategoryRequest) ProtoMessage ¶
func (*RandomCategoryRequest) ProtoMessage()
func (*RandomCategoryRequest) ProtoSize ¶ added in v1.3.0
func (m *RandomCategoryRequest) ProtoSize() (n int)
func (*RandomCategoryRequest) Reset ¶
func (m *RandomCategoryRequest) Reset()
func (*RandomCategoryRequest) String ¶
func (m *RandomCategoryRequest) String() string
func (*RandomCategoryRequest) Unmarshal ¶
func (m *RandomCategoryRequest) Unmarshal(dAtA []byte) error
type RandomNumberRequest ¶
type RandomNumberRequest struct { Arg1 float64 `protobuf:"fixed64,1,opt,name=arg1,proto3" json:"arg1,omitempty"` Arg2 float64 `protobuf:"fixed64,2,opt,name=arg2,proto3" json:"arg2,omitempty"` }
func (*RandomNumberRequest) Descriptor ¶
func (*RandomNumberRequest) Descriptor() ([]byte, []int)
func (*RandomNumberRequest) GetArg1 ¶
func (m *RandomNumberRequest) GetArg1() float64
func (*RandomNumberRequest) GetArg2 ¶
func (m *RandomNumberRequest) GetArg2() float64
func (*RandomNumberRequest) Marshal ¶
func (m *RandomNumberRequest) Marshal() (dAtA []byte, err error)
func (*RandomNumberRequest) MarshalTo ¶
func (m *RandomNumberRequest) MarshalTo(dAtA []byte) (int, error)
func (*RandomNumberRequest) ProtoMessage ¶
func (*RandomNumberRequest) ProtoMessage()
func (*RandomNumberRequest) ProtoSize ¶ added in v1.3.0
func (m *RandomNumberRequest) ProtoSize() (n int)
func (*RandomNumberRequest) Reset ¶
func (m *RandomNumberRequest) Reset()
func (*RandomNumberRequest) String ¶
func (m *RandomNumberRequest) String() string
func (*RandomNumberRequest) Unmarshal ¶
func (m *RandomNumberRequest) Unmarshal(dAtA []byte) error
type RandomNumberResponse ¶
type RandomNumberResponse struct {
Result1 float64 `protobuf:"fixed64,1,opt,name=result1,proto3" json:"result1,omitempty"`
}
func (*RandomNumberResponse) Descriptor ¶
func (*RandomNumberResponse) Descriptor() ([]byte, []int)
func (*RandomNumberResponse) GetResult1 ¶
func (m *RandomNumberResponse) GetResult1() float64
func (*RandomNumberResponse) Marshal ¶
func (m *RandomNumberResponse) Marshal() (dAtA []byte, err error)
func (*RandomNumberResponse) MarshalTo ¶
func (m *RandomNumberResponse) MarshalTo(dAtA []byte) (int, error)
func (*RandomNumberResponse) ProtoMessage ¶
func (*RandomNumberResponse) ProtoMessage()
func (*RandomNumberResponse) ProtoSize ¶ added in v1.3.0
func (m *RandomNumberResponse) ProtoSize() (n int)
func (*RandomNumberResponse) Reset ¶
func (m *RandomNumberResponse) Reset()
func (*RandomNumberResponse) String ¶
func (m *RandomNumberResponse) String() string
func (*RandomNumberResponse) Unmarshal ¶
func (m *RandomNumberResponse) Unmarshal(dAtA []byte) error
Directories ¶
Path | Synopsis |
---|---|
Package categories is a generated protocol buffer package.
|
Package categories is a generated protocol buffer package. |
Click to show internal directories.
Click to hide internal directories.