Documentation ¶
Overview ¶
Package proto is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterExchangerHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterExchangerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ExchangerClient) error
- func RegisterExchangerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterExchangerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExchangerServer) error
- func RegisterExchangerServer(s grpc.ServiceRegistrar, srv ExchangerServer)
- type Currency
- type ExchangeRequest
- func (*ExchangeRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ExchangeRequest) GetAmount() float64
- func (x *ExchangeRequest) GetFrom() Currency
- func (x *ExchangeRequest) GetRate() float64
- func (x *ExchangeRequest) GetTo() Currency
- func (*ExchangeRequest) ProtoMessage()
- func (x *ExchangeRequest) ProtoReflect() protoreflect.Message
- func (x *ExchangeRequest) Reset()
- func (x *ExchangeRequest) String() string
- type ExchangeResponse
- func (*ExchangeResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ExchangeResponse) GetConvertedValue() float64
- func (x *ExchangeResponse) GetCurrencySymbol() string
- func (*ExchangeResponse) ProtoMessage()
- func (x *ExchangeResponse) ProtoReflect() protoreflect.Message
- func (x *ExchangeResponse) Reset()
- func (x *ExchangeResponse) String() string
- type ExchangerClient
- type ExchangerServer
- type UnimplementedExchangerServer
- type UnsafeExchangerServer
Constants ¶
This section is empty.
Variables ¶
var ( Currency_name = map[int32]string{ 0: "USD", 1: "BRL", 2: "EUR", 3: "BTC", } Currency_value = map[string]int32{ "USD": 0, "BRL": 1, "EUR": 2, "BTC": 3, } )
Enum value maps for Currency.
var Exchanger_ServiceDesc = grpc.ServiceDesc{ ServiceName: "proto.Exchanger", HandlerType: (*ExchangerServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Exchange", Handler: _Exchanger_Exchange_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "currency.proto", }
Exchanger_ServiceDesc is the grpc.ServiceDesc for Exchanger service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_currency_proto protoreflect.FileDescriptor
Functions ¶
func RegisterExchangerHandler ¶
func RegisterExchangerHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterExchangerHandler registers the http handlers for service Exchanger to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterExchangerHandlerClient ¶
func RegisterExchangerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ExchangerClient) error
RegisterExchangerHandlerClient registers the http handlers for service Exchanger to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ExchangerClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ExchangerClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ExchangerClient" to call the correct interceptors.
func RegisterExchangerHandlerFromEndpoint ¶
func RegisterExchangerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterExchangerHandlerFromEndpoint is same as RegisterExchangerHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterExchangerHandlerServer ¶
func RegisterExchangerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExchangerServer) error
RegisterExchangerHandlerServer registers the http handlers for service Exchanger to "mux". UnaryRPC :call ExchangerServer 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 RegisterExchangerHandlerFromEndpoint instead.
func RegisterExchangerServer ¶
func RegisterExchangerServer(s grpc.ServiceRegistrar, srv ExchangerServer)
Types ¶
type Currency ¶
type Currency int32
func (Currency) Descriptor ¶
func (Currency) Descriptor() protoreflect.EnumDescriptor
func (Currency) EnumDescriptor
deprecated
func (Currency) Number ¶
func (x Currency) Number() protoreflect.EnumNumber
func (Currency) Type ¶
func (Currency) Type() protoreflect.EnumType
type ExchangeRequest ¶
type ExchangeRequest struct { // Amount is the amount of money to convert. Amount float64 `protobuf:"fixed64,1,opt,name=amount,proto3" json:"amount,omitempty"` // Rate is the proportion rate between the currencies. Rate float64 `protobuf:"fixed64,2,opt,name=rate,proto3" json:"rate,omitempty"` // From is the currency to be converted from. From Currency `protobuf:"varint,3,opt,name=from,proto3,enum=proto.Currency" json:"from,omitempty"` // To is the currency to be converted to. To Currency `protobuf:"varint,4,opt,name=to,proto3,enum=proto.Currency" json:"to,omitempty"` // contains filtered or unexported fields }
ExchangeRequest contains the information to exchange a currency to another.
func (*ExchangeRequest) Descriptor
deprecated
func (*ExchangeRequest) Descriptor() ([]byte, []int)
Deprecated: Use ExchangeRequest.ProtoReflect.Descriptor instead.
func (*ExchangeRequest) GetAmount ¶
func (x *ExchangeRequest) GetAmount() float64
func (*ExchangeRequest) GetFrom ¶
func (x *ExchangeRequest) GetFrom() Currency
func (*ExchangeRequest) GetRate ¶
func (x *ExchangeRequest) GetRate() float64
func (*ExchangeRequest) GetTo ¶
func (x *ExchangeRequest) GetTo() Currency
func (*ExchangeRequest) ProtoMessage ¶
func (*ExchangeRequest) ProtoMessage()
func (*ExchangeRequest) ProtoReflect ¶
func (x *ExchangeRequest) ProtoReflect() protoreflect.Message
func (*ExchangeRequest) Reset ¶
func (x *ExchangeRequest) Reset()
func (*ExchangeRequest) String ¶
func (x *ExchangeRequest) String() string
type ExchangeResponse ¶
type ExchangeResponse struct { // ConvertedValue is the amount value after the exchange. ConvertedValue float64 `protobuf:"fixed64,1,opt,name=convertedValue,json=valorConvertido,proto3" json:"convertedValue,omitempty"` // CurrencySymbol is the symbol of the the currency after // the exchange. CurrencySymbol string `protobuf:"bytes,2,opt,name=currencySymbol,json=simboloMoeda,proto3" json:"currencySymbol,omitempty"` // contains filtered or unexported fields }
ExchangeResponse is the response of a exchange.
func (*ExchangeResponse) Descriptor
deprecated
func (*ExchangeResponse) Descriptor() ([]byte, []int)
Deprecated: Use ExchangeResponse.ProtoReflect.Descriptor instead.
func (*ExchangeResponse) GetConvertedValue ¶
func (x *ExchangeResponse) GetConvertedValue() float64
func (*ExchangeResponse) GetCurrencySymbol ¶
func (x *ExchangeResponse) GetCurrencySymbol() string
func (*ExchangeResponse) ProtoMessage ¶
func (*ExchangeResponse) ProtoMessage()
func (*ExchangeResponse) ProtoReflect ¶
func (x *ExchangeResponse) ProtoReflect() protoreflect.Message
func (*ExchangeResponse) Reset ¶
func (x *ExchangeResponse) Reset()
func (*ExchangeResponse) String ¶
func (x *ExchangeResponse) String() string
type ExchangerClient ¶
type ExchangerClient interface { // Exchange exchanges a amount of money from one currency to another. Exchange(ctx context.Context, in *ExchangeRequest, opts ...grpc.CallOption) (*ExchangeResponse, error) }
ExchangerClient is the client API for Exchanger 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 NewExchangerClient ¶
func NewExchangerClient(cc grpc.ClientConnInterface) ExchangerClient
type ExchangerServer ¶
type ExchangerServer interface { // Exchange exchanges a amount of money from one currency to another. Exchange(context.Context, *ExchangeRequest) (*ExchangeResponse, error) // contains filtered or unexported methods }
ExchangerServer is the server API for Exchanger service. All implementations must embed UnimplementedExchangerServer for forward compatibility
type UnimplementedExchangerServer ¶
type UnimplementedExchangerServer struct { }
UnimplementedExchangerServer must be embedded to have forward compatible implementations.
func (UnimplementedExchangerServer) Exchange ¶
func (UnimplementedExchangerServer) Exchange(context.Context, *ExchangeRequest) (*ExchangeResponse, error)
type UnsafeExchangerServer ¶
type UnsafeExchangerServer interface {
// contains filtered or unexported methods
}
UnsafeExchangerServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ExchangerServer will result in compilation errors.