discount

package
v0.0.0-...-2f9ccf3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package discount used to generate the gRPC client and call the discount service

Index

Constants

This section is empty.

Variables

View Source
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)

View Source
var File_discount_proto protoreflect.FileDescriptor

Functions

func DescountPercentage

func DescountPercentage(port string, product int32, timeout int) float32

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

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.

Jump to

Keyboard shortcuts

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