example

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package example is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	ExampleGreeter_SayExample_FullMethodName = "/hello.example.v1.ExampleGreeter/SayExample"
)
View Source
const (
	ExampleIdentity_ServerVersion_FullMethodName = "/hello.example.v1.ExampleIdentity/ServerVersion"
)

Variables

View Source
var (
	ExampleVersion_Version_name = map[int32]string{
		0: "VERSION_UNSPECIFIED",

		1: "PATCH",
	}
	ExampleVersion_Version_value = map[string]int32{
		"VERSION_UNSPECIFIED": 0,
		"MAJOR":               0,
		"MINOR":               0,
		"PATCH":               1,
	}
)

Enum value maps for ExampleVersion_Version.

View Source
var ExampleGreeter_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "hello.example.v1.ExampleGreeter",
	HandlerType: (*ExampleGreeterServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "SayExample",
			Handler:    _ExampleGreeter_SayExample_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apis/example/apiv1/example.proto",
}

ExampleGreeter_ServiceDesc is the grpc.ServiceDesc for ExampleGreeter 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 ExampleIdentity_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "hello.example.v1.ExampleIdentity",
	HandlerType: (*ExampleIdentityServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ServerVersion",
			Handler:    _ExampleIdentity_ServerVersion_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apis/example/apiv1/example.proto",
}

ExampleIdentity_ServiceDesc is the grpc.ServiceDesc for ExampleIdentity 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_apis_example_apiv1_example_proto protoreflect.FileDescriptor

Functions

func RegisterExampleGreeterHandler

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

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

func RegisterExampleGreeterHandlerClient

func RegisterExampleGreeterHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ExampleGreeterClient) error

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

func RegisterExampleGreeterHandlerFromEndpoint

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

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

func RegisterExampleGreeterHandlerServer

func RegisterExampleGreeterHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExampleGreeterServer) error

RegisterExampleGreeterHandlerServer registers the http handlers for service ExampleGreeter to "mux". UnaryRPC :call ExampleGreeterServer 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 RegisterExampleGreeterHandlerFromEndpoint instead.

func RegisterExampleGreeterServer

func RegisterExampleGreeterServer(s grpc.ServiceRegistrar, srv ExampleGreeterServer)

func RegisterExampleIdentityHandler

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

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

func RegisterExampleIdentityHandlerClient

func RegisterExampleIdentityHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ExampleIdentityClient) error

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

func RegisterExampleIdentityHandlerFromEndpoint

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

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

func RegisterExampleIdentityHandlerServer

func RegisterExampleIdentityHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExampleIdentityServer) error

RegisterExampleIdentityHandlerServer registers the http handlers for service ExampleIdentity to "mux". UnaryRPC :call ExampleIdentityServer 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 RegisterExampleIdentityHandlerFromEndpoint instead.

func RegisterExampleIdentityServer

func RegisterExampleIdentityServer(s grpc.ServiceRegistrar, srv ExampleIdentityServer)

Types

type ExampleGreeterClient

type ExampleGreeterClient interface {
	// Sends a greeting
	SayExample(ctx context.Context, in *ExampleGreeterSayExampleRequest, opts ...grpc.CallOption) (*ExampleGreeterSayExampleResponse, error)
}

ExampleGreeterClient is the client API for ExampleGreeter 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.

type ExampleGreeterSayExampleRequest

type ExampleGreeterSayExampleRequest struct {

	// Name to say Example to
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

The request message containing the user's name.

func (*ExampleGreeterSayExampleRequest) Descriptor deprecated

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

Deprecated: Use ExampleGreeterSayExampleRequest.ProtoReflect.Descriptor instead.

func (*ExampleGreeterSayExampleRequest) GetName

func (*ExampleGreeterSayExampleRequest) ProtoMessage

func (*ExampleGreeterSayExampleRequest) ProtoMessage()

func (*ExampleGreeterSayExampleRequest) ProtoReflect

func (*ExampleGreeterSayExampleRequest) Reset

func (*ExampleGreeterSayExampleRequest) String

type ExampleGreeterSayExampleResponse

type ExampleGreeterSayExampleResponse struct {

	// Message returned from server containing 'name'
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

The response message containing the greetings

func (*ExampleGreeterSayExampleResponse) Descriptor deprecated

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

Deprecated: Use ExampleGreeterSayExampleResponse.ProtoReflect.Descriptor instead.

func (*ExampleGreeterSayExampleResponse) GetMessage

func (x *ExampleGreeterSayExampleResponse) GetMessage() string

func (*ExampleGreeterSayExampleResponse) ProtoMessage

func (*ExampleGreeterSayExampleResponse) ProtoMessage()

func (*ExampleGreeterSayExampleResponse) ProtoReflect

func (*ExampleGreeterSayExampleResponse) Reset

func (*ExampleGreeterSayExampleResponse) String

type ExampleGreeterServer

type ExampleGreeterServer interface {
	// Sends a greeting
	SayExample(context.Context, *ExampleGreeterSayExampleRequest) (*ExampleGreeterSayExampleResponse, error)
	// contains filtered or unexported methods
}

ExampleGreeterServer is the server API for ExampleGreeter service. All implementations must embed UnimplementedExampleGreeterServer for forward compatibility

type ExampleIdentityClient

type ExampleIdentityClient interface {
	// Gets server version
	ServerVersion(ctx context.Context, in *ExampleIdentityVersionRequest, opts ...grpc.CallOption) (*ExampleIdentityVersionResponse, error)
}

ExampleIdentityClient is the client API for ExampleIdentity 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.

type ExampleIdentityServer

type ExampleIdentityServer interface {
	// Gets server version
	ServerVersion(context.Context, *ExampleIdentityVersionRequest) (*ExampleIdentityVersionResponse, error)
	// contains filtered or unexported methods
}

ExampleIdentityServer is the server API for ExampleIdentity service. All implementations must embed UnimplementedExampleIdentityServer for forward compatibility

type ExampleIdentityVersionRequest

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

Empty request

func (*ExampleIdentityVersionRequest) Descriptor deprecated

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

Deprecated: Use ExampleIdentityVersionRequest.ProtoReflect.Descriptor instead.

func (*ExampleIdentityVersionRequest) ProtoMessage

func (*ExampleIdentityVersionRequest) ProtoMessage()

func (*ExampleIdentityVersionRequest) ProtoReflect

func (*ExampleIdentityVersionRequest) Reset

func (x *ExampleIdentityVersionRequest) Reset()

func (*ExampleIdentityVersionRequest) String

type ExampleIdentityVersionResponse

type ExampleIdentityVersionResponse struct {

	// Example application version
	ServerVersion *ExampleVersion `protobuf:"bytes,1,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"`
	// contains filtered or unexported fields
}

Defines the response to version

func (*ExampleIdentityVersionResponse) Descriptor deprecated

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

Deprecated: Use ExampleIdentityVersionResponse.ProtoReflect.Descriptor instead.

func (*ExampleIdentityVersionResponse) GetServerVersion

func (x *ExampleIdentityVersionResponse) GetServerVersion() *ExampleVersion

func (*ExampleIdentityVersionResponse) ProtoMessage

func (*ExampleIdentityVersionResponse) ProtoMessage()

func (*ExampleIdentityVersionResponse) ProtoReflect

func (*ExampleIdentityVersionResponse) Reset

func (x *ExampleIdentityVersionResponse) Reset()

func (*ExampleIdentityVersionResponse) String

type ExampleVersion

type ExampleVersion struct {

	// Version major number
	Major int32 `protobuf:"varint,1,opt,name=major,proto3" json:"major,omitempty"`
	// Version minor number
	Minor int32 `protobuf:"varint,2,opt,name=minor,proto3" json:"minor,omitempty"`
	// Version patch number
	Patch int32 `protobuf:"varint,3,opt,name=patch,proto3" json:"patch,omitempty"`
	// String representation of the version. Must be
	// in `major.minor.patch` format.
	Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
	// contains filtered or unexported fields
}

Example version in Major.Minor.Patch format. The goal of this message is to provide clients a method to determine the server and client versions.

func (*ExampleVersion) Descriptor deprecated

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

Deprecated: Use ExampleVersion.ProtoReflect.Descriptor instead.

func (*ExampleVersion) GetMajor

func (x *ExampleVersion) GetMajor() int32

func (*ExampleVersion) GetMinor

func (x *ExampleVersion) GetMinor() int32

func (*ExampleVersion) GetPatch

func (x *ExampleVersion) GetPatch() int32

func (*ExampleVersion) GetVersion

func (x *ExampleVersion) GetVersion() string

func (*ExampleVersion) ProtoMessage

func (*ExampleVersion) ProtoMessage()

func (*ExampleVersion) ProtoReflect

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

func (*ExampleVersion) Reset

func (x *ExampleVersion) Reset()

func (*ExampleVersion) String

func (x *ExampleVersion) String() string

type ExampleVersion_Version

type ExampleVersion_Version int32

These values are constants that can be used by the client and server applications

const (
	// Must be set in the proto file; ignore.
	ExampleVersion_VERSION_UNSPECIFIED ExampleVersion_Version = 0
	// Version major value of this specification
	ExampleVersion_MAJOR ExampleVersion_Version = 0
	// Version minor value of this specification
	ExampleVersion_MINOR ExampleVersion_Version = 0
	// Version patch value of this specification
	ExampleVersion_PATCH ExampleVersion_Version = 1
)

func (ExampleVersion_Version) Descriptor

func (ExampleVersion_Version) Enum

func (ExampleVersion_Version) EnumDescriptor deprecated

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

Deprecated: Use ExampleVersion_Version.Descriptor instead.

func (ExampleVersion_Version) Number

func (ExampleVersion_Version) String

func (x ExampleVersion_Version) String() string

func (ExampleVersion_Version) Type

type UnimplementedExampleGreeterServer

type UnimplementedExampleGreeterServer struct {
}

UnimplementedExampleGreeterServer must be embedded to have forward compatible implementations.

type UnimplementedExampleIdentityServer

type UnimplementedExampleIdentityServer struct {
}

UnimplementedExampleIdentityServer must be embedded to have forward compatible implementations.

type UnsafeExampleGreeterServer

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

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

type UnsafeExampleIdentityServer

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

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

Jump to

Keyboard shortcuts

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