Documentation ¶
Index ¶
- func IsDuplicate(err error) bool
- func Sanitize(s string) string
- type CmsIntegrator
- func (ss *CmsIntegrator) AddCredits(keyID string, input *api.CreditsInput) (*api.Key, error)
- func (ss *CmsIntegrator) Change(keyID string) (*api.Key, error)
- func (ss *CmsIntegrator) Changes(from *time.Time, services []string) (*api.Changes, error)
- func (ss *CmsIntegrator) Create(input *api.CreateInput) (*api.Key, bool, error)
- func (ss *CmsIntegrator) GetKey(keyID string) (*api.Key, error)
- func (ss *CmsIntegrator) GetKeyID(key string) (*api.KeyID, error)
- func (ss *CmsIntegrator) Update(keyID string, input map[string]interface{}) (*api.Key, error)
- func (ss *CmsIntegrator) Usage(keyID string, from, to *time.Time, full bool) (*api.Usage, error)
- type DBProvider
- type IPSaver
- type IndexData
- type KeySaver
- func (ss *KeySaver) Create(project string, key *adminapi.Key) (*adminapi.Key, error)
- func (ss *KeySaver) Get(project string, key string) (*adminapi.Key, error)
- func (ss *KeySaver) List(project string) ([]*adminapi.Key, error)
- func (ss *KeySaver) RestoreUsage(project string, manual bool, requestID string, errMsg string) error
- func (ss *KeySaver) Update(project string, key string, data map[string]interface{}) (*adminapi.Key, error)
- type KeyValidator
- func (ss *KeyValidator) IsValid(key string, IP string, manual bool) (bool, string, []string, error)
- func (ss *KeyValidator) Restore(key string, manual bool, qv float64) (float64, float64, error)
- func (ss *KeyValidator) SaveValidate(key string, ip string, manual bool, qv float64) (bool, float64, float64, error)
- type LogProvider
- type LogSaver
- type Reseter
- type SProvider
- type SessionProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDuplicate ¶
IsDuplicate returns true if error indicates index duplicate key error
Types ¶
type CmsIntegrator ¶
type CmsIntegrator struct {
// contains filtered or unexported fields
}
CmsIntegrator integrator function implementation with mongoDB persistence
func NewCmsIntegrator ¶
func NewCmsIntegrator(sessionProvider *SessionProvider, keySize int) (*CmsIntegrator, error)
NewCmsIntegrator creates CmsIntegrator instance
func (*CmsIntegrator) AddCredits ¶
func (ss *CmsIntegrator) AddCredits(keyID string, input *api.CreditsInput) (*api.Key, error)
AddCredits to the key
func (*CmsIntegrator) Change ¶
func (ss *CmsIntegrator) Change(keyID string) (*api.Key, error)
Change generates new key for keyID, disables the old one, returns new key
func (*CmsIntegrator) Create ¶
func (ss *CmsIntegrator) Create(input *api.CreateInput) (*api.Key, bool, error)
Create creates new key
func (*CmsIntegrator) GetKey ¶
func (ss *CmsIntegrator) GetKey(keyID string) (*api.Key, error)
GetKey by ID
func (*CmsIntegrator) GetKeyID ¶
func (ss *CmsIntegrator) GetKeyID(key string) (*api.KeyID, error)
GetKeyID returns keyID by key value
type DBProvider ¶
type DBProvider struct {
// contains filtered or unexported fields
}
DBProvider keeps SessionProvider and database for mongo DB
func NewDBProvider ¶
func NewDBProvider(sessionP SProvider, db string) (*DBProvider, error)
NewDBProvider creates Mongo session provider and opens client with selected db
func (*DBProvider) NewSesionDatabase ¶
NewSesionDatabase creates mongo session and databse
type IPSaver ¶
type IPSaver struct {
SessionProvider *DBProvider
}
IPSaver validates saves ip into DB
func NewIPSaver ¶
func NewIPSaver(sessionProvider *DBProvider) (*IPSaver, error)
NewIPSaver creates IPSaver instance
type KeySaver ¶
type KeySaver struct { SessionProvider *SessionProvider NewKeySize int }
KeySaver saves keys to mongo db
func NewKeySaver ¶
func NewKeySaver(sessionProvider *SessionProvider, keySize int) (*KeySaver, error)
NewKeySaver creates KeySaver instance
type KeyValidator ¶
type KeyValidator struct {
SessionProvider *DBProvider
}
KeyValidator validates key in mongo db
func NewKeyValidator ¶
func NewKeyValidator(sessionProvider *DBProvider) (*KeyValidator, error)
NewKeyValidator creates KeyValidator instance
type LogProvider ¶
type LogProvider struct {
SessionProvider *SessionProvider
}
LogProvider retrieves the log
func NewLogProvider ¶
func NewLogProvider(sessionProvider *SessionProvider) (*LogProvider, error)
NewLogProvider creates LogProvider instance
type LogSaver ¶
type LogSaver struct {
SessionProvider *DBProvider
}
LogSaver saves log info to mongo db
func NewLogSaver ¶
func NewLogSaver(sessionProvider *DBProvider) (*LogSaver, error)
NewLogSaver creates LogSaver instance
type Reseter ¶
type Reseter struct {
// contains filtered or unexported fields
}
Reseter resets monthly usage
func NewReseter ¶
func NewReseter(sessionProvider *SessionProvider) (*Reseter, error)
NewReseter creates Reseter instance
type SessionProvider ¶
type SessionProvider struct { URL string // contains filtered or unexported fields }
SessionProvider connects and provides session for mongo DB
func NewSessionProvider ¶
func NewSessionProvider(url string) (*SessionProvider, error)
NewSessionProvider creates Mongo session provider
func (*SessionProvider) CheckIndexes ¶
func (sp *SessionProvider) CheckIndexes(dbs []string) error
CheckIndexes tries to create indexes in db if not exists
func (*SessionProvider) Healthy ¶
func (sp *SessionProvider) Healthy() error
Healthy checks if mongo DB is up
func (*SessionProvider) NewSession ¶
func (sp *SessionProvider) NewSession() (mongo.Session, error)
NewSession creates mongo session