admin

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartWebServer

func StartWebServer(data *Data) error

StartWebServer starts the HTTP service and listens for the admin requests

Types

type Data

type Data struct {
	Port int

	KeySaver         KeyCreator
	KeyGetter        KeyRetriever
	OneKeyGetter     OneKeyRetriever
	LogProvider      LogProvider
	OneKeyUpdater    KeyUpdater
	UsageRestorer    UsageRestorer
	UsageReseter     UsageReseter
	ProjectValidator PrValidator

	CmsData *cms.Data
}

Data is service operation data

type KeyCreator

type KeyCreator interface {
	Create(string, *adminapi.Key) (*adminapi.Key, error)
}

KeyCreator creates key

type KeyRetriever

type KeyRetriever interface {
	List(string) ([]*adminapi.Key, error)
}

KeyRetriever gets keys list from db

type KeyUpdater

type KeyUpdater interface {
	Update(string, string, map[string]interface{}) (*adminapi.Key, error)
}

KeyUpdater creates key

type LogProvider

type LogProvider interface {
	Get(string, string) ([]*adminapi.Log, error)
	List(string, time.Time) ([]*adminapi.Log, error)
	Delete(string, time.Time) (int, error)
}

LogRetriever retrieves one list from db

type OneKeyRetriever

type OneKeyRetriever interface {
	Get(string, string) (*adminapi.Key, error)
}

OneKeyRetriever retrieves one list from db

type PrValidator

type PrValidator interface {
	Check(string) bool
	Projects() []string
}

PrValidator validates if project is available

type ProjectConfigValidator

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

ProjectConfigValidator loads available projects from config

func NewProjectConfigValidator

func NewProjectConfigValidator(projects string) (*ProjectConfigValidator, error)

NewProjectConfigValidator creates project validator, reads available projects from config

func (*ProjectConfigValidator) Check

func (pv *ProjectConfigValidator) Check(pr string) bool

Check tests if project is available

func (*ProjectConfigValidator) Projects

func (pv *ProjectConfigValidator) Projects() []string

Projects returns all supported projects

type UsageReseter

type UsageReseter interface {
	Reset(ctx context.Context, project string, since time.Time, limit float64) error
}

UsageReseter resets montly usage

type UsageRestorer

type UsageRestorer interface {
	RestoreUsage(project string, manual bool, request string, errorMsg string) error
}

UsageRestorer restores key usage by requestID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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