postgres

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2025 License: BSD-3-Clause Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(ctx context.Context, dsn string) (*sqlx.DB, error)

NewKeyValidator creates KeyValidator instance

Types

type AdmimRepository added in v1.0.0

type AdmimRepository struct {
	// contains filtered or unexported fields
}

Repository communicates with postgres

func NewAdmimRepository

func NewAdmimRepository(ctx context.Context, db *sqlx.DB, hasher Hasher) (*AdmimRepository, error)

func (*AdmimRepository) AddAdmin added in v1.0.0

func (r *AdmimRepository) AddAdmin(ctx context.Context, key string, user *model.User) error

func (*AdmimRepository) DeleteLogs added in v1.0.0

func (a *AdmimRepository) DeleteLogs(ctx context.Context, project string, to time.Time) (int, error)

DeleteLogs implements admin.LogProvider.

func (*AdmimRepository) Get added in v1.0.0

func (r *AdmimRepository) Get(ctx context.Context, user *model.User, id string) (*api.Key, error)

func (*AdmimRepository) GetLogs added in v1.0.0

func (r *AdmimRepository) GetLogs(ctx context.Context, user *model.User, keyID string) ([]*api.Log, error)

func (*AdmimRepository) List added in v1.0.0

func (a *AdmimRepository) List(ctx context.Context, project string) ([]*api.Key, error)

List implements admin.KeyRetriever.

func (*AdmimRepository) ListLogs added in v1.0.0

func (a *AdmimRepository) ListLogs(ctx context.Context, project string, to time.Time) ([]*api.Log, error)

ListLogs implements admin.LogProvider.

func (*AdmimRepository) Reset added in v1.0.0

func (r *AdmimRepository) Reset(ctx context.Context, project string, since time.Time, limit float64) error

func (*AdmimRepository) RestoreUsage added in v1.0.0

func (r *AdmimRepository) RestoreUsage(ctx context.Context, project string, manual bool, request string, errorMsg string) error

func (*AdmimRepository) ValidateToken added in v1.0.0

func (r *AdmimRepository) ValidateToken(ctx context.Context, token string) (*model.User, error)

type CMSRepository

type CMSRepository struct {
	// contains filtered or unexported fields
}

func NewCMSRepository

func NewCMSRepository(ctx context.Context, db *sqlx.DB, keySize int, hasher Hasher) (*CMSRepository, error)

func (*CMSRepository) AddCredits

func (r *CMSRepository) AddCredits(ctx context.Context, user *model.User, id string, in *api.CreditsInput) (*api.Key, error)

func (*CMSRepository) Change

func (r *CMSRepository) Change(ctx context.Context, user *model.User, id string) (*api.Key, error)

func (*CMSRepository) Create

func (r *CMSRepository) Create(ctx context.Context, user *model.User, in *api.CreateInput) (*api.Key, bool, error)

func (*CMSRepository) GetKey

func (r *CMSRepository) GetKey(ctx context.Context, user *model.User, id string) (*api.Key, error)

func (*CMSRepository) GetKeyID

func (r *CMSRepository) GetKeyID(ctx context.Context, user *model.User, id string) (*api.KeyID, error)

func (*CMSRepository) Stats

func (r *CMSRepository) Stats(ctx context.Context, user *model.User, in *api.StatParams) ([]*api.Bucket, error)

func (*CMSRepository) Update

func (r *CMSRepository) Update(ctx context.Context, user *model.User, id string, in *api.UpdateInput) (*api.Key, error)

func (*CMSRepository) Usage

func (r *CMSRepository) Usage(ctx context.Context, user *model.User, id string, from *time.Time, to *time.Time, full bool) (*api.Usage, error)

type Hasher

type Hasher interface {
	HashKey(key string) string
}

type ProjectSettings

type ProjectSettings struct {
	Project      string
	ResetStarted time.Time `json:"resetStarted,omitempty"`
	NextReset    time.Time `json:"nextReset,omitempty"`
	Updated      time.Time `json:"updated,omitempty"`
}

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository communicates with postgres

func NewRepository

func NewRepository(ctx context.Context, db *sqlx.DB, project string, hasher Hasher) (*Repository, error)

func (*Repository) CheckCreateIPKey

func (r *Repository) CheckCreateIPKey(ctx context.Context, ip string, limit float64) (string, error)

func (*Repository) IsValid

func (r *Repository) IsValid(ctx context.Context, key string, IP string, manual bool) (bool, string, []string, error)

IsValid validates key

func (*Repository) Restore

func (r *Repository) Restore(ctx context.Context, key string, manual bool, qv float64) (float64, float64, error)

Restore restores quota value after failed service call

func (*Repository) SaveLog

func (r *Repository) SaveLog(ctx context.Context, data *api.Log) error

func (*Repository) SaveValidate

func (r *Repository) SaveValidate(ctx context.Context, key string, ip string, manual bool, qv float64) (bool, float64, float64, error)

SaveValidate add qv to quota and validates with quota limit

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL