Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Enabled indicates if the grpcPricer is to be used. Enabled bool `long:"enabled" description:"Set to true if a gRPC server is available to query for price data"` // GRPCAddress is the address that the pricer gRPC server is serving on. GRPCAddress string `long:"grpcaddress" description:"gRPC addr to use for price info for service resources"` // Insecure indicates if the connection to the gRPC server should use // TLS encryption or not. Insecure bool `long:"insecure" description:"Set to true if no TLS encryption is to be used"` // TLSCertPath is the path the the tls cert used by the price server. TLSCertPath string `long:"tlscertpath" description:"Path to the servers tls cert"` }
Config holds all the config values required to initialise the GRPCPricer.
type DefaultPricer ¶
type DefaultPricer struct {
Price int64
}
DefaultPricer provides the same price for any service path. It implements the Pricer interface.
func NewDefaultPricer ¶
func NewDefaultPricer(price int64) *DefaultPricer
NewDefaultPricer initialises a new DefaultPricer provider where each resource for the service will have the same price.
func (*DefaultPricer) Close ¶
func (d *DefaultPricer) Close() error
Close is part of the Pricer interface. For the DefaultPricer, the method does nothing.
type GRPCPricer ¶
type GRPCPricer struct {
// contains filtered or unexported fields
}
GRPCPricer uses the pricesrpc PricesClient to query a backend server for the price of a service resource given the resource path. It implements the Pricer interface.
func NewGRPCPricer ¶
func NewGRPCPricer(cfg *Config) (*GRPCPricer, error)
NewGRPCPricer initialises a Pricer backed by a gRPC backend server.
func (GRPCPricer) Close ¶
func (c GRPCPricer) Close() error
Close closes the gRPC connection. It is part of the Pricer interface.
type Pricer ¶
type Pricer interface { // GetPrice should return the price in satoshis for the given // resource path. GetPrice(ctx context.Context, req *http.Request) (int64, error) // Close should clean up the Pricer implementation if needed. Close() error }
Pricer is an interface used to query price data from a price provider.