modelling

This commit is contained in:
mr
2024-12-16 12:17:20 +01:00
parent 02d1e93c78
commit 7696f065f8
9 changed files with 383 additions and 74 deletions

View File

@@ -3,7 +3,6 @@ package pricing
import (
"time"
"cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/tools"
)
@@ -22,33 +21,38 @@ const (
REFUND_ON_EARLY_END
)
type AccessPricingProfile struct { // only use for acces such as : DATA && PROCESSING
utils.DBObject
DefaultRefund RefundType `json:"default_refund" bson:"default_refund"` // DefaultRefund is the default refund type of the pricing
RefundRatio int32 `json:"refund_ratio" bson:"refund_ratio" default:"0"` // RefundRatio is the refund ratio if missing
type AccessPricingProfile[T Strategy] struct { // only use for acces such as : DATA && PROCESSING
ID string `json:"id,omitempty" bson:"id,omitempty"` // ID is the ID of the pricing
Pricing PricingStrategy[T] `json:"price,omitempty" bson:"price,omitempty"` // Price is the price of the resource
DefaultRefund RefundType `json:"default_refund" bson:"default_refund"` // DefaultRefund is the default refund type of the pricing
RefundRatio int32 `json:"refund_ratio" bson:"refund_ratio" default:"0"` // RefundRatio is the refund ratio if missing
}
func (b *AccessPricingProfile) GetOverrideStrategyValue() int {
func (b *AccessPricingProfile[T]) GetID() string {
return b.ID
}
func (b *AccessPricingProfile[T]) GetOverrideStrategyValue() int {
return -1
}
type ExploitPricingStrategy int
type ExploitPrivilegeStrategy int
const (
BASIC ExploitPricingStrategy = iota
BASIC ExploitPrivilegeStrategy = iota
GARANTED_ON_DELAY
GARANTED
)
func (t ExploitPricingStrategy) String() string {
func (t ExploitPrivilegeStrategy) String() string {
return [...]string{"BASIC", "GARANTED_ON_DELAY", "GARANTED"}[t]
}
type ExploitPricingProfile struct { // only use for exploit such as : STORAGE, COMPUTE, WORKFLOW
AccessPricingProfile
type ExploitPricingProfile[T Strategy] struct { // only use for exploit such as : STORAGE, COMPUTE, WORKFLOW
AccessPricingProfile[T]
AdditionnalRefundTypes []RefundType `json:"refund_types" bson:"refund_types"` // RefundTypes is the refund types of the pricing
PrivilegeStrategy ExploitPricingStrategy `json:"privilege_strategy,omitempty" bson:"privilege_strategy,omitempty"` // Strategy is the strategy of the pricing
PrivilegeStrategy ExploitPrivilegeStrategy `json:"privilege_strategy,omitempty" bson:"privilege_strategy,omitempty"` // Strategy is the strategy of the pricing
GarantedDelaySecond uint
Exceeding bool