Documentation ¶
Index ¶
- Constants
- type BillableEventRows
- type Config
- type EventStore
- func (s *EventStore) ForecastBillableEventRows(events []eventio.UsageEvent, filter eventio.EventFilter) (eventio.BillableEventRows, error)
- func (s *EventStore) ForecastBillableEvents(input []eventio.UsageEvent, filter eventio.EventFilter) ([]eventio.BillableEvent, error)
- func (s *EventStore) GetBillableEventRows(filter eventio.EventFilter) (eventio.BillableEventRows, error)
- func (s *EventStore) GetBillableEvents(filter eventio.EventFilter) ([]eventio.BillableEvent, error)
- func (s *EventStore) GetEvents(filter eventio.RawEventFilter) ([]eventio.RawEvent, error)
- func (s *EventStore) GetPricingPlans(filter eventio.PricingPlanFilter) ([]eventio.PricingPlan, error)
- func (s *EventStore) GetUsageEventRows(filter eventio.EventFilter) (eventio.UsageEventRows, error)
- func (s *EventStore) GetUsageEvents(filter eventio.EventFilter) ([]eventio.UsageEvent, error)
- func (s *EventStore) Init() error
- func (s *EventStore) Refresh() error
- func (s *EventStore) StoreEvents(events []eventio.RawEvent) error
- type UsageEventRows
Constants ¶
const ( AppUsageTableName = "app_usage_events" ServiceUsageTableName = "service_usage_events" ComputePlanGUID = "f4d4b95a-f55e-4593-8d54-3364c25798c4" ComputeServiceGUID = "4f6f0a18-cdd4-4e51-8b6b-dc39b696e61b" TaskPlanGUID = "ebfa9453-ef66-450c-8c37-d53dfd931038" StagingPlanGUID = "9d071c77-7a68-4346-9981-e8dafac95b6f" DefaultInitTimeout = 5 * time.Minute DefaultRefreshTimeout = 5 * time.Minute DefaultStoreTimeout = 45 * time.Second DefaultQueryTimeout = 45 * time.Second )
const ( DummyOrgGUID = "00000001-0000-0000-0000-000000000000" DummySpaceGUID = "00000001-0001-0000-0000-000000000000" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BillableEventRows ¶
type BillableEventRows struct {
// contains filtered or unexported fields
}
func (*BillableEventRows) Close ¶
func (ber *BillableEventRows) Close() error
Close ends the query connection. You must call this. So stick it in a defer.
func (*BillableEventRows) Err ¶
func (ber *BillableEventRows) Err() error
Err returns any errors that occured behind the scenes during processing. Call this at the end of your iteration.
func (*BillableEventRows) Event ¶
func (ber *BillableEventRows) Event() (*eventio.BillableEvent, error)
Event returns the current row's BillableEvent. Call Next() to get the next row. You must call Next _before_ calling this method
func (*BillableEventRows) EventJSON ¶
func (ber *BillableEventRows) EventJSON() ([]byte, error)
EventJSON returns the JSON representation of the event directly from the db. If you are just going to marshel the object to JSON immediately, then this is probably more effcient.
func (*BillableEventRows) Next ¶
func (ber *BillableEventRows) Next() bool
Next moves the row cursor to the next iteration. Returns false if no more rows.
type Config ¶
type Config struct { VATRates []eventio.VATRate `json:"vat_rates"` // vat rate CurrencyRates []eventio.CurrencyRate `json:"currency_rates"` // exchange rates PricingPlans []eventio.PricingPlan `json:"pricing_plans"` // dataset to generate prices from IgnoreMissingPlans bool `json:"ignore_missing_plans"` // if true, will generate missing plans that emit "£0", useful for testing }
func LoadConfig ¶
func (*Config) AddCurrencyRate ¶
func (cfg *Config) AddCurrencyRate(c eventio.CurrencyRate)
func (*Config) AddPlan ¶
func (cfg *Config) AddPlan(p eventio.PricingPlan)
func (*Config) AddVATRate ¶
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
func NewFromConfig ¶
func (*EventStore) ForecastBillableEventRows ¶
func (s *EventStore) ForecastBillableEventRows(events []eventio.UsageEvent, filter eventio.EventFilter) (eventio.BillableEventRows, error)
func (*EventStore) ForecastBillableEvents ¶
func (s *EventStore) ForecastBillableEvents(input []eventio.UsageEvent, filter eventio.EventFilter) ([]eventio.BillableEvent, error)
func (*EventStore) GetBillableEventRows ¶
func (s *EventStore) GetBillableEventRows(filter eventio.EventFilter) (eventio.BillableEventRows, error)
GetBillableEventRows returns a handle to a resultset of BillableEvents. Use this to iterate over rows without buffering all into memory. You must call rows.Close when you are done to release the connection. Use GetBillableEvents if you intend on buffering everything into memory.
func (*EventStore) GetBillableEvents ¶
func (s *EventStore) GetBillableEvents(filter eventio.EventFilter) ([]eventio.BillableEvent, error)
GetBillableEvents returns a slice of billable events for the given filter. Due to the large number of results that can be returned it is recormended you use the GetBillableEventRows version to avoid buffering everything into memory
func (*EventStore) GetEvents ¶
func (s *EventStore) GetEvents(filter eventio.RawEventFilter) ([]eventio.RawEvent, error)
GetEvents returns the eventio.RawEvents filtered using eventio.RawEventFilter if present
func (*EventStore) GetPricingPlans ¶ added in v0.24.0
func (s *EventStore) GetPricingPlans(filter eventio.PricingPlanFilter) ([]eventio.PricingPlan, error)
func (*EventStore) GetUsageEventRows ¶
func (s *EventStore) GetUsageEventRows(filter eventio.EventFilter) (eventio.UsageEventRows, error)
GetUsageEventRows returns a handle to a resultset of UsageEvents. Use this to iterate over rows without buffering all into memory. You must call rows.Close when you are done to release the connection. Use GetUsageEvents if you intend on buffering everything into memory.
func (*EventStore) GetUsageEvents ¶
func (s *EventStore) GetUsageEvents(filter eventio.EventFilter) ([]eventio.UsageEvent, error)
GetUsageEvents returns a slice of usage events for the given filter. Due to the large number of results that can be returned it is recormended you use the GetUsageEventRows version to avoid buffering everything into memory
func (*EventStore) Init ¶
func (s *EventStore) Init() error
Init initialises the database tables and functions
func (*EventStore) Refresh ¶
func (s *EventStore) Refresh() error
Refresh triggers regeneration of the cached normalized view of the event dat and rebuilds the billable components. Ideally you should do this once a day
func (*EventStore) StoreEvents ¶
func (s *EventStore) StoreEvents(events []eventio.RawEvent) error
type UsageEventRows ¶
type UsageEventRows struct {
// contains filtered or unexported fields
}
func (*UsageEventRows) Close ¶
func (ber *UsageEventRows) Close() error
Close ends the query connection. You must call this. So stick it in a defer.
func (*UsageEventRows) Err ¶
func (ber *UsageEventRows) Err() error
Err returns any errors that occured behind the scenes during processing. Call this at the end of your iteration.
func (*UsageEventRows) Event ¶
func (ber *UsageEventRows) Event() (*eventio.UsageEvent, error)
Event returns the current row's UsageEvent. Call Next() to get the next row. You must call Next _before_ calling this method
func (*UsageEventRows) EventJSON ¶
func (ber *UsageEventRows) EventJSON() ([]byte, error)
EventJSON returns the JSON representation of the event directly from the db. If you are just going to marshel the object to JSON immediately, then this is probably more effcient.
func (*UsageEventRows) Next ¶
func (ber *UsageEventRows) Next() bool
Next moves the row cursor to the next iteration. Returns false if no more rows.