processors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatFieldValue

func FormatFieldValue(
	identFunc IdentFunc,
	field *protogen.Field,
	value protoreflect.Value,
) (string, error)

FormatFieldValue receives a value (protoreflect.Value) and converts it to a string format as an instantiate representation. See the example below:

If value is a string the format will be myString -> "myString" because using double quote is the way we use to instantiate/create a string. Some other examples:

  • int64: 64 -> 64 (to instantiate/create a int we just need the number)
  • []bytes: []byte("abcd") -> []byte{0x61, 0x62, 0x63, 0x64}

func FormatMessageField

func FormatMessageField(
	identFunc IdentFunc,
	ident protogen.GoIdent,
	fieldsByNumber FieldsByNumber,
	message protoreflect.Message,
) (string, error)

FormatMessageField takes care of formatting a message to a properly string format.

func IsErrorCodeValid

func IsErrorCodeValid(errorCode string) bool

IsErrorCodeValid returns true when a error code exists in the GRPC Codes package

func MakeExportedName

func MakeExportedName(name string) string

MakeExportedName transforms any string in a Go's exported name. In Go to make a function/struct/const/var public the first letter must be upper.

func ReadContractFile

func ReadContractFile(filePath string) (entities.Contract, error)

ReadContractFile reads a JSON File and try to parse it to a entities.Contract object

Types

type FieldsByNumber

type FieldsByNumber map[protoreflect.FieldNumber]*protogen.Field

FieldsByNumber represents the relation between the proto field number with a protogen.Field. It's very useful to correlate with fields from protoreflect.Message.

func CreateFieldsByNumber

func CreateFieldsByNumber(fields []*protogen.Field) FieldsByNumber

CreateFieldsByNumber transform a slice of protogen.Field into a FieldsByNumber, so we can access the field by its number. This is very handy when we need to correlate fields from a protogen.Message with fields from a protoreflect.Message.

type IdentFunc

type IdentFunc func(ident protogen.GoIdent) string

IdentFunc is used when we need to use the QualifiedGoIdent method from protogen.GeneratedFile without passing the entire struct.

Jump to

Keyboard shortcuts

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