v1

package
v0.0.0-...-4c0fd1a Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 30 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 (
	ErrorReason_name = map[int32]string{
		0: "CHAT_NOT_FOUND",
		1: "USER_NOT_FOUND",
	}
	ErrorReason_value = map[string]int32{
		"CHAT_NOT_FOUND": 0,
		"USER_NOT_FOUND": 1,
	}
)

Enum value maps for ErrorReason.

View Source
var File_messenger_v1_error_reason_proto protoreflect.FileDescriptor
View Source
var File_messenger_v1_messenger_proto protoreflect.FileDescriptor
View Source
var Messenger_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "api.messenger.v1.Messenger",
	HandlerType: (*MessengerServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Send",
			Handler:    _Messenger_Send_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Subscribe",
			Handler:       _Messenger_Subscribe_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "messenger/v1/messenger.proto",
}

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

Functions

func RegisterMessengerHandler

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

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

func RegisterMessengerHandlerClient

func RegisterMessengerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MessengerClient) error

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

func RegisterMessengerHandlerFromEndpoint

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

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

func RegisterMessengerHandlerServer

func RegisterMessengerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MessengerServer) error

RegisterMessengerHandlerServer registers the http handlers for service Messenger to "mux". UnaryRPC :call MessengerServer 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 RegisterMessengerHandlerFromEndpoint instead.

func RegisterMessengerServer

func RegisterMessengerServer(s grpc.ServiceRegistrar, srv MessengerServer)

Types

type ErrorReason

type ErrorReason int32
const (
	ErrorReason_CHAT_NOT_FOUND ErrorReason = 0
	ErrorReason_USER_NOT_FOUND ErrorReason = 1
)

func (ErrorReason) Descriptor

func (ErrorReason) Enum

func (x ErrorReason) Enum() *ErrorReason

func (ErrorReason) EnumDescriptor deprecated

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

Deprecated: Use ErrorReason.Descriptor instead.

func (ErrorReason) Number

func (x ErrorReason) Number() protoreflect.EnumNumber

func (ErrorReason) String

func (x ErrorReason) String() string

func (ErrorReason) Type

type MessengerClient

type MessengerClient interface {
	Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (Messenger_SubscribeClient, error)
	Send(ctx context.Context, in *SendRequest, opts ...grpc.CallOption) (*NewMessage, error)
}

MessengerClient is the client API for Messenger 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 NewMessengerClient

func NewMessengerClient(cc grpc.ClientConnInterface) MessengerClient

type MessengerServer

type MessengerServer interface {
	Subscribe(*SubscribeRequest, Messenger_SubscribeServer) error
	Send(context.Context, *SendRequest) (*NewMessage, error)
	// contains filtered or unexported methods
}

MessengerServer is the server API for Messenger service. All implementations must embed UnimplementedMessengerServer for forward compatibility

type Messenger_SubscribeClient

type Messenger_SubscribeClient interface {
	Recv() (*NewMessage, error)
	grpc.ClientStream
}

type Messenger_SubscribeServer

type Messenger_SubscribeServer interface {
	Send(*NewMessage) error
	grpc.ServerStream
}

type NewMessage

type NewMessage struct {
	Id        int64                  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	User      *NewMessage_User       `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"`
	Text      string                 `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"`
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

func (*NewMessage) Descriptor deprecated

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

Deprecated: Use NewMessage.ProtoReflect.Descriptor instead.

func (*NewMessage) GetId

func (x *NewMessage) GetId() int64

func (*NewMessage) GetText

func (x *NewMessage) GetText() string

func (*NewMessage) GetTimestamp

func (x *NewMessage) GetTimestamp() *timestamppb.Timestamp

func (*NewMessage) GetUser

func (x *NewMessage) GetUser() *NewMessage_User

func (*NewMessage) ProtoMessage

func (*NewMessage) ProtoMessage()

func (*NewMessage) ProtoReflect

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

func (*NewMessage) Reset

func (x *NewMessage) Reset()

func (*NewMessage) String

func (x *NewMessage) String() string

func (*NewMessage) Validate

func (m *NewMessage) Validate() error

Validate checks the field values on NewMessage with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*NewMessage) ValidateAll

func (m *NewMessage) ValidateAll() error

ValidateAll checks the field values on NewMessage with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in NewMessageMultiError, or nil if none found.

type NewMessageMultiError

type NewMessageMultiError []error

NewMessageMultiError is an error wrapping multiple validation errors returned by NewMessage.ValidateAll() if the designated constraints aren't met.

func (NewMessageMultiError) AllErrors

func (m NewMessageMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (NewMessageMultiError) Error

func (m NewMessageMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type NewMessageValidationError

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

NewMessageValidationError is the validation error returned by NewMessage.Validate if the designated constraints aren't met.

func (NewMessageValidationError) Cause

func (e NewMessageValidationError) Cause() error

Cause function returns cause value.

func (NewMessageValidationError) Error

Error satisfies the builtin error interface

func (NewMessageValidationError) ErrorName

func (e NewMessageValidationError) ErrorName() string

ErrorName returns error name.

func (NewMessageValidationError) Field

Field function returns field value.

func (NewMessageValidationError) Key

Key function returns key value.

func (NewMessageValidationError) Reason

func (e NewMessageValidationError) Reason() string

Reason function returns reason value.

type NewMessage_User

type NewMessage_User struct {
	Id    int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Name  string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Color string `protobuf:"bytes,3,opt,name=color,proto3" json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (*NewMessage_User) Descriptor deprecated

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

Deprecated: Use NewMessage_User.ProtoReflect.Descriptor instead.

func (*NewMessage_User) GetColor

func (x *NewMessage_User) GetColor() string

func (*NewMessage_User) GetId

func (x *NewMessage_User) GetId() int64

func (*NewMessage_User) GetName

func (x *NewMessage_User) GetName() string

func (*NewMessage_User) ProtoMessage

func (*NewMessage_User) ProtoMessage()

func (*NewMessage_User) ProtoReflect

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

func (*NewMessage_User) Reset

func (x *NewMessage_User) Reset()

func (*NewMessage_User) String

func (x *NewMessage_User) String() string

func (*NewMessage_User) Validate

func (m *NewMessage_User) Validate() error

Validate checks the field values on NewMessage_User with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*NewMessage_User) ValidateAll

func (m *NewMessage_User) ValidateAll() error

ValidateAll checks the field values on NewMessage_User with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in NewMessage_UserMultiError, or nil if none found.

type NewMessage_UserMultiError

type NewMessage_UserMultiError []error

NewMessage_UserMultiError is an error wrapping multiple validation errors returned by NewMessage_User.ValidateAll() if the designated constraints aren't met.

func (NewMessage_UserMultiError) AllErrors

func (m NewMessage_UserMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (NewMessage_UserMultiError) Error

Error returns a concatenation of all the error messages it wraps.

type NewMessage_UserValidationError

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

NewMessage_UserValidationError is the validation error returned by NewMessage_User.Validate if the designated constraints aren't met.

func (NewMessage_UserValidationError) Cause

Cause function returns cause value.

func (NewMessage_UserValidationError) Error

Error satisfies the builtin error interface

func (NewMessage_UserValidationError) ErrorName

func (e NewMessage_UserValidationError) ErrorName() string

ErrorName returns error name.

func (NewMessage_UserValidationError) Field

Field function returns field value.

func (NewMessage_UserValidationError) Key

Key function returns key value.

func (NewMessage_UserValidationError) Reason

Reason function returns reason value.

type SendRequest

type SendRequest struct {
	ChatId int64  `protobuf:"varint,1,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
	Text   string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"`
	// contains filtered or unexported fields
}

func (*SendRequest) Descriptor deprecated

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

Deprecated: Use SendRequest.ProtoReflect.Descriptor instead.

func (*SendRequest) GetChatId

func (x *SendRequest) GetChatId() int64

func (*SendRequest) GetText

func (x *SendRequest) GetText() string

func (*SendRequest) ProtoMessage

func (*SendRequest) ProtoMessage()

func (*SendRequest) ProtoReflect

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

func (*SendRequest) Reset

func (x *SendRequest) Reset()

func (*SendRequest) String

func (x *SendRequest) String() string

func (*SendRequest) Validate

func (m *SendRequest) Validate() error

Validate checks the field values on SendRequest with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*SendRequest) ValidateAll

func (m *SendRequest) ValidateAll() error

ValidateAll checks the field values on SendRequest with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in SendRequestMultiError, or nil if none found.

type SendRequestMultiError

type SendRequestMultiError []error

SendRequestMultiError is an error wrapping multiple validation errors returned by SendRequest.ValidateAll() if the designated constraints aren't met.

func (SendRequestMultiError) AllErrors

func (m SendRequestMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (SendRequestMultiError) Error

func (m SendRequestMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type SendRequestValidationError

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

SendRequestValidationError is the validation error returned by SendRequest.Validate if the designated constraints aren't met.

func (SendRequestValidationError) Cause

Cause function returns cause value.

func (SendRequestValidationError) Error

Error satisfies the builtin error interface

func (SendRequestValidationError) ErrorName

func (e SendRequestValidationError) ErrorName() string

ErrorName returns error name.

func (SendRequestValidationError) Field

Field function returns field value.

func (SendRequestValidationError) Key

Key function returns key value.

func (SendRequestValidationError) Reason

Reason function returns reason value.

type SubscribeRequest

type SubscribeRequest struct {
	ChatId int64 `protobuf:"varint,1,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
	// contains filtered or unexported fields
}

func (*SubscribeRequest) Descriptor deprecated

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

Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead.

func (*SubscribeRequest) GetChatId

func (x *SubscribeRequest) GetChatId() int64

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) ProtoReflect

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

func (*SubscribeRequest) Reset

func (x *SubscribeRequest) Reset()

func (*SubscribeRequest) String

func (x *SubscribeRequest) String() string

func (*SubscribeRequest) Validate

func (m *SubscribeRequest) Validate() error

Validate checks the field values on SubscribeRequest with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*SubscribeRequest) ValidateAll

func (m *SubscribeRequest) ValidateAll() error

ValidateAll checks the field values on SubscribeRequest with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in SubscribeRequestMultiError, or nil if none found.

type SubscribeRequestMultiError

type SubscribeRequestMultiError []error

SubscribeRequestMultiError is an error wrapping multiple validation errors returned by SubscribeRequest.ValidateAll() if the designated constraints aren't met.

func (SubscribeRequestMultiError) AllErrors

func (m SubscribeRequestMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (SubscribeRequestMultiError) Error

Error returns a concatenation of all the error messages it wraps.

type SubscribeRequestValidationError

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

SubscribeRequestValidationError is the validation error returned by SubscribeRequest.Validate if the designated constraints aren't met.

func (SubscribeRequestValidationError) Cause

Cause function returns cause value.

func (SubscribeRequestValidationError) Error

Error satisfies the builtin error interface

func (SubscribeRequestValidationError) ErrorName

ErrorName returns error name.

func (SubscribeRequestValidationError) Field

Field function returns field value.

func (SubscribeRequestValidationError) Key

Key function returns key value.

func (SubscribeRequestValidationError) Reason

Reason function returns reason value.

type UnimplementedMessengerServer

type UnimplementedMessengerServer struct {
}

UnimplementedMessengerServer must be embedded to have forward compatible implementations.

func (UnimplementedMessengerServer) Send

func (UnimplementedMessengerServer) Subscribe

type UnsafeMessengerServer

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

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

Jump to

Keyboard shortcuts

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