Documentation ¶
Index ¶
- Constants
- Variables
- func CloseDatabase()
- func DispatchEvent(event interface{})
- func DoBigTick()
- func DoSmallTick()
- func InitID()
- func LoadDatabase()
- func NextID() uint64
- func RegisterListener(d interface{})
- func RegisterProduct(meta *ProductMeta)
- type Balance
- type BalanceChangeEvent
- type BigTickEvent
- type Billing
- type DBModel
- type Dispatcher
- type Logger
- func (l *Logger) Error(_ context.Context, msg string, data ...interface{})
- func (l *Logger) Info(_ context.Context, msg string, data ...interface{})
- func (l *Logger) LogMode(_ logger.LogLevel) logger.Interface
- func (l *Logger) Trace(_ context.Context, begin time.Time, fc func() (string, int64), _ error)
- func (l *Logger) Warn(_ context.Context, msg string, data ...interface{})
- type NetRequest
- type Product
- func (p *Product) ChangeBilling(billing *Billing) error
- func (p *Product) GetBalance() (*Balance, error)
- func (p *Product) GetCost() int64
- func (p *Product) GetMeta() *ProductMeta
- func (p *Product) Prolong(period int64) error
- func (p *Product) SuspendProduct(reason string) error
- func (p *Product) UnsuspendProduct() error
- func (p *Product) Update() error
- type ProductDeletedEvent
- type ProductListener
- type ProductMeta
- type ProductOrderedEvent
- type ProductSuspendEvent
- type ProductUnsuspendEvent
- type ResponseType
- type SmallTickEvent
- type User
- type UserActivationEvent
- type UserCreationEvent
- type UserDeactivationEvent
Constants ¶
View Source
const ( ResponseJson ResponseType = "JSON" ResponseURLEncoded = "URLEncoded" ResponsePlain = "PLAIN" ResponseNone = "NONE" )
Variables ¶
View Source
var BillingTypeNotSupportedError = errors.New("specified billing type is not supported by the product")
View Source
var DB *gorm.DB
View Source
var DailyBilling = RegisterBilling("daily", time.Hour*24)
View Source
var HourlyBilling = RegisterBilling("hourly", time.Hour)
View Source
var ID *sonyflake.Sonyflake
View Source
var LocalDispatchers = make(map[reflect.Type][]*Dispatcher)
View Source
var ModuleDispatchers = make(map[reflect.Type][]*Dispatcher)
View Source
var MonthlyBilling = RegisterBilling("monthly", time.Hour*24*30)
View Source
var NotEnoughFundsError = errors.New("not enough funds")
View Source
var OneTimeBilling = RegisterBilling("onetime", 0)
View Source
var PathNotFoundError = errors.New("url decoding path not found")
View Source
var QuarterlyBilling = RegisterBilling("quarterly", time.Hour*24*90)
View Source
var Redis *redis.Conn
View Source
var WeeklyBilling = RegisterBilling("weekly", time.Hour*24*7)
View Source
var YearlyBilling = RegisterBilling("yearly", time.Hour*24*365)
Functions ¶
func CloseDatabase ¶
func CloseDatabase()
func DispatchEvent ¶
func DispatchEvent(event interface{})
func DoSmallTick ¶
func DoSmallTick()
func LoadDatabase ¶
func LoadDatabase()
func RegisterListener ¶
func RegisterListener(d interface{})
func RegisterProduct ¶
func RegisterProduct(meta *ProductMeta)
Types ¶
type Balance ¶
func NewBalance ¶
type BalanceChangeEvent ¶
type BigTickEvent ¶
type BigTickEvent struct{}
type Billing ¶
func GetBilling ¶
type Dispatcher ¶
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(event interface{})
type NetRequest ¶
type Product ¶
type Product struct { ID uint64 DisplayName string Billing string BalanceID uint64 `json:"-"` Module string Type string Users []*User `gorm:"many2many:user_products;"` PaidTill time.Time Suspended bool SuspendReason string }
func (*Product) ChangeBilling ¶
func (*Product) GetBalance ¶
func (*Product) GetMeta ¶
func (p *Product) GetMeta() *ProductMeta
func (*Product) SuspendProduct ¶
func (*Product) UnsuspendProduct ¶
type ProductDeletedEvent ¶
type ProductDeletedEvent struct {
Product *Product
}
type ProductListener ¶
type ProductListener struct{}
func (*ProductListener) OnSmallTick ¶
func (*ProductListener) OnSmallTick(_ SmallTickEvent)
type ProductMeta ¶
type ProductOrderedEvent ¶
type ProductOrderedEvent struct {
Product *Product
}
type ProductSuspendEvent ¶
type ProductUnsuspendEvent ¶
type ProductUnsuspendEvent struct {
Product *Product
}
type ResponseType ¶
type ResponseType string
type SmallTickEvent ¶
type SmallTickEvent struct{}
type User ¶
type User struct { ID uint64 `json:"id"` BalanceID int64 `json:"-"` Balance Balance `json:"balance"` Products []Product `json:"products,omitempty" gorm:"many2many:user_products;"` Token string `json:"token,omitempty"` Active bool `json:"active"` }
func (*User) AddProduct ¶
func (*User) Deactivate ¶
func (u *User) Deactivate()
func (*User) FetchProducts ¶
type UserActivationEvent ¶
type UserActivationEvent struct {
User *User
}
type UserCreationEvent ¶
type UserCreationEvent struct {
User *User
}
type UserDeactivationEvent ¶
type UserDeactivationEvent struct {
User *User
}
Click to show internal directories.
Click to hide internal directories.