Documentation
¶
Index ¶
- func CheckPassword(password string, hashedPassowrd string) error
- func HashPassword(password string) (string, error)
- func RandomEmail(n int) string
- func RandomInt(min, max int64) int64
- func RandomMoney() int64
- func RandomStr(n int) string
- func RandomUser() string
- func ValidQuery(query string) bool
- type Config
- type SchemaCache
- func (cache *SchemaCache) AutoRefresh(schema map[string]map[string]string, interval time.Duration) error
- func (cache *SchemaCache) CacheSchema(schema map[string]map[string]string) error
- func (cache *SchemaCache) GetSchema() map[string]map[string]string
- func (cache *SchemaCache) GetSchemaWithExpiry(maxAge time.Duration) (map[string]map[string]string, bool)
- func (cache *SchemaCache) RefreshSchema(schema map[string]map[string]string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPassword ¶
CheckPassword checks if password and hashedpassword are the same.
func HashPassword ¶
HashPassword returns the bcrypt hash of the password and an error.
func ValidQuery ¶
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 ¶
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.