grpc_mock_api

package
v1.0.8 Latest Latest
Warning

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

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

Documentation

Overview

Package grpc_mock_api is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

Functions

func RegisterMockHandler

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

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

func RegisterMockHandlerClient

func RegisterMockHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MockClient) error

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

func RegisterMockHandlerFromEndpoint

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

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

func RegisterMockHandlerServer

func RegisterMockHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MockServer) error

RegisterMockHandlerServer registers the http handlers for service Mock to "mux". UnaryRPC :call MockServer 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 RegisterMockHandlerFromEndpoint instead.

func RegisterMockServer

func RegisterMockServer(s *grpc.Server, srv MockServer)

Types

type AddStubsRequest

type AddStubsRequest struct {
	Stubs []*Stub `protobuf:"bytes,1,rep,name=stubs,proto3" json:"stubs,omitempty"`
	// contains filtered or unexported fields
}

func (*AddStubsRequest) Descriptor deprecated

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

Deprecated: Use AddStubsRequest.ProtoReflect.Descriptor instead.

func (*AddStubsRequest) GetStubs

func (x *AddStubsRequest) GetStubs() []*Stub

func (*AddStubsRequest) ProtoMessage

func (*AddStubsRequest) ProtoMessage()

func (*AddStubsRequest) ProtoReflect

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

func (*AddStubsRequest) Reset

func (x *AddStubsRequest) Reset()

func (*AddStubsRequest) String

func (x *AddStubsRequest) String() string

type AddStubsResponse

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

func (*AddStubsResponse) Descriptor deprecated

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

Deprecated: Use AddStubsResponse.ProtoReflect.Descriptor instead.

func (*AddStubsResponse) ProtoMessage

func (*AddStubsResponse) ProtoMessage()

func (*AddStubsResponse) ProtoReflect

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

func (*AddStubsResponse) Reset

func (x *AddStubsResponse) Reset()

func (*AddStubsResponse) String

func (x *AddStubsResponse) String() string

type DeleteStubsRequest

type DeleteStubsRequest struct {
	Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	Method  string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteStubsRequest) Descriptor deprecated

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

Deprecated: Use DeleteStubsRequest.ProtoReflect.Descriptor instead.

func (*DeleteStubsRequest) GetMethod

func (x *DeleteStubsRequest) GetMethod() string

func (*DeleteStubsRequest) GetService

func (x *DeleteStubsRequest) GetService() string

func (*DeleteStubsRequest) ProtoMessage

func (*DeleteStubsRequest) ProtoMessage()

func (*DeleteStubsRequest) ProtoReflect

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

func (*DeleteStubsRequest) Reset

func (x *DeleteStubsRequest) Reset()

func (*DeleteStubsRequest) String

func (x *DeleteStubsRequest) String() string

type DeleteStubsResponse

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

func (*DeleteStubsResponse) Descriptor deprecated

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

Deprecated: Use DeleteStubsResponse.ProtoReflect.Descriptor instead.

func (*DeleteStubsResponse) ProtoMessage

func (*DeleteStubsResponse) ProtoMessage()

func (*DeleteStubsResponse) ProtoReflect

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

func (*DeleteStubsResponse) Reset

func (x *DeleteStubsResponse) Reset()

func (*DeleteStubsResponse) String

func (x *DeleteStubsResponse) String() string

type FindStubsRequest

type FindStubsRequest struct {
	Service string           `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	Method  string           `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	In      *structpb.Struct `protobuf:"bytes,3,opt,name=in,proto3" json:"in,omitempty"`
	// contains filtered or unexported fields
}

func (*FindStubsRequest) Descriptor deprecated

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

Deprecated: Use FindStubsRequest.ProtoReflect.Descriptor instead.

func (*FindStubsRequest) GetIn

func (x *FindStubsRequest) GetIn() *structpb.Struct

func (*FindStubsRequest) GetMethod

func (x *FindStubsRequest) GetMethod() string

func (*FindStubsRequest) GetService

func (x *FindStubsRequest) GetService() string

func (*FindStubsRequest) ProtoMessage

func (*FindStubsRequest) ProtoMessage()

func (*FindStubsRequest) ProtoReflect

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

func (*FindStubsRequest) Reset

func (x *FindStubsRequest) Reset()

func (*FindStubsRequest) String

func (x *FindStubsRequest) String() string

type FindStubsResponse

type FindStubsResponse struct {
	Stubs []*Stub `protobuf:"bytes,1,rep,name=stubs,proto3" json:"stubs,omitempty"`
	// contains filtered or unexported fields
}

func (*FindStubsResponse) Descriptor deprecated

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

Deprecated: Use FindStubsResponse.ProtoReflect.Descriptor instead.

func (*FindStubsResponse) GetStubs

func (x *FindStubsResponse) GetStubs() []*Stub

func (*FindStubsResponse) ProtoMessage

func (*FindStubsResponse) ProtoMessage()

func (*FindStubsResponse) ProtoReflect

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

func (*FindStubsResponse) Reset

func (x *FindStubsResponse) Reset()

func (*FindStubsResponse) String

func (x *FindStubsResponse) String() string

type Input

type Input struct {

	// Types that are assignable to Rule:
	//	*Input_Equals
	//	*Input_Contains
	//	*Input_Matches
	Rule isInput_Rule `protobuf_oneof:"rule"`
	// contains filtered or unexported fields
}

func (*Input) Descriptor deprecated

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

Deprecated: Use Input.ProtoReflect.Descriptor instead.

func (*Input) GetContains

func (x *Input) GetContains() *structpb.Struct

func (*Input) GetEquals

func (x *Input) GetEquals() *structpb.Struct

func (*Input) GetMatches

func (x *Input) GetMatches() *structpb.Struct

func (*Input) GetRule

func (m *Input) GetRule() isInput_Rule

func (*Input) ProtoMessage

func (*Input) ProtoMessage()

func (*Input) ProtoReflect

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

func (*Input) Reset

func (x *Input) Reset()

func (*Input) String

func (x *Input) String() string

type Input_Contains

type Input_Contains struct {
	Contains *structpb.Struct `protobuf:"bytes,2,opt,name=contains,proto3,oneof"`
}

type Input_Equals

type Input_Equals struct {
	Equals *structpb.Struct `protobuf:"bytes,1,opt,name=equals,proto3,oneof"`
}

type Input_Matches

type Input_Matches struct {
	Matches *structpb.Struct `protobuf:"bytes,3,opt,name=matches,proto3,oneof"`
}

type MockClient

type MockClient interface {
	AddStubs(ctx context.Context, in *AddStubsRequest, opts ...grpc.CallOption) (*AddStubsResponse, error)
	FindStubs(ctx context.Context, in *FindStubsRequest, opts ...grpc.CallOption) (*FindStubsResponse, error)
	DeleteStubs(ctx context.Context, in *DeleteStubsRequest, opts ...grpc.CallOption) (*DeleteStubsResponse, error)
}

MockClient is the client API for Mock service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewMockClient

func NewMockClient(cc grpc.ClientConnInterface) MockClient

type MockServer

MockServer is the server API for Mock service.

type Output

type Output struct {
	Data  *structpb.Struct `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	Code  int32            `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
	Error string           `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*Output) Descriptor deprecated

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

Deprecated: Use Output.ProtoReflect.Descriptor instead.

func (*Output) GetCode

func (x *Output) GetCode() int32

func (*Output) GetData

func (x *Output) GetData() *structpb.Struct

func (*Output) GetError

func (x *Output) GetError() string

func (*Output) ProtoMessage

func (*Output) ProtoMessage()

func (*Output) ProtoReflect

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

func (*Output) Reset

func (x *Output) Reset()

func (*Output) String

func (x *Output) String() string

type Stub

type Stub struct {
	Service string  `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	Method  string  `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	In      *Input  `protobuf:"bytes,3,opt,name=in,proto3" json:"in,omitempty"`
	Out     *Output `protobuf:"bytes,4,opt,name=out,proto3" json:"out,omitempty"`
	// contains filtered or unexported fields
}

func (*Stub) Descriptor deprecated

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

Deprecated: Use Stub.ProtoReflect.Descriptor instead.

func (*Stub) GetIn

func (x *Stub) GetIn() *Input

func (*Stub) GetMethod

func (x *Stub) GetMethod() string

func (*Stub) GetOut

func (x *Stub) GetOut() *Output

func (*Stub) GetService

func (x *Stub) GetService() string

func (*Stub) ProtoMessage

func (*Stub) ProtoMessage()

func (*Stub) ProtoReflect

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

func (*Stub) Reset

func (x *Stub) Reset()

func (*Stub) String

func (x *Stub) String() string

type UnimplementedMockServer

type UnimplementedMockServer struct {
}

UnimplementedMockServer can be embedded to have forward compatible implementations.

func (*UnimplementedMockServer) AddStubs

func (*UnimplementedMockServer) DeleteStubs

func (*UnimplementedMockServer) FindStubs

Jump to

Keyboard shortcuts

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