add event base intelligency
This commit is contained in:
@@ -56,28 +56,6 @@ func NewProcessingInstance(name string, peerID string) ResourceInstanceITF {
|
||||
UUID: uuid.New().String(),
|
||||
Name: name,
|
||||
},
|
||||
Partnerships: []*ResourcePartnerShip[*ProcessingResourcePricingProfile]{
|
||||
{
|
||||
Namespace: "default",
|
||||
PeerGroups: map[string][]string{
|
||||
peerID: {"*"},
|
||||
},
|
||||
PricingProfiles: map[int]map[int]*ProcessingResourcePricingProfile{
|
||||
0: {
|
||||
0: &ProcessingResourcePricingProfile{
|
||||
AccessPricingProfile: pricing.AccessPricingProfile[pricing.TimePricingStrategy]{
|
||||
Pricing: pricing.PricingStrategy[pricing.TimePricingStrategy]{
|
||||
Price: 0,
|
||||
Currency: "EUR",
|
||||
TimePricingStrategy: pricing.ONCE,
|
||||
BuyingStrategy: pricing.PERMANENT,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -92,16 +70,19 @@ func (r *PricedProcessingResource) GetType() tools.DataType {
|
||||
}
|
||||
|
||||
func (a *PricedProcessingResource) GetExplicitDurationInS() float64 {
|
||||
if a.ExplicitBookingDurationS == 0 {
|
||||
if a.IsService || a.UsageStart == nil {
|
||||
if a.BookingConfiguration == nil {
|
||||
a.BookingConfiguration = &BookingConfiguration{}
|
||||
}
|
||||
if a.BookingConfiguration.ExplicitBookingDurationS == 0 {
|
||||
if a.IsService || a.BookingConfiguration.UsageStart == nil {
|
||||
if a.IsService {
|
||||
return -1
|
||||
}
|
||||
return time.Duration(1 * time.Hour).Seconds()
|
||||
}
|
||||
return a.UsageEnd.Sub(*a.UsageStart).Seconds()
|
||||
return a.BookingConfiguration.UsageEnd.Sub(*a.BookingConfiguration.UsageStart).Seconds()
|
||||
}
|
||||
return a.ExplicitBookingDurationS
|
||||
return a.BookingConfiguration.ExplicitBookingDurationS
|
||||
}
|
||||
|
||||
func (d *ProcessingResource) GetAccessor(request *tools.APIRequest) utils.Accessor {
|
||||
@@ -119,11 +100,3 @@ func (p *ProcessingResourcePricingProfile) IsPurchasable() bool {
|
||||
func (p *ProcessingResourcePricingProfile) IsBooked() bool {
|
||||
return p.Pricing.BuyingStrategy != pricing.PERMANENT
|
||||
}
|
||||
|
||||
func (p *ProcessingResourcePricingProfile) GetPurchase() pricing.BuyingStrategy {
|
||||
return p.Pricing.BuyingStrategy
|
||||
}
|
||||
|
||||
func (p *ProcessingResourcePricingProfile) GetPrice(amountOfData float64, val float64, start time.Time, end time.Time, params ...string) (float64, error) {
|
||||
return p.Pricing.GetPrice(amountOfData, val, start, &end)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user