Documentation ¶
Index ¶
- Constants
- func RegisterEntryYAML(raw []byte) map[string]rkentry.Entry
- type BootExchange
- type Entry
- func (e *Entry) Bootstrap(ctx context.Context)
- func (e *Entry) Convert(srcUnit, targetUnit string, srcAmount float64) (float64, bool)
- func (e *Entry) GetCurrency(srcUnit, targetUnit string) (float64, bool)
- func (e *Entry) GetDescription() string
- func (e *Entry) GetName() string
- func (e *Entry) GetType() string
- func (e *Entry) Interrupt(ctx context.Context)
- func (e *Entry) ListCurrency(srcUnit string) map[string]float64
- func (e *Entry) MarshalJSON() ([]byte, error)
- func (e *Entry) String() string
- func (e *Entry) UnmarshalJSON([]byte) error
- type ExRateApiSyncer
- type Option
- type StaticSyncer
- type SyncReq
- type SyncResp
- type Syncer
Constants ¶
const (
ExchangeEntryType = "ExchangeEntry"
)
Variables ¶
This section is empty.
Functions ¶
func RegisterEntryYAML ¶
RegisterEntryYAML create entry from config file
Types ¶
type BootExchange ¶
type BootExchange struct { Exchange struct { Enabled bool `yaml:"enabled" json:"enabled"` Name string `yaml:"name" json:"name"` SyncIntervalMin int `yaml:"syncIntervalMin" json:"syncIntervalMin"` BaseUnit string `yaml:"baseUnit" json:"baseUnit"` Static struct { Enabled bool `yaml:"enabled" json:"enabled"` Currency map[string]float64 `yaml:"currency" json:"currency"` } `yaml:"static" json:"static"` Provider struct { ExchangeRateApi struct { Enabled bool `yaml:"enabled" json:"enabled"` ApiKey string `yaml:"apiKey" json:"apiKey"` } `yaml:"exchangeRateApi" json:"exchangeRateApi"` } `yaml:"provider" json:"provider"` } `yaml:"exchange" json:"exchange"` }
BootExchange bootstrap entry from config
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry implementation of rkentry.Entry
func GetExchangeEntry ¶ added in v0.0.2
func (*Entry) GetCurrency ¶
GetCurrency with source unit and target unit
func (*Entry) GetDescription ¶
GetDescription returns description of entry
func (*Entry) ListCurrency ¶
ListCurrency list all currency info
func (*Entry) MarshalJSON ¶
MarshalJSON json marshaller
func (*Entry) UnmarshalJSON ¶
UnmarshalJSON json unmarshaller
type ExRateApiSyncer ¶
ExRateApiSyncer fetch currency info from remote server
func NewExRateApiSyncer ¶
func NewExRateApiSyncer(base, token string) *ExRateApiSyncer
NewExRateApiSyncer create new ExRateApiSyncer
func (*ExRateApiSyncer) GetType ¶
func (e *ExRateApiSyncer) GetType() string
GetType returns type of Syncer
func (*ExRateApiSyncer) Sync ¶
func (e *ExRateApiSyncer) Sync(req *SyncReq) *SyncResp
Sync fetch data from remote server
type Option ¶
type Option func(e *Entry)
Option entry options
func WithSyncIntervalMin ¶
WithSyncIntervalMin provide intervalMin.
type StaticSyncer ¶
StaticSyncer stores static currency info defined by user
func NewStaticSyncer ¶
func NewStaticSyncer(base string, cur map[string]float64) *StaticSyncer
NewStaticSyncer create new StaticSyncer
func (*StaticSyncer) GetType ¶
func (s *StaticSyncer) GetType() string
GetType returns type of Syncer
func (*StaticSyncer) Sync ¶
func (s *StaticSyncer) Sync(req *SyncReq) *SyncResp
Sync fetch data from local memory