utils

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AppEnvDev string = "dev"
View Source
const AppEnvProd string = "prod"
View Source
const WebhookModeAnonymous string = "anonymous"
View Source
const WebhookModeRestricted string = "restricted"

Variables

This section is empty.

Functions

func Censor

func Censor(text string, replace string) string

func CensorPart added in v0.0.2

func CensorPart(text string, show int) string

func ConnectDb

func ConnectDb(uri string) *gorm.DB

func ConnectDbCluster

func ConnectDbCluster(config *Config) (*gorm.DB, *gorm.DB)

func GenTestIds added in v0.0.6

func GenTestIds(count int) []string

func GenTestLogs added in v0.0.6

func GenTestLogs(db *gorm.DB, wid, mid, eid string, count int, rps int) *[]models.ScraphookWebhooksForwardingLogs

func GenTestMessages added in v0.0.6

func GenTestMessages(db *gorm.DB, wid string, count int) *[]models.ScraphookMessages

func MaxInt

func MaxInt(x, y int) int

func MinInt

func MinInt(x, y int) int

func NewId added in v0.0.6

func NewId(prefix string) string

func NewLogger

func NewLogger(prod bool) *zap.SugaredLogger

Types

type Config

type Config struct {
	IsProd bool

	AppEnv  string `mapstructure:"SCRAP_APP_ENV"`
	AppPort string `mapstructure:"SCRAP_APP_PORT"`

	DBUriMaster   string `mapstructure:"SCRAP_DB_URI_MASTER"`
	DBUriReplicas string `mapstructure:"SCRAP_DB_URI_REPLICAS"`

	MQUri          string `mapstructure:"SCRAP_MQ_URI"`
	MQExchangeName string `mapstructure:"SCRAP_MQ_EXCHANGE_NAME"`
	MQQueueName    string `mapstructure:"SCRAP_MQ_QUEUE_NAME"`

	CacheUri             string `mapstructure:"SCRAP_CACHE_URI"`
	CacheDb              int    `mapstructure:"SCRAP_CACHE_DB"`
	CacheExpirySeconds   int    `mapstructure:"SCRAP_CACHE_EXPIRY_SECONDS"`
	RedLockExpirySeconds int    `mapstructure:"SCRAP_REDLOCK_EXPIRY_SECONDS"`

	QueryLimit    int `mapstructure:"SCRAP_QUERY_LIMIT"`
	QueryLimitMax int `mapstructure:"SCRAP_QUERY_LIMIT_MAX"`

	WebhookMode                 string `mapstructure:"SCRAP_WEBHOOK_MODE"`
	WebhookAuthBypass           string `mapstructure:"SCRAP_WEBHOOK_AUTH_BYPASS"`
	WebhookAuthToken            string `mapstructure:"SCRAP_WEBHOOK_AUTH_TOKEN"`
	WebhookVerifyTokenField     string `mapstructure:"SCRAP_WEBHOOK_VERIFY_TOKEN_FIELD"`
	WebhookVerifyTokenValue     string `mapstructure:"SCRAP_WEBHOOK_VERIFY_TOKEN_VALUE"`
	WebhookVerifyResponseField  string `mapstructure:"SCRAP_WEBHOOK_VERIFY_RESPONSE_FILED"`
	WebhookSignatureHeaderField string `mapstructure:"SCRAP_WEBHOOK_SIGNATURE_HEADER_FIELD"`

	WebhookForwardingErrorNotificationUrl string `mapstructure:"SCRAP_WEBHOOK_FORWARDING_ERROR_NOTIFICATION_URL"`
	WebhookForwardingSuccessStatusCode    string `mapstructure:"SCRAP_WEBHOOK_FORWARDING_SUCCESS_STATUS_CODE"`

	CronCleanupSchedule     string `mapstructure:"SCRAP_CRON_CLEANUP_SCHEDULE"`
	CronCleanupLifetimeHour int    `mapstructure:"SCRAP_CRON_CLEANUP_LIFETIME_HOUR"`
}

func LoadConfig

func LoadConfig(paths ...string) *Config

Jump to

Keyboard shortcuts

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