v1

package
v0.0.0-...-3b9ec85 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package v1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	Status_name = map[int32]string{
		0: "Unknown",
		1: "Error",
		2: "OK",
	}
	Status_value = map[string]int32{
		"Unknown": 0,
		"Error":   1,
		"OK":      2,
	}
)

Enum value maps for Status.

View Source
var Countries_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "gunk.example.v1.Countries",
	HandlerType: (*CountriesServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetCountries",
			Handler:    _Countries_GetCountries_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "github.com/gunk/gunk-example-server/api/v1/all.proto",
}

Countries_ServiceDesc is the grpc.ServiceDesc for Countries service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_github_com_gunk_gunk_example_server_api_v1_all_proto protoreflect.FileDescriptor
View Source
var Swagger []byte

Swagger is the embedded swagger definition.

View Source
var Util_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "gunk.example.v1.Util",
	HandlerType: (*UtilServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CheckStatus",
			Handler:    _Util_CheckStatus_Handler,
		},
		{
			MethodName: "Echo",
			Handler:    _Util_Echo_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "github.com/gunk/gunk-example-server/api/v1/all.proto",
}

Util_ServiceDesc is the grpc.ServiceDesc for Util service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterCountriesHandler

func RegisterCountriesHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterCountriesHandler registers the http handlers for service Countries to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterCountriesHandlerClient

func RegisterCountriesHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CountriesClient) error

RegisterCountriesHandlerClient registers the http handlers for service Countries to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "CountriesClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "CountriesClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "CountriesClient" to call the correct interceptors.

func RegisterCountriesHandlerFromEndpoint

func RegisterCountriesHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterCountriesHandlerFromEndpoint is same as RegisterCountriesHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterCountriesHandlerServer

func RegisterCountriesHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CountriesServer) error

RegisterCountriesHandlerServer registers the http handlers for service Countries to "mux". UnaryRPC :call CountriesServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCountriesHandlerFromEndpoint instead.

func RegisterCountriesServer

func RegisterCountriesServer(s grpc.ServiceRegistrar, srv CountriesServer)

func RegisterUtilHandler

func RegisterUtilHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterUtilHandler registers the http handlers for service Util to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterUtilHandlerClient

func RegisterUtilHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UtilClient) error

RegisterUtilHandlerClient registers the http handlers for service Util to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UtilClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UtilClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UtilClient" to call the correct interceptors.

func RegisterUtilHandlerFromEndpoint

func RegisterUtilHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterUtilHandlerFromEndpoint is same as RegisterUtilHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterUtilHandlerServer

func RegisterUtilHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UtilServer) error

RegisterUtilHandlerServer registers the http handlers for service Util to "mux". UnaryRPC :call UtilServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUtilHandlerFromEndpoint instead.

func RegisterUtilServer

func RegisterUtilServer(s grpc.ServiceRegistrar, srv UtilServer)

Types

type CheckStatusResponse

type CheckStatusResponse struct {
	Status Status `protobuf:"varint,1,opt,name=Status,json=status,proto3,enum=gunk.example.v1.Status" json:"status,omitempty"`
	// Deprecated: Do not use.
	OldField int32 `protobuf:"varint,2,opt,name=OldField,json=old_field,proto3" json:"old_field,omitempty"`
	// contains filtered or unexported fields
}

CheckStatusResponse is the server health status response.

func (*CheckStatusResponse) Descriptor deprecated

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

Deprecated: Use CheckStatusResponse.ProtoReflect.Descriptor instead.

func (*CheckStatusResponse) GetOldField deprecated

func (x *CheckStatusResponse) GetOldField() int32

Deprecated: Do not use.

func (*CheckStatusResponse) GetStatus

func (x *CheckStatusResponse) GetStatus() Status

func (*CheckStatusResponse) ProtoMessage

func (*CheckStatusResponse) ProtoMessage()

func (*CheckStatusResponse) ProtoReflect

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

func (*CheckStatusResponse) Reset

func (x *CheckStatusResponse) Reset()

func (*CheckStatusResponse) String

func (x *CheckStatusResponse) String() string

type CountriesClient

type CountriesClient interface {
	// GetCountries returns a list of countries identified by their ISO code.
	// (showcases multiple http matching rules with a filter).
	GetCountries(ctx context.Context, in *GetCountriesRequest, opts ...grpc.CallOption) (*GetCountriesResponse, error)
}

CountriesClient is the client API for Countries service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewCountriesClient

func NewCountriesClient(cc grpc.ClientConnInterface) CountriesClient

type CountriesServer

type CountriesServer interface {
	// GetCountries returns a list of countries identified by their ISO code.
	// (showcases multiple http matching rules with a filter).
	GetCountries(context.Context, *GetCountriesRequest) (*GetCountriesResponse, error)
	// contains filtered or unexported methods
}

CountriesServer is the server API for Countries service. All implementations must embed UnimplementedCountriesServer for forward compatibility

type Country

type Country struct {
	Name string `protobuf:"bytes,1,opt,name=Name,json=name,proto3" json:"name,omitempty"`
	Code string `protobuf:"bytes,2,opt,name=Code,json=code,proto3" json:"code,omitempty"`
	// contains filtered or unexported fields
}

Country contains country information.

func (*Country) Descriptor deprecated

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

Deprecated: Use Country.ProtoReflect.Descriptor instead.

func (*Country) GetCode

func (x *Country) GetCode() string

func (*Country) GetName

func (x *Country) GetName() string

func (*Country) ProtoMessage

func (*Country) ProtoMessage()

func (*Country) ProtoReflect

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

func (*Country) Reset

func (x *Country) Reset()

func (*Country) String

func (x *Country) String() string

type GetCountriesRequest

type GetCountriesRequest struct {
	Countries []string `protobuf:"bytes,1,rep,name=Countries,json=countries,proto3" json:"countries,omitempty"`
	// contains filtered or unexported fields
}

GetCountriesRequest is the get countries request.

func (*GetCountriesRequest) Descriptor deprecated

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

Deprecated: Use GetCountriesRequest.ProtoReflect.Descriptor instead.

func (*GetCountriesRequest) GetCountries

func (x *GetCountriesRequest) GetCountries() []string

func (*GetCountriesRequest) ProtoMessage

func (*GetCountriesRequest) ProtoMessage()

func (*GetCountriesRequest) ProtoReflect

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

func (*GetCountriesRequest) Reset

func (x *GetCountriesRequest) Reset()

func (*GetCountriesRequest) String

func (x *GetCountriesRequest) String() string

type GetCountriesResponse

type GetCountriesResponse struct {
	Countries map[string]*Country `` /* 174-byte string literal not displayed */
	// contains filtered or unexported fields
}

GetCountriesResponse is the get countries response.

func (*GetCountriesResponse) Descriptor deprecated

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

Deprecated: Use GetCountriesResponse.ProtoReflect.Descriptor instead.

func (*GetCountriesResponse) GetCountries

func (x *GetCountriesResponse) GetCountries() map[string]*Country

func (*GetCountriesResponse) ProtoMessage

func (*GetCountriesResponse) ProtoMessage()

func (*GetCountriesResponse) ProtoReflect

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

func (*GetCountriesResponse) Reset

func (x *GetCountriesResponse) Reset()

func (*GetCountriesResponse) String

func (x *GetCountriesResponse) String() string

type Message

type Message struct {

	// Msg holds a message.
	Msg  string `protobuf:"bytes,1,opt,name=Msg,json=msg,proto3" json:"msg,omitempty"`
	Code int32  `protobuf:"varint,2,opt,name=Code,json=code,proto3" json:"code,omitempty"`
	// contains filtered or unexported fields
}

Message is a echo message.

func (*Message) Descriptor deprecated

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

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetCode

func (x *Message) GetCode() int32

func (*Message) GetMsg

func (x *Message) GetMsg() string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

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

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type Status

type Status int32

Status is a server health status.

const (
	Status_Unknown Status = 0
	Status_Error   Status = 1
	Status_OK      Status = 2
)

func (Status) Descriptor

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

func (Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use Status.Descriptor instead.

func (Status) Number

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

func (Status) Type

func (Status) Type() protoreflect.EnumType

type UnimplementedCountriesServer

type UnimplementedCountriesServer struct{}

UnimplementedCountriesServer must be embedded to have forward compatible implementations.

func (UnimplementedCountriesServer) GetCountries

type UnimplementedUtilServer

type UnimplementedUtilServer struct{}

UnimplementedUtilServer must be embedded to have forward compatible implementations.

func (UnimplementedUtilServer) CheckStatus

func (UnimplementedUtilServer) Echo

type UnsafeCountriesServer

type UnsafeCountriesServer interface {
	// contains filtered or unexported methods
}

UnsafeCountriesServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to CountriesServer will result in compilation errors.

type UnsafeUtilServer

type UnsafeUtilServer interface {
	// contains filtered or unexported methods
}

UnsafeUtilServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UtilServer will result in compilation errors.

type UtilClient

type UtilClient interface {
	// CheckStatus returns the server health status.
	CheckStatus(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*CheckStatusResponse, error)
	// Echo echoes a message.
	Echo(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error)
}

UtilClient is the client API for Util service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewUtilClient

func NewUtilClient(cc grpc.ClientConnInterface) UtilClient

type UtilServer

type UtilServer interface {
	// CheckStatus returns the server health status.
	CheckStatus(context.Context, *emptypb.Empty) (*CheckStatusResponse, error)
	// Echo echoes a message.
	Echo(context.Context, *Message) (*Message, error)
	// contains filtered or unexported methods
}

UtilServer is the server API for Util service. All implementations must embed UnimplementedUtilServer for forward compatibility

Jump to

Keyboard shortcuts

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