util

package
v0.0.0-...-97e77ea Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(password string, hashedPassowrd string) error

CheckPassword checks if password and hashedpassword are the same.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns the bcrypt hash of the password and an error.

func RandomEmail

func RandomEmail(n int) string

RandomEmail generates a random email address

func RandomInt

func RandomInt(min, max int64) int64

RandomInt generates a random integer between min and max

func RandomMoney

func RandomMoney() int64

RandomMoney generates a random amount of money

func RandomStr

func RandomStr(n int) string

RandomStr generates a random string of length n

func RandomUser

func RandomUser() string

RandomOwner generates a random owner name

func ValidQuery

func ValidQuery(query string) bool

ValidQuery checks if parsed SQL Query is a valid query a valid query in this case is a correct SQL which is also a SELECT statement. It adds extra security to ensure only SELECT queries are validated.

Types

type Config

type Config struct {
	Port                string        `json:"PORT"`
	DBDriver            string        `json:"DB_DRIVER"`
	DBUrl               string        `json:"DB_URL"`
	DBName              string        `json:"DB_NAME"`
	Environment         string        `json:"ENVIRONMENT"`
	TokenSymmetricKey   string        `json:"TOKEN_SYMMETRIC_KEY"`
	TokenSecretKey      string        `json:"TOKEN_SECRET_KEY"`
	AccessTokenDuration time.Duration `json:"ACCESS_TOKEN_DURATION"`
	ApiKey              string        `json:"API_KEY"`
	OrgId               string        `json:"ORG_ID"`
	ProjectId           string        `json:"PROJECT_ID"`
	Model               string        `json:"MODEL"`
	Temp                string        `json:"TEMP"`
	CronSchedule        string        `json:"CRON_SCHEDULE"`
	CronBatchSize       string        `json:"CRON_BATCH_SIZE"`
	LogPath             string        `json:"LOG_PATH"`
}

func LoadConfig

func LoadConfig(path string) (config Config, err error)

type SchemaCache

type SchemaCache struct {
	Data       map[string]map[string]string
	LastUpdate time.Time
	// contains filtered or unexported fields
}

func NewSchemaCache

func NewSchemaCache() *SchemaCache

func (*SchemaCache) AutoRefresh

func (cache *SchemaCache) AutoRefresh(schema map[string]map[string]string, interval time.Duration) error

Set up a background goroutine to periodically refresh the schema.

func (*SchemaCache) CacheSchema

func (cache *SchemaCache) CacheSchema(schema map[string]map[string]string) error

Load the schema from the database and store it in the cache.

func (*SchemaCache) GetSchema

func (cache *SchemaCache) GetSchema() map[string]map[string]string

Provide thread-safe access to the cached data.

func (*SchemaCache) GetSchemaWithExpiry

func (cache *SchemaCache) GetSchemaWithExpiry(maxAge time.Duration) (map[string]map[string]string, bool)

If the schema changes infrequently, add logic to validate or expire the cache based on the LastUpdate timestamp.

func (*SchemaCache) RefreshSchema

func (cache *SchemaCache) RefreshSchema(schema map[string]map[string]string) error

Manual Refresh API: Allow manual cache refresh via an admin endpoint or CLI.

Jump to

Keyboard shortcuts

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