goff

package module
v1.0.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2020 License: Apache-2.0 Imports: 4 Imported by: 8

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 or bff. The reason behind it is we encounrage every one (especial FE code) to access the service via bff 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:"deviceType,omitempty"'];
  • [(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 E_Custom = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.FieldOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         51242,
	Name:          "goff.custom",
	Tag:           "bytes,51242,opt,name=custom",
	Filename:      "goff.proto",
}
View Source
var E_Name = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.ServiceOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         51300,
	Name:          "goff.name",
	Tag:           "bytes,51300,opt,name=name",
	Filename:      "goff.proto",
}
View Source
var E_NatsSubject = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.FileOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         51236,
	Name:          "goff.nats_subject",
	Tag:           "bytes,51236,opt,name=nats_subject",
	Filename:      "goff.proto",
}
View Source
var E_Nullable = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.FieldOptions)(nil),
	ExtensionType: (*bool)(nil),
	Field:         51243,
	Name:          "goff.nullable",
	Tag:           "varint,51243,opt,name=nullable",
	Filename:      "goff.proto",
}
View Source
var E_ResponseEvent = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.MethodOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         51238,
	Name:          "goff.response_event",
	Tag:           "bytes,51238,opt,name=response_event",
	Filename:      "goff.proto",
}
View Source
var E_Secured = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.MethodOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         51239,
	Name:          "goff.secured",
	Tag:           "bytes,51239,opt,name=secured",
	Filename:      "goff.proto",
}
View Source
var E_TsFile = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.FileOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         51238,
	Name:          "goff.ts_file",
	Tag:           "bytes,51238,opt,name=ts_file",
	Filename:      "goff.proto",
}
View Source
var E_Value = &proto.ExtensionDesc{
	ExtendedType:  (*descriptor.EnumValueOptions)(nil),
	ExtensionType: (*string)(nil),
	Field:         51250,
	Name:          "goff.value",
	Tag:           "bytes,51250,opt,name=value",
	Filename:      "goff.proto",
}

Functions

This section is empty.

Types

type Empty

type Empty struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Empty) Descriptor

func (*Empty) Descriptor() ([]byte, []int)

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) String

func (m *Empty) String() string

func (*Empty) XXX_DiscardUnknown

func (m *Empty) XXX_DiscardUnknown()

func (*Empty) XXX_Marshal

func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Empty) XXX_Merge

func (m *Empty) XXX_Merge(src proto.Message)

func (*Empty) XXX_Size

func (m *Empty) XXX_Size() int

func (*Empty) XXX_Unmarshal

func (m *Empty) XXX_Unmarshal(b []byte) error

type HttpHeader added in v1.0.18

type HttpHeader struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*HttpHeader) Descriptor added in v1.0.18

func (*HttpHeader) Descriptor() ([]byte, []int)

func (*HttpHeader) ProtoMessage added in v1.0.18

func (*HttpHeader) ProtoMessage()

func (*HttpHeader) Reset added in v1.0.18

func (m *HttpHeader) Reset()

func (*HttpHeader) String added in v1.0.18

func (m *HttpHeader) String() string

func (*HttpHeader) XXX_DiscardUnknown added in v1.0.18

func (m *HttpHeader) XXX_DiscardUnknown()

func (*HttpHeader) XXX_Marshal added in v1.0.18

func (m *HttpHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HttpHeader) XXX_Merge added in v1.0.18

func (m *HttpHeader) XXX_Merge(src proto.Message)

func (*HttpHeader) XXX_Size added in v1.0.18

func (m *HttpHeader) XXX_Size() int

func (*HttpHeader) XXX_Unmarshal added in v1.0.18

func (m *HttpHeader) XXX_Unmarshal(b []byte) error

type HttpResponse added in v1.0.18

type HttpResponse struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*HttpResponse) Descriptor added in v1.0.18

func (*HttpResponse) Descriptor() ([]byte, []int)

func (*HttpResponse) ProtoMessage added in v1.0.18

func (*HttpResponse) ProtoMessage()

func (*HttpResponse) Reset added in v1.0.18

func (m *HttpResponse) Reset()

func (*HttpResponse) String added in v1.0.18

func (m *HttpResponse) String() string

func (*HttpResponse) XXX_DiscardUnknown added in v1.0.18

func (m *HttpResponse) XXX_DiscardUnknown()

func (*HttpResponse) XXX_Marshal added in v1.0.18

func (m *HttpResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HttpResponse) XXX_Merge added in v1.0.18

func (m *HttpResponse) XXX_Merge(src proto.Message)

func (*HttpResponse) XXX_Size added in v1.0.18

func (m *HttpResponse) XXX_Size() int

func (*HttpResponse) XXX_Unmarshal added in v1.0.18

func (m *HttpResponse) XXX_Unmarshal(b []byte) error

type Time added in v1.0.25

type Time struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Time) Descriptor added in v1.0.25

func (*Time) Descriptor() ([]byte, []int)

func (*Time) ProtoMessage added in v1.0.25

func (*Time) ProtoMessage()

func (*Time) Reset added in v1.0.25

func (m *Time) Reset()

func (*Time) String added in v1.0.25

func (m *Time) String() string

func (*Time) XXX_DiscardUnknown added in v1.0.25

func (m *Time) XXX_DiscardUnknown()

func (*Time) XXX_Marshal added in v1.0.25

func (m *Time) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Time) XXX_Merge added in v1.0.25

func (m *Time) XXX_Merge(src proto.Message)

func (*Time) XXX_Size added in v1.0.25

func (m *Time) XXX_Size() int

func (*Time) XXX_Unmarshal added in v1.0.25

func (m *Time) XXX_Unmarshal(b []byte) error

type UUID

type UUID struct {
	Value                string   `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UUID) Descriptor

func (*UUID) Descriptor() ([]byte, []int)

func (*UUID) GetValue

func (m *UUID) GetValue() string

func (*UUID) ProtoMessage

func (*UUID) ProtoMessage()

func (*UUID) Reset

func (m *UUID) Reset()

func (*UUID) String

func (m *UUID) String() string

func (*UUID) XXX_DiscardUnknown

func (m *UUID) XXX_DiscardUnknown()

func (*UUID) XXX_Marshal

func (m *UUID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UUID) XXX_Merge

func (m *UUID) XXX_Merge(src proto.Message)

func (*UUID) XXX_Size

func (m *UUID) XXX_Size() int

func (*UUID) XXX_Unmarshal

func (m *UUID) XXX_Unmarshal(b []byte) error

type UserInfo added in v1.0.18

type UserInfo struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UserInfo) Descriptor added in v1.0.18

func (*UserInfo) Descriptor() ([]byte, []int)

func (*UserInfo) ProtoMessage added in v1.0.18

func (*UserInfo) ProtoMessage()

func (*UserInfo) Reset added in v1.0.18

func (m *UserInfo) Reset()

func (*UserInfo) String added in v1.0.18

func (m *UserInfo) String() string

func (*UserInfo) XXX_DiscardUnknown added in v1.0.18

func (m *UserInfo) XXX_DiscardUnknown()

func (*UserInfo) XXX_Marshal added in v1.0.18

func (m *UserInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserInfo) XXX_Merge added in v1.0.18

func (m *UserInfo) XXX_Merge(src proto.Message)

func (*UserInfo) XXX_Size added in v1.0.18

func (m *UserInfo) XXX_Size() int

func (*UserInfo) XXX_Unmarshal added in v1.0.18

func (m *UserInfo) XXX_Unmarshal(b []byte) error

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL