Documentation ¶
Index ¶
- func DailyBudgetScript() string
- func DebitIfNotZeroScript() string
- func NewRedisBanker(da NoDbDataAccess) rtb.Banker
- func NewRedisCampaign(da NoDbDataAccess, id int64, accountKey string, targetSetKey string) rtb.Campaign
- func NewRedisCampaignProvider(da NoDbDataAccess, banker rtb.Banker) rtb.CampaignProvider
- func NewRedisPacer(cp rtb.CampaignProvider, da NoDbDataAccess, banker rtb.Banker, ...) rtb.Pacer
- func TargetKeysForTargets(prepend string, targets []rtb.Target) []string
- type NoDbDataAccess
- type RedisBanker
- func (b *RedisBanker) DebitAccount(account int64, amount int64, dailyBudget int64, ...) (remainingDailyBudgetInMicroCents int64, err error)
- func (b *RedisBanker) DeleteAccount(account int64)
- func (b *RedisBanker) RemainingDailyBudgetInMicroCents(account int64) int64
- func (b *RedisBanker) SetRemainingDailyBudgetInMicroCents(account int64, amount int64, dailyBudgetExpiration time.Time)
- type RedisCampaign
- type RedisCampaignProvider
- func (cp *RedisCampaignProvider) CreateCampaign(campaignId int64, bidCpmInMicroCents int64, dailyBudgetInMicroCents int64, ...) rtb.Campaign
- func (cp *RedisCampaignProvider) DebitCampaign(campaignId int64, amountInMicroCents int64, dailyBudgetExpiration time.Time) (remainingDailyBudgetInMicroCents int64, err error)
- func (cp *RedisCampaignProvider) ListCampaigns() []int64
- func (cp *RedisCampaignProvider) ReadByTargeting(bidFloorInMicroCents int64, targets []rtb.Target) []rtb.Campaign
- func (cp *RedisCampaignProvider) ReadCampaign(campaignId int64) rtb.Campaign
- type RedisDataAccess
- func (da *RedisDataAccess) AddMembersToSet(setKey string, members []interface{})
- func (da *RedisDataAccess) AddMembersToSortedSets(keyValues map[string]SortedSetMember)
- func (da *RedisDataAccess) DebitIfNotZero(accountKey string, amount int64, dailyBudget int64, ...) (remainingDailyBudgetInMicroCents int64, err error)
- func (da *RedisDataAccess) DeleteKeys(keys []string)
- func (da *RedisDataAccess) ExpireKey(key string, expirationTime time.Time)
- func (da *RedisDataAccess) GetInt64(accountKey string) (success bool, result int64)
- func (da *RedisDataAccess) GetKeys() []string
- func (da *RedisDataAccess) GetSetMembers(setKey string) []string
- func (da *RedisDataAccess) HGetInt64(accountKey string, key string) int64
- func (da *RedisDataAccess) HSetInt64(accountKey string, key string, val int64)
- func (da *RedisDataAccess) SetInt64(accountKey string, val int64)
- func (da *RedisDataAccess) SortedSetUnion(keys []string) []string
- type RedisPacer
- type SortedSetMember
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DailyBudgetScript ¶
func DailyBudgetScript() string
KEYS[1] is the account key ARGV[1] is the daily budget ARGV[2] is the expiration time
func DebitIfNotZeroScript ¶
func DebitIfNotZeroScript() string
KEYS[1] is the account key ARGV[1] is the amount to debit
func NewRedisBanker ¶
func NewRedisBanker(da NoDbDataAccess) rtb.Banker
func NewRedisCampaign ¶
func NewRedisCampaignProvider ¶
func NewRedisCampaignProvider(da NoDbDataAccess, banker rtb.Banker) rtb.CampaignProvider
func NewRedisPacer ¶
func NewRedisPacer(cp rtb.CampaignProvider, da NoDbDataAccess, banker rtb.Banker, segment time.Duration) rtb.Pacer
Types ¶
type NoDbDataAccess ¶
type NoDbDataAccess interface { DeleteKeys(keys []string) HGetInt64(accountKey string, key string) int64 HSetInt64(accountKey string, key string, val int64) GetInt64(accountKey string) (success bool, result int64) SetInt64(accountKey string, val int64) GetSetMembers(setKey string) []string AddMembersToSet(setKey string, members []interface{}) AddMembersToSortedSets(keyValues map[string]SortedSetMember) SortedSetUnion(keys []string) []string DebitIfNotZero(accountKey string, amount int64, dailyBudget int64, dailyBudgetExpiration time.Time) (remainingDailyBudgetInMicroCents int64, err error) ExpireKey(key string, expirationTime time.Time) // Should only be used for testing GetKeys() []string }
func NewRedisDataAccess ¶
func NewRedisDataAccess(network string, addr string, appDomain string, poolSize int) NoDbDataAccess
type RedisBanker ¶
type RedisBanker struct {
// contains filtered or unexported fields
}
func (*RedisBanker) DebitAccount ¶
func (*RedisBanker) DeleteAccount ¶
func (b *RedisBanker) DeleteAccount(account int64)
func (*RedisBanker) RemainingDailyBudgetInMicroCents ¶
func (b *RedisBanker) RemainingDailyBudgetInMicroCents(account int64) int64
func (*RedisBanker) SetRemainingDailyBudgetInMicroCents ¶
func (b *RedisBanker) SetRemainingDailyBudgetInMicroCents(account int64, amount int64, dailyBudgetExpiration time.Time)
type RedisCampaign ¶
type RedisCampaign struct {
// contains filtered or unexported fields
}
func (*RedisCampaign) BidCpmInMicroCents ¶
func (c *RedisCampaign) BidCpmInMicroCents() int64
func (*RedisCampaign) DailyBudgetInMicroCents ¶
func (c *RedisCampaign) DailyBudgetInMicroCents() int64
func (*RedisCampaign) Id ¶
func (c *RedisCampaign) Id() int64
func (*RedisCampaign) Targets ¶
func (c *RedisCampaign) Targets() *map[rtb.TargetType]string
type RedisCampaignProvider ¶
type RedisCampaignProvider struct {
// contains filtered or unexported fields
}
func (*RedisCampaignProvider) CreateCampaign ¶
func (*RedisCampaignProvider) DebitCampaign ¶
func (*RedisCampaignProvider) ListCampaigns ¶
func (cp *RedisCampaignProvider) ListCampaigns() []int64
func (*RedisCampaignProvider) ReadByTargeting ¶
func (*RedisCampaignProvider) ReadCampaign ¶
func (cp *RedisCampaignProvider) ReadCampaign(campaignId int64) rtb.Campaign
type RedisDataAccess ¶
type RedisDataAccess struct {
// contains filtered or unexported fields
}
func (*RedisDataAccess) AddMembersToSet ¶
func (da *RedisDataAccess) AddMembersToSet(setKey string, members []interface{})
func (*RedisDataAccess) AddMembersToSortedSets ¶
func (da *RedisDataAccess) AddMembersToSortedSets(keyValues map[string]SortedSetMember)
func (*RedisDataAccess) DebitIfNotZero ¶
func (*RedisDataAccess) DeleteKeys ¶
func (da *RedisDataAccess) DeleteKeys(keys []string)
func (*RedisDataAccess) ExpireKey ¶
func (da *RedisDataAccess) ExpireKey(key string, expirationTime time.Time)
func (*RedisDataAccess) GetInt64 ¶
func (da *RedisDataAccess) GetInt64(accountKey string) (success bool, result int64)
func (*RedisDataAccess) GetKeys ¶
func (da *RedisDataAccess) GetKeys() []string
Should only be used for testing
func (*RedisDataAccess) GetSetMembers ¶
func (da *RedisDataAccess) GetSetMembers(setKey string) []string
func (*RedisDataAccess) HGetInt64 ¶
func (da *RedisDataAccess) HGetInt64(accountKey string, key string) int64
func (*RedisDataAccess) HSetInt64 ¶
func (da *RedisDataAccess) HSetInt64(accountKey string, key string, val int64)
func (*RedisDataAccess) SetInt64 ¶
func (da *RedisDataAccess) SetInt64(accountKey string, val int64)
func (*RedisDataAccess) SortedSetUnion ¶
func (da *RedisDataAccess) SortedSetUnion(keys []string) []string
type RedisPacer ¶
type RedisPacer struct {
// contains filtered or unexported fields
}
Implements a simple time segmented pacer. Dividing the daily budget into time segments based on the segment duration provided
func (*RedisPacer) Segment ¶
func (p *RedisPacer) Segment() time.Duration
type SortedSetMember ¶
type SortedSetMember struct { Score int64 Member interface{} }
Click to show internal directories.
Click to hide internal directories.