goff

package module
v1.1.20 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 6 Imported by: 2

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:"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];

Env parameters

  • TS_SOCKET_PATH:
    • Change default import socket path on generated ts files:
    • Default value: @tutum/hermes/websocket

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
	// optional bool pointer_strict_mode = 51239;
	E_PointerStrictMode = &file_goff_proto_extTypes[2] // pointer strict mode
)

Extension fields to descriptorpb.FileOptions.

View Source
var (
	// optional bool model = 60000;
	E_Model = &file_goff_proto_extTypes[4] // repository model
	// optional string extend_from_type = 60001;
	E_ExtendFromType = &file_goff_proto_extTypes[5] // extend from data type, example contract type from string
	// optional string collection_name = 60002;
	E_CollectionName = &file_goff_proto_extTypes[6]
	// optional bool is_tenant = 60003;
	E_IsTenant = &file_goff_proto_extTypes[7]
	// repeated string policy = 60004;
	E_Policy = &file_goff_proto_extTypes[8] // example  option (goff.policy) = "CareConsumer:read=#,write=#;"
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// optional string custom = 51242;
	E_Custom = &file_goff_proto_extTypes[11] //
	// optional bool nullable = 51243;
	E_Nullable = &file_goff_proto_extTypes[12]
	// optional string ref = 51244;
	E_Ref = &file_goff_proto_extTypes[13] // model foreign key
)

Extension fields to descriptorpb.FieldOptions.

View Source
var (
	// optional string name = 51300;
	E_Name = &file_goff_proto_extTypes[3] // custom name of service
)

Extension fields to descriptorpb.ServiceOptions.

View Source
var (
	// optional string of_type = 70000;
	E_OfType = &file_goff_proto_extTypes[9]
)

Extension fields to descriptorpb.EnumOptions.

View Source
var (
	// optional string secured = 51239;
	E_Secured = &file_goff_proto_extTypes[10] // role checking
)

Extension fields to descriptorpb.MethodOptions.

View Source
var (
	// optional string value = 51250;
	E_Value = &file_goff_proto_extTypes[14] // enum value option to fix issue https://github.com/protobuf-net/protobuf-net/issues/60
)

Extension fields to descriptorpb.EnumValueOptions.

Functions

This section is empty.

Types

type Empty

type Empty struct {
	// contains filtered or unexported fields
}

func (*Empty) Descriptor deprecated

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

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect added in v1.0.48

func (x *Empty) ProtoReflect() protoreflect.Message

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Time.ProtoReflect.Descriptor instead.

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

func (*Time) Reset added in v1.0.25

func (x *Time) Reset()

func (*Time) String added in v1.0.25

func (x *Time) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use UUID.ProtoReflect.Descriptor instead.

func (*UUID) GetValue

func (x *UUID) GetValue() string

func (*UUID) ProtoMessage

func (*UUID) ProtoMessage()

func (*UUID) ProtoReflect added in v1.0.48

func (x *UUID) ProtoReflect() protoreflect.Message

func (*UUID) Reset

func (x *UUID) Reset()

func (*UUID) String

func (x *UUID) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use UserInfo.ProtoReflect.Descriptor instead.

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

func (*UserInfo) Reset added in v1.0.18

func (x *UserInfo) Reset()

func (*UserInfo) String added in v1.0.18

func (x *UserInfo) String() string

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