Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterKernelOrderServer(s grpc.ServiceRegistrar, srv KernelOrderServer)
- type CompleteOrderPaymentRequest
- func (*CompleteOrderPaymentRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CompleteOrderPaymentRequest) GetOrderId() uint64
- func (x *CompleteOrderPaymentRequest) GetTradeNo() string
- func (*CompleteOrderPaymentRequest) ProtoMessage()
- func (x *CompleteOrderPaymentRequest) ProtoReflect() protoreflect.Message
- func (x *CompleteOrderPaymentRequest) Reset()
- func (x *CompleteOrderPaymentRequest) String() string
- type CompleteOrderPaymentResponse
- func (*CompleteOrderPaymentResponse) Descriptor() ([]byte, []int)deprecated
- func (x *CompleteOrderPaymentResponse) GetApplied() bool
- func (x *CompleteOrderPaymentResponse) GetOrderId() uint64
- func (x *CompleteOrderPaymentResponse) GetOutcome() OrderPaymentOutcome
- func (x *CompleteOrderPaymentResponse) GetReason() string
- func (*CompleteOrderPaymentResponse) ProtoMessage()
- func (x *CompleteOrderPaymentResponse) ProtoReflect() protoreflect.Message
- func (x *CompleteOrderPaymentResponse) Reset()
- func (x *CompleteOrderPaymentResponse) String() string
- type KernelOrderClient
- type KernelOrderServer
- type OrderPaymentOutcome
- func (OrderPaymentOutcome) Descriptor() protoreflect.EnumDescriptor
- func (x OrderPaymentOutcome) Enum() *OrderPaymentOutcome
- func (OrderPaymentOutcome) EnumDescriptor() ([]byte, []int)deprecated
- func (x OrderPaymentOutcome) Number() protoreflect.EnumNumber
- func (x OrderPaymentOutcome) String() string
- func (OrderPaymentOutcome) Type() protoreflect.EnumType
- type UnimplementedKernelOrderServer
- type UnsafeKernelOrderServer
Constants ¶
const (
KernelOrder_CompleteOrderPayment_FullMethodName = "/anixops.kernelorder.v1.KernelOrder/CompleteOrderPayment"
)
Variables ¶
var ( OrderPaymentOutcome_name = map[int32]string{ 0: "ORDER_PAYMENT_OUTCOME_UNSPECIFIED", 1: "ORDER_PAYMENT_OUTCOME_COMPLETED", 2: "ORDER_PAYMENT_OUTCOME_PAID", 3: "ORDER_PAYMENT_OUTCOME_REFUSED", } OrderPaymentOutcome_value = map[string]int32{ "ORDER_PAYMENT_OUTCOME_UNSPECIFIED": 0, "ORDER_PAYMENT_OUTCOME_COMPLETED": 1, "ORDER_PAYMENT_OUTCOME_PAID": 2, "ORDER_PAYMENT_OUTCOME_REFUSED": 3, } )
Enum value maps for OrderPaymentOutcome.
var File_api_kernelorder_v1_kernel_order_proto protoreflect.FileDescriptor
var KernelOrder_ServiceDesc = grpc.ServiceDesc{ ServiceName: "anixops.kernelorder.v1.KernelOrder", HandlerType: (*KernelOrderServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "CompleteOrderPayment", Handler: _KernelOrder_CompleteOrderPayment_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "api/kernelorder/v1/kernel_order.proto", }
KernelOrder_ServiceDesc is the grpc.ServiceDesc for KernelOrder service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterKernelOrderServer ¶
func RegisterKernelOrderServer(s grpc.ServiceRegistrar, srv KernelOrderServer)
Types ¶
type CompleteOrderPaymentRequest ¶
type CompleteOrderPaymentRequest struct {
// trade_no is the payment record's trade number
// (v2_payment_record.trade_no), at most 120 bytes.
TradeNo string `protobuf:"bytes,1,opt,name=trade_no,json=tradeNo,proto3" json:"trade_no,omitempty"`
// order_id is the order the record names (v2_payment_record.order_id).
OrderId uint64 `protobuf:"varint,2,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
// contains filtered or unexported fields
}
func (*CompleteOrderPaymentRequest) Descriptor
deprecated
func (*CompleteOrderPaymentRequest) Descriptor() ([]byte, []int)
Deprecated: Use CompleteOrderPaymentRequest.ProtoReflect.Descriptor instead.
func (*CompleteOrderPaymentRequest) GetOrderId ¶
func (x *CompleteOrderPaymentRequest) GetOrderId() uint64
func (*CompleteOrderPaymentRequest) GetTradeNo ¶
func (x *CompleteOrderPaymentRequest) GetTradeNo() string
func (*CompleteOrderPaymentRequest) ProtoMessage ¶
func (*CompleteOrderPaymentRequest) ProtoMessage()
func (*CompleteOrderPaymentRequest) ProtoReflect ¶
func (x *CompleteOrderPaymentRequest) ProtoReflect() protoreflect.Message
func (*CompleteOrderPaymentRequest) Reset ¶
func (x *CompleteOrderPaymentRequest) Reset()
func (*CompleteOrderPaymentRequest) String ¶
func (x *CompleteOrderPaymentRequest) String() string
type CompleteOrderPaymentResponse ¶
type CompleteOrderPaymentResponse struct {
// applied is false when the trade number was applied before; the other
// fields then describe that first application.
Applied bool `protobuf:"varint,1,opt,name=applied,proto3" json:"applied,omitempty"`
OrderId uint64 `protobuf:"varint,2,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
Outcome OrderPaymentOutcome `protobuf:"varint,3,opt,name=outcome,proto3,enum=anixops.kernelorder.v1.OrderPaymentOutcome" json:"outcome,omitempty"`
// reason says why a REFUSED record does not pay its order.
Reason string `protobuf:"bytes,4,opt,name=reason,proto3" json:"reason,omitempty"`
// contains filtered or unexported fields
}
func (*CompleteOrderPaymentResponse) Descriptor
deprecated
func (*CompleteOrderPaymentResponse) Descriptor() ([]byte, []int)
Deprecated: Use CompleteOrderPaymentResponse.ProtoReflect.Descriptor instead.
func (*CompleteOrderPaymentResponse) GetApplied ¶
func (x *CompleteOrderPaymentResponse) GetApplied() bool
func (*CompleteOrderPaymentResponse) GetOrderId ¶
func (x *CompleteOrderPaymentResponse) GetOrderId() uint64
func (*CompleteOrderPaymentResponse) GetOutcome ¶
func (x *CompleteOrderPaymentResponse) GetOutcome() OrderPaymentOutcome
func (*CompleteOrderPaymentResponse) GetReason ¶
func (x *CompleteOrderPaymentResponse) GetReason() string
func (*CompleteOrderPaymentResponse) ProtoMessage ¶
func (*CompleteOrderPaymentResponse) ProtoMessage()
func (*CompleteOrderPaymentResponse) ProtoReflect ¶
func (x *CompleteOrderPaymentResponse) ProtoReflect() protoreflect.Message
func (*CompleteOrderPaymentResponse) Reset ¶
func (x *CompleteOrderPaymentResponse) Reset()
func (*CompleteOrderPaymentResponse) String ¶
func (x *CompleteOrderPaymentResponse) String() string
type KernelOrderClient ¶
type KernelOrderClient interface {
// CompleteOrderPayment applies a paid payment record to the order it
// names, as the kernel's payment callbacks do. The payment module first
// records the payment (the record's status, gateway trade number and
// notify data, and its gateway's statistics) in its own tables and
// commits, then calls this. The kernel reads the record itself and, in
// one transaction:
// 1. requires the record to be paid and to name order_id;
// 2. re-checks that the record pays the order: the order exists, is the
// record's user's, is still pending, and the record's amount covers
// its total. Otherwise the order is left unchanged and the outcome
// is REFUSED;
// 3. marks the order paid;
// 4. completes it: grants its plan with request id "order:<order id>"
// and marks it completed. If the grant fails, the order stays paid
// for an administrator to complete and the outcome is PAID.
//
// It is idempotent per trade number: the outcome is recorded with request
// id "payment:<trade_no>" in the kernel's request ledger, and a repeat
// answers the first outcome with applied false.
//
// NOT_FOUND when no record has the trade number; FAILED_PRECONDITION when
// the record is not paid or names another order (nothing is recorded, a
// later call may apply).
CompleteOrderPayment(ctx context.Context, in *CompleteOrderPaymentRequest, opts ...grpc.CallOption) (*CompleteOrderPaymentResponse, error)
}
KernelOrderClient is the client API for KernelOrder 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.
KernelOrder is the kernel's contract for the order writes that span domains (docs/architecture/order-service.md). Completing a paid order changes the order (v2_order, the order module's table) and grants its plan (v2_user, the kernel's subscriber state) in one transaction; no single module may write both, so the kernel does it for the module that took the payment.
It is served on the module listener and the local package bridge to official packages, by capability:
- kernel.order.complete.v1: CompleteOrderPayment
func NewKernelOrderClient ¶
func NewKernelOrderClient(cc grpc.ClientConnInterface) KernelOrderClient
type KernelOrderServer ¶
type KernelOrderServer interface {
// CompleteOrderPayment applies a paid payment record to the order it
// names, as the kernel's payment callbacks do. The payment module first
// records the payment (the record's status, gateway trade number and
// notify data, and its gateway's statistics) in its own tables and
// commits, then calls this. The kernel reads the record itself and, in
// one transaction:
// 1. requires the record to be paid and to name order_id;
// 2. re-checks that the record pays the order: the order exists, is the
// record's user's, is still pending, and the record's amount covers
// its total. Otherwise the order is left unchanged and the outcome
// is REFUSED;
// 3. marks the order paid;
// 4. completes it: grants its plan with request id "order:<order id>"
// and marks it completed. If the grant fails, the order stays paid
// for an administrator to complete and the outcome is PAID.
//
// It is idempotent per trade number: the outcome is recorded with request
// id "payment:<trade_no>" in the kernel's request ledger, and a repeat
// answers the first outcome with applied false.
//
// NOT_FOUND when no record has the trade number; FAILED_PRECONDITION when
// the record is not paid or names another order (nothing is recorded, a
// later call may apply).
CompleteOrderPayment(context.Context, *CompleteOrderPaymentRequest) (*CompleteOrderPaymentResponse, error)
// contains filtered or unexported methods
}
KernelOrderServer is the server API for KernelOrder service. All implementations must embed UnimplementedKernelOrderServer for forward compatibility.
KernelOrder is the kernel's contract for the order writes that span domains (docs/architecture/order-service.md). Completing a paid order changes the order (v2_order, the order module's table) and grants its plan (v2_user, the kernel's subscriber state) in one transaction; no single module may write both, so the kernel does it for the module that took the payment.
It is served on the module listener and the local package bridge to official packages, by capability:
- kernel.order.complete.v1: CompleteOrderPayment
type OrderPaymentOutcome ¶
type OrderPaymentOutcome int32
OrderPaymentOutcome is what a paid record did to its order.
const ( OrderPaymentOutcome_ORDER_PAYMENT_OUTCOME_UNSPECIFIED OrderPaymentOutcome = 0 // The order was marked paid and completed: its plan is granted. OrderPaymentOutcome_ORDER_PAYMENT_OUTCOME_COMPLETED OrderPaymentOutcome = 1 // The order was marked paid, but granting its plan failed; it stays paid // for an administrator to complete. OrderPaymentOutcome_ORDER_PAYMENT_OUTCOME_PAID OrderPaymentOutcome = 2 // The record does not pay its order (see reason); the order is unchanged // and the payment stays recorded. OrderPaymentOutcome_ORDER_PAYMENT_OUTCOME_REFUSED OrderPaymentOutcome = 3 )
func (OrderPaymentOutcome) Descriptor ¶
func (OrderPaymentOutcome) Descriptor() protoreflect.EnumDescriptor
func (OrderPaymentOutcome) Enum ¶
func (x OrderPaymentOutcome) Enum() *OrderPaymentOutcome
func (OrderPaymentOutcome) EnumDescriptor
deprecated
func (OrderPaymentOutcome) EnumDescriptor() ([]byte, []int)
Deprecated: Use OrderPaymentOutcome.Descriptor instead.
func (OrderPaymentOutcome) Number ¶
func (x OrderPaymentOutcome) Number() protoreflect.EnumNumber
func (OrderPaymentOutcome) String ¶
func (x OrderPaymentOutcome) String() string
func (OrderPaymentOutcome) Type ¶
func (OrderPaymentOutcome) Type() protoreflect.EnumType
type UnimplementedKernelOrderServer ¶
type UnimplementedKernelOrderServer struct{}
UnimplementedKernelOrderServer must be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
func (UnimplementedKernelOrderServer) CompleteOrderPayment ¶
func (UnimplementedKernelOrderServer) CompleteOrderPayment(context.Context, *CompleteOrderPaymentRequest) (*CompleteOrderPaymentResponse, error)
type UnsafeKernelOrderServer ¶
type UnsafeKernelOrderServer interface {
// contains filtered or unexported methods
}
UnsafeKernelOrderServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to KernelOrderServer will result in compilation errors.