Documentation ¶
Overview ¶
Package discount used to generate the gRPC client and call the discount service
Index ¶
- Variables
- func DescountPercentage(port string, product int32, timeout int) float32
- func RegisterDiscountServer(s grpc.ServiceRegistrar, srv DiscountServer)
- type DiscountClient
- type DiscountServer
- type GetDiscountRequest
- func (*GetDiscountRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetDiscountRequest) GetProductID() int32
- func (*GetDiscountRequest) ProtoMessage()
- func (x *GetDiscountRequest) ProtoReflect() protoreflect.Message
- func (x *GetDiscountRequest) Reset()
- func (x *GetDiscountRequest) String() string
- type GetDiscountResponse
- func (*GetDiscountResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetDiscountResponse) GetPercentage() float32
- func (*GetDiscountResponse) ProtoMessage()
- func (x *GetDiscountResponse) ProtoReflect() protoreflect.Message
- func (x *GetDiscountResponse) Reset()
- func (x *GetDiscountResponse) String() string
- type UnimplementedDiscountServer
- type UnsafeDiscountServer
Constants ¶
This section is empty.
Variables ¶
var Discount_ServiceDesc = grpc.ServiceDesc{ ServiceName: "discount.Discount", HandlerType: (*DiscountServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetDiscount", Handler: _Discount_GetDiscount_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "discount.proto", }
Discount_ServiceDesc is the grpc.ServiceDesc for Discount service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_discount_proto protoreflect.FileDescriptor
Functions ¶
func DescountPercentage ¶
DescountPercentage uses the generated gRPC client and call the GetDiscount to retrieve 0 or 0.05 percentage In case the service is offline or we can't reach it for any reason, it will return 0
func RegisterDiscountServer ¶
func RegisterDiscountServer(s grpc.ServiceRegistrar, srv DiscountServer)
Types ¶
type DiscountClient ¶
type DiscountClient interface {
GetDiscount(ctx context.Context, in *GetDiscountRequest, opts ...grpc.CallOption) (*GetDiscountResponse, error)
}
DiscountClient is the client API for Discount 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 NewDiscountClient ¶
func NewDiscountClient(cc grpc.ClientConnInterface) DiscountClient
type DiscountServer ¶
type DiscountServer interface { GetDiscount(context.Context, *GetDiscountRequest) (*GetDiscountResponse, error) // contains filtered or unexported methods }
DiscountServer is the server API for Discount service. All implementations must embed UnimplementedDiscountServer for forward compatibility
type GetDiscountRequest ¶
type GetDiscountRequest struct { ProductID int32 `protobuf:"varint,1,opt,name=productID,proto3" json:"productID,omitempty"` // contains filtered or unexported fields }
productID used to represent a product. Ilustrative only.
func (*GetDiscountRequest) Descriptor
deprecated
func (*GetDiscountRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetDiscountRequest.ProtoReflect.Descriptor instead.
func (*GetDiscountRequest) GetProductID ¶
func (x *GetDiscountRequest) GetProductID() int32
func (*GetDiscountRequest) ProtoMessage ¶
func (*GetDiscountRequest) ProtoMessage()
func (*GetDiscountRequest) ProtoReflect ¶
func (x *GetDiscountRequest) ProtoReflect() protoreflect.Message
func (*GetDiscountRequest) Reset ¶
func (x *GetDiscountRequest) Reset()
func (*GetDiscountRequest) String ¶
func (x *GetDiscountRequest) String() string
type GetDiscountResponse ¶
type GetDiscountResponse struct { Percentage float32 `protobuf:"fixed32,1,opt,name=percentage,proto3" json:"percentage,omitempty"` // contains filtered or unexported fields }
The discount percentage is a fixed value.
func (*GetDiscountResponse) Descriptor
deprecated
func (*GetDiscountResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetDiscountResponse.ProtoReflect.Descriptor instead.
func (*GetDiscountResponse) GetPercentage ¶
func (x *GetDiscountResponse) GetPercentage() float32
func (*GetDiscountResponse) ProtoMessage ¶
func (*GetDiscountResponse) ProtoMessage()
func (*GetDiscountResponse) ProtoReflect ¶
func (x *GetDiscountResponse) ProtoReflect() protoreflect.Message
func (*GetDiscountResponse) Reset ¶
func (x *GetDiscountResponse) Reset()
func (*GetDiscountResponse) String ¶
func (x *GetDiscountResponse) String() string
type UnimplementedDiscountServer ¶
type UnimplementedDiscountServer struct { }
UnimplementedDiscountServer must be embedded to have forward compatible implementations.
func (UnimplementedDiscountServer) GetDiscount ¶
func (UnimplementedDiscountServer) GetDiscount(context.Context, *GetDiscountRequest) (*GetDiscountResponse, error)
type UnsafeDiscountServer ¶
type UnsafeDiscountServer interface {
// contains filtered or unexported methods
}
UnsafeDiscountServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to DiscountServer will result in compilation errors.