Documentation ¶
Index ¶
Constants ¶
const ( ContractStateUnknown = uint8(iota) ContractStateAllowed ContractStateRefused )
The contract's state possible values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contract ¶
type Contract interface { Validate(key security.Key) bool // Validate checks the security key with the contract. Stats() usage.Meter // Gets the usage statistics. }
Contract represents an interface for a contract.
type HTTPContractProvider ¶
type HTTPContractProvider struct {
// contains filtered or unexported fields
}
HTTPContractProvider provides contracts over http.
func NewHTTPContractProvider ¶
func NewHTTPContractProvider(license license.License, metering usage.Metering) *HTTPContractProvider
NewHTTPContractProvider creates a new single contract provider.
func (*HTTPContractProvider) Close ¶
func (p *HTTPContractProvider) Close() error
Close closes the provider.
func (*HTTPContractProvider) Configure ¶
func (p *HTTPContractProvider) Configure(config map[string]interface{}) (err error)
Configure configures the provider.
func (*HTTPContractProvider) Create ¶
func (p *HTTPContractProvider) Create() (Contract, error)
Create creates a contract, the HTTPContractProvider way.
func (*HTTPContractProvider) Get ¶
func (p *HTTPContractProvider) Get(id uint32) (Contract, bool)
Get returns a ContractData fetched by its id.
func (*HTTPContractProvider) Name ¶
func (p *HTTPContractProvider) Name() string
Name returns the name of the provider.
type NoopContractProvider ¶
type NoopContractProvider struct{}
NoopContractProvider does not provide a contract.
func NewNoopContractProvider ¶
func NewNoopContractProvider() *NoopContractProvider
NewNoopContractProvider creates a new no-op contract provider.
func (*NoopContractProvider) Configure ¶
func (p *NoopContractProvider) Configure(config map[string]interface{}) error
Configure configures the provider.
func (*NoopContractProvider) Create ¶
func (p *NoopContractProvider) Create() (Contract, error)
Create creates a contract, the SingleContractProvider way.
func (*NoopContractProvider) Get ¶
func (p *NoopContractProvider) Get(id uint32) (Contract, bool)
Get returns a ContractData fetched by its id.
func (*NoopContractProvider) Name ¶
func (p *NoopContractProvider) Name() string
Name returns the name of the provider.
type Provider ¶
type Provider interface { config.Provider Create() (Contract, error) Get(id uint32) (Contract, bool) }
Provider represents an interface for a contract provider.
type SingleContractProvider ¶
type SingleContractProvider struct {
// contains filtered or unexported fields
}
SingleContractProvider provides contracts on premise.
func NewSingleContractProvider ¶
func NewSingleContractProvider(license license.License, metering usage.Metering) *SingleContractProvider
NewSingleContractProvider creates a new single contract provider.
func (*SingleContractProvider) Configure ¶
func (p *SingleContractProvider) Configure(config map[string]interface{}) error
Configure configures the provider.
func (*SingleContractProvider) Create ¶
func (p *SingleContractProvider) Create() (Contract, error)
Create creates a contract, the SingleContractProvider way.
func (*SingleContractProvider) Get ¶
func (p *SingleContractProvider) Get(id uint32) (Contract, bool)
Get returns a ContractData fetched by its id.
func (*SingleContractProvider) Name ¶
func (p *SingleContractProvider) Name() string
Name returns the name of the provider.