Files
aperture/pricer/defaultPricer.go
Elle Mouton 7fdda6a504 pricer: add pricer package
This commit adds a new pricer package which contains a Pricer interface
and two implementations of the interface. The Pricer interface can be
used to query the price of a certain path. The two implementations are
as follows: a DefaultPricer which returns the same price for all paths
of a service, and a GRPCPricer which queries a backend grpc server for
the price of a given path.
2021-08-03 14:25:45 +02:00

30 lines
759 B
Go

package pricer
import "context"
// DefaultPricer provides the same price for any service path. It implements
// the Pricer interface.
type DefaultPricer struct {
Price int64
}
// NewDefaultPricer initialises a new DefaultPricer provider where each resource
// for the service will have the same price.
func NewDefaultPricer(price int64) *DefaultPricer {
return &DefaultPricer{Price: price}
}
// GetPrice returns the price charged for all resources of a service.
// It is part of the Pricer interface.
func (d *DefaultPricer) GetPrice(_ context.Context, _ string) (int64,
error) {
return d.Price, nil
}
// Close is part of the Pricer interface. For the DefaultPricer, the method does
// nothing.
func (d *DefaultPricer) Close() error {
return nil
}