Documentation
¶
Index ¶
- Variables
- func AddProduct(product Product) error
- func Setup(d *sql.DB, sqlTblPrefix string) error
- func TerminateProduct(ProductID uint64) error
- func UpdateProduct(productID uint64, product Product) error
- type BillingCycle
- type Product
- type Wallet
- func (w *Wallet) AvailableFund() (float64, error)
- func (w *Wallet) Balance() (float64, error)
- func (w *Wallet) Charge(amount float64) error
- func (w *Wallet) Deposit(amount float64) error
- func (w *Wallet) SecureFund(amount float64) error
- func (w *Wallet) Secured() (float64, error)
- func (w *Wallet) Spend(amount float64) error
- func (w *Wallet) SpendSecured(amount float64) error
- func (w *Wallet) UndoSecureFund(amount float64) error
- func (w *Wallet) UploadPubkey(pubkey []byte, signature string) error
- func (w *Wallet) VerifySignature(signature, data string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrBadAmount error = errors.New("billing: bad amount input")
)
Functions ¶
func UpdateProduct ¶
UpdateProduct() effectively updates OwnerID, ServerType, InstanceID, WalletID for the product specified by ProductID
Types ¶
type BillingCycle ¶
type BillingCycle uint8
const ( PayAsYouGo BillingCycle = iota PerMonth PerQuarter PerYear )
type Product ¶
type Product struct {
ProductID uint64
// Ownership
OwnerID uint64
// Server-Account binding
ServerType string
InstanceID string
// billing/payment
DateCreation time.Time // Accurate to DAY only
DateTermination time.Time // Accurate to DAY only
BillingCycle BillingCycle
WalletID uint64
}
func ListActiveProductsByBillingCycle ¶
func ListActiveProductsByBillingCycle(billingCycle BillingCycle) ([]Product, error)
For billing purposes
func ListAllProducts ¶
For admin viewing. Caller should do local pagination
func ListUserProducts ¶
For user viewing. Caller should do local pagination
func SelectProduct ¶
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
func UserWallet ¶
func WalletByID ¶
WalletByID() build a Wallet struct reflecting an entry in the database.
func (*Wallet) AvailableFund ¶
func (*Wallet) Charge ¶
Charge() is unsafe version of Spend(). It doesn't fail when user can't afford it. USE ONLY FOR POST-USE BILLING
func (*Wallet) SecureFund ¶
func (*Wallet) Spend ¶
Spend() is safe. i.e., it does not leave a negative balance will return error if not enough balance to spend
func (*Wallet) SpendSecured ¶
func (*Wallet) UndoSecureFund ¶
func (*Wallet) UploadPubkey ¶
Use Ed25519 TODO: Upload to Database
func (*Wallet) VerifySignature ¶
TODO: VerifySignature()
Click to show internal directories.
Click to hide internal directories.