core

package
v0.0.0-...-908e76c Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoTypeNameFromFullyQualified

func GoTypeNameFromFullyQualified(typ string) string

GoTypeNameFromFullyQualified returns a go type name from a fully qualified type name. For example, if typ is `.com.example.v1.CreateRequest`, it returns `v1.CreateRequest`. The fully qualified type name is typically from FieldDescriptorProto.TypeName.

Types

type APIDescriptor

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

APIDescriptor describes a gRPC API from a proto file.

func (*APIDescriptor) APIVersion

func (a *APIDescriptor) APIVersion() string

APIVersion returns the API version from the package name. For example, if the package name is "com.example.v1", it returns "v1".

func (*APIDescriptor) ImportPath

func (a *APIDescriptor) ImportPath() *v1.ImportPath

ImportPath returns the import path from the go_package option. For example, if the go_package option is "com.example.v1;example", it returns "com.example.v1".

func (*APIDescriptor) ServiceName

func (a *APIDescriptor) ServiceName() string

ServiceName returns the service name from the package name. For example, if the package name is "com.example.v1", it returns "example".

type ListResponseDescriptor

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

func (*ListResponseDescriptor) ListField

func (l *ListResponseDescriptor) ListField() (string, error)

ListField returns the field name of the resource list.

The response message of the list method must have two fields. One is the resource list and the other is the next page token. If the response message has more than two fields, it returns an error.

For example, the following response message has two fields: ```

message ListClusterResponse {
  repeated Cluster clusters = 1;
  string next_page_token = 2;
}

``` In this case, it returns `Clusters`.

type MethodDescriptor

type MethodDescriptor struct {
	*descriptorpb.MethodDescriptorProto
}

MethodDescriptor describes a gRPC method from a proto file.

func (*MethodDescriptor) ResourceName

func (m *MethodDescriptor) ResourceName() string

ResourceName returns a resource name from a method type. For example, if the method type is `Create` and the method name is `CreateFoo`, it returns `Foo`.

func (*MethodDescriptor) Type

func (m *MethodDescriptor) Type() v1.MethodType

Type returns a method type. It determines the type of the method from its name.

type Plugin

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

Plugin is a plugin for protoc.

func NewPlugin

NewPlugin returns a new Plugin with stdin and stdout.

func (*Plugin) Debugf

func (p *Plugin) Debugf(format string, args ...any)

Debugf writes debug messages to stderr if the parameter is "debug".

func (*Plugin) MarshalJsonProto

func (p *Plugin) MarshalJsonProto(v proto.Message) ([]byte, error)

MarshalJSONProto marshals a proto message to JSON in protojson format.

If the parameter is "multiline", the output is formatted with newlines and indentation.

func (*Plugin) Run

func (p *Plugin) Run() error

Run reads CodeGeneratorRequest from stdin, writes CodeGeneratorResponse to stdout.

if the parameter is "debug", it writes debug messages to stderr.

func (*Plugin) SetInput

func (p *Plugin) SetInput(in io.Reader)

SetInput sets the input reader. It is used for testing.

func (*Plugin) SetOutput

func (p *Plugin) SetOutput(out io.Writer)

SetOutput sets the output writer. It is used for testing.

Jump to

Keyboard shortcuts

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