README
¶
Using protobuf-v3
Protobuf v3 comes with pretty nice definition that normally used for GRPC, including
- Solid data types
- Quite known pre-defined format
- Service definition ready
Current state
- Define structure
- Code skeleton for protobuf generator
- Define golang implementation
- Define typescript implementation
- Tests
- Incorporate tracing and monitoring into the implementations
Project structure
.
├── proto # example used to test this tool
├── protoc-gen-goff # a protoc plugin it's responsible for generating source code from .proto file
├── protoc-gen-parser # a protoc plugin it's responsible for compiling .proto file to intermediate binary file this is used by protoc-gen-goff in debuging
├── generate.sh # command compiles 'proto' example above by using protoc-gen-goff
├── goff.proto # protobuf extension defination
├── parser.sh # command compiles 'proto' example above by using protoc-gen-parser
├── LICENSE
└── README.md
How to run example
- Go installed
- Make sure probuffer installed (can install using
brew install protobuf
) - Confirm the installation by having protoc in code
- Execute generate.sh from root dir (can also use go generate todo ...)
Noted (naming proto file is matter)
- We decided only gen action methods and their listener when the proto file contant
app
orbff
. The reason behind it is we encounrage every one (especial FE code) to access the service viabff
not call service dirrectly.
How to use current repo
check the link below
https://www.notion.so/silenteer/RFD-Simplify-even-further-BFF-integration-using-code-generation-d50823d79d57430685cd855edba9be54
Option Examples:
- [(goff.custom) = '']
- validate: from https://github.com/go-playground/validator.
- Example: [(goff.custom) = 'validate:"notblank"'], [(goff.custom) = 'validate:"required,oneof=MEMBER PATIENT ORGANIZATION"']
- customize struct tags:
- Example: [(goff.custom) = 'json:"omitempty"'];
- validate: from https://github.com/go-playground/validator.
- [(goff.nullable) = true] //Set basic type to pointer.
- goff.Empty
- rpc getAllDevices (goff.Empty) returns (AdminDevicesDto) =>func getAllDevices() (AdminDevicesDto, error)
- rpc getAllDevices (Model) returns (goff.Empty) =>func getAllDevices(Model) (error)
- Mix options: [(goff.custom) = 'json:"gender,omitempty"', (goff.nullable) = true];
Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // optional string nats_subject = 51236; E_NatsSubject = &file_goff_proto_extTypes[0] // backward compatible, will be removed latter // optional string ts_file = 51238; E_TsFile = &file_goff_proto_extTypes[1] // typescript file name )
Extension fields to descriptor.FileOptions.
View Source
var ( // optional bool model = 60000; E_Model = &file_goff_proto_extTypes[3] // repository model // optional string extend_from_type = 60001; E_ExtendFromType = &file_goff_proto_extTypes[4] // extend from data type, example contract type from string // optional string collection_name = 60002; E_CollectionName = &file_goff_proto_extTypes[5] // optional bool is_tenant = 60003; E_IsTenant = &file_goff_proto_extTypes[6] )
Extension fields to descriptor.MessageOptions.
View Source
var ( // optional string custom = 51242; E_Custom = &file_goff_proto_extTypes[9] // // optional bool nullable = 51243; E_Nullable = &file_goff_proto_extTypes[10] )
Extension fields to descriptor.FieldOptions.
View Source
var ( // optional string name = 51300; E_Name = &file_goff_proto_extTypes[2] // custom name of service )
Extension fields to descriptor.ServiceOptions.
View Source
var (
// optional string of_type = 70000;
E_OfType = &file_goff_proto_extTypes[7]
)
Extension fields to descriptor.EnumOptions.
View Source
var ( // optional string secured = 51239; E_Secured = &file_goff_proto_extTypes[8] // role checking )
Extension fields to descriptor.MethodOptions.
View Source
var ( // optional string value = 51250; E_Value = &file_goff_proto_extTypes[11] // enum value option to fix issue https://github.com/protobuf-net/protobuf-net/issues/60 )
Extension fields to descriptor.EnumValueOptions.
View Source
var File_goff_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Empty ¶
type Empty struct {
// contains filtered or unexported fields
}
func (*Empty) Descriptor
deprecated
func (*Empty) ProtoMessage ¶
func (*Empty) ProtoMessage()
func (*Empty) ProtoReflect ¶ added in v1.0.48
func (x *Empty) ProtoReflect() protoreflect.Message
type HttpHeader ¶ added in v1.0.18
type HttpHeader struct {
// contains filtered or unexported fields
}
func (*HttpHeader) Descriptor
deprecated
added in
v1.0.18
func (*HttpHeader) Descriptor() ([]byte, []int)
Deprecated: Use HttpHeader.ProtoReflect.Descriptor instead.
func (*HttpHeader) ProtoMessage ¶ added in v1.0.18
func (*HttpHeader) ProtoMessage()
func (*HttpHeader) ProtoReflect ¶ added in v1.0.48
func (x *HttpHeader) ProtoReflect() protoreflect.Message
func (*HttpHeader) Reset ¶ added in v1.0.18
func (x *HttpHeader) Reset()
func (*HttpHeader) String ¶ added in v1.0.18
func (x *HttpHeader) String() string
type HttpResponse ¶ added in v1.0.18
type HttpResponse struct {
// contains filtered or unexported fields
}
func (*HttpResponse) Descriptor
deprecated
added in
v1.0.18
func (*HttpResponse) Descriptor() ([]byte, []int)
Deprecated: Use HttpResponse.ProtoReflect.Descriptor instead.
func (*HttpResponse) ProtoMessage ¶ added in v1.0.18
func (*HttpResponse) ProtoMessage()
func (*HttpResponse) ProtoReflect ¶ added in v1.0.48
func (x *HttpResponse) ProtoReflect() protoreflect.Message
func (*HttpResponse) Reset ¶ added in v1.0.18
func (x *HttpResponse) Reset()
func (*HttpResponse) String ¶ added in v1.0.18
func (x *HttpResponse) String() string
type Time ¶ added in v1.0.25
type Time struct {
// contains filtered or unexported fields
}
func (*Time) Descriptor
deprecated
added in
v1.0.25
func (*Time) ProtoMessage ¶ added in v1.0.25
func (*Time) ProtoMessage()
func (*Time) ProtoReflect ¶ added in v1.0.48
func (x *Time) ProtoReflect() protoreflect.Message
type UUID ¶
type UUID struct { Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*UUID) Descriptor
deprecated
func (*UUID) ProtoMessage ¶
func (*UUID) ProtoMessage()
func (*UUID) ProtoReflect ¶ added in v1.0.48
func (x *UUID) ProtoReflect() protoreflect.Message
type UserInfo ¶ added in v1.0.18
type UserInfo struct {
// contains filtered or unexported fields
}
func (*UserInfo) Descriptor
deprecated
added in
v1.0.18
func (*UserInfo) ProtoMessage ¶ added in v1.0.18
func (*UserInfo) ProtoMessage()
func (*UserInfo) ProtoReflect ¶ added in v1.0.48
func (x *UserInfo) ProtoReflect() protoreflect.Message
Directories
¶
Path | Synopsis |
---|---|
uritemplates
Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).
|
Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570). |
Click to show internal directories.
Click to hide internal directories.