Documentation ¶
Index ¶
Constants ¶
View Source
const ( NacosConfigType = "nacos" ApolloConfigType = "apollo" )
View Source
const ( // GddBanner indicates banner enabled or not GddBanner envVariable = "GDD_BANNER" // GddBannerText sets text content of banner GddBannerText envVariable = "GDD_BANNER_TEXT" // GddLogLevel accepts panic, fatal, error, warn, warning, info, debug, trace, disabled. please reference zerolog.ParseLevel GddLogLevel envVariable = "GDD_LOG_LEVEL" // GddLogFormat text or json // Deprecated: move to zerolog GddLogFormat envVariable = "GDD_LOG_FORMAT" // GddLogReqEnable enables request and response logging GddLogReqEnable envVariable = "GDD_LOG_REQ_ENABLE" GddLogCaller envVariable = "GDD_LOG_CALLER" GddLogDiscard envVariable = "GDD_LOG_DISCARD" GddLogPath envVariable = "GDD_LOG_PATH" // GddLogStyle is only valid when GDD_LOG_PATH is specified, accepts json or console. // Default is json GddLogStyle envVariable = "GDD_LOG_STYLE" // GddGraceTimeout sets graceful shutdown timeout GddGraceTimeout envVariable = "GDD_GRACE_TIMEOUT" // GddWriteTimeout sets http connection write timeout GddWriteTimeout envVariable = "GDD_WRITE_TIMEOUT" // GddReadTimeout sets http connection read timeout GddReadTimeout envVariable = "GDD_READ_TIMEOUT" // GddIdleTimeout sets http connection idle timeout GddIdleTimeout envVariable = "GDD_IDLE_TIMEOUT" // GddRouteRootPath sets root path for all routes GddRouteRootPath envVariable = "GDD_ROUTE_ROOT_PATH" // GddServiceName sets service name GddServiceName envVariable = "GDD_SERVICE_NAME" GddServiceGroup envVariable = "GDD_SERVICE_GROUP" GddServiceVersion envVariable = "GDD_SERVICE_VERSION" // GddHost sets bind host for http server GddHost envVariable = "GDD_HOST" // GddPort sets bind port for http server GddPort envVariable = "GDD_PORT" // GddGrpcPort sets bind port for grpc server GddGrpcPort envVariable = "GDD_GRPC_PORT" // GddManage if true, it will add built-in apis with /go-doudou path prefix for online api document and service status monitor etc. GddManage envVariable = "GDD_MANAGE_ENABLE" // GddManageUser manage api endpoint http basic auth user GddManageUser envVariable = "GDD_MANAGE_USER" // GddManagePass manage api endpoint http basic auth password GddManagePass envVariable = "GDD_MANAGE_PASS" GddEnableResponseGzip envVariable = "GDD_ENABLE_RESPONSE_GZIP" // Deprecated: move to GddFallbackContentType GddAppType envVariable = "GDD_APP_TYPE" // GddFallbackContentType fallback response content-type header value GddFallbackContentType envVariable = "GDD_FALLBACK_CONTENTTYPE" GddRouterSaveMatchedRoutePath envVariable = "GDD_ROUTER_SAVEMATCHEDROUTEPATH" // GddConfigRemoteType has two options available: nacos, apollo GddConfigRemoteType envVariable = "GDD_CONFIG_REMOTE_TYPE" GddRetryCount envVariable = "GDD_RETRY_COUNT" GddTracingMetricsRoot envVariable = "GDD_TRACING_METRICS_ROOT" GddServiceDiscoveryMode envVariable = "GDD_SERVICE_DISCOVERY_MODE" GddNacosNamespaceId envVariable = "GDD_NACOS_NAMESPACE_ID" GddNacosTimeoutMs envVariable = "GDD_NACOS_TIMEOUT_MS" GddNacosNotLoadCacheAtStart envVariable = "GDD_NACOS_NOTLOADCACHEATSTART" GddNacosLogDir envVariable = "GDD_NACOS_LOG_DIR" GddNacosCacheDir envVariable = "GDD_NACOS_CACHE_DIR" GddNacosLogLevel envVariable = "GDD_NACOS_LOG_LEVEL" GddNacosLogDiscard envVariable = "GDD_NACOS_LOG_DISCARD" GddNacosServerAddr envVariable = "GDD_NACOS_SERVER_ADDR" GddNacosRegisterHost envVariable = "GDD_NACOS_REGISTER_HOST" GddNacosClusterName envVariable = "GDD_NACOS_CLUSTER_NAME" GddNacosGroupName envVariable = "GDD_NACOS_GROUP_NAME" // GddNacosConfigFormat has two options available: dotenv, yaml GddNacosConfigFormat envVariable = "GDD_NACOS_CONFIG_FORMAT" GddNacosConfigGroup envVariable = "GDD_NACOS_CONFIG_GROUP" GddNacosConfigDataid envVariable = "GDD_NACOS_CONFIG_DATAID" // GddWeight node weight GddWeight envVariable = "GDD_WEIGHT" GddApolloCluster envVariable = "GDD_APOLLO_CLUSTER" GddApolloAddr envVariable = "GDD_APOLLO_ADDR" GddApolloNamespace envVariable = "GDD_APOLLO_NAMESPACE" GddApolloBackupEnable envVariable = "GDD_APOLLO_BACKUP_ENABLE" GddApolloBackupPath envVariable = "GDD_APOLLO_BACKUP_PATH" GddApolloMuststart envVariable = "GDD_APOLLO_MUSTSTART" GddApolloSecret envVariable = "GDD_APOLLO_SECRET" GddApolloLogEnable envVariable = "GDD_APOLLO_LOG_ENABLE" // GddSqlLogEnable only for doc purpose GddSqlLogEnable envVariable = "GDD_SQL_LOG_ENABLE" GddStatsFreq envVariable = "GDD_STATS_FREQ" GddRegisterHost envVariable = "GDD_REGISTER_HOST" GddEtcdEndpoints envVariable = "GDD_ETCD_ENDPOINTS" GddEtcdLease envVariable = "GDD_ETCD_LEASE" // configs for memberlist component // GddMemSeed sets cluster seeds for joining GddMemSeed envVariable = "GDD_MEM_SEED" // GddMemName unique name of this node in cluster. if empty or not set, hostname will be used instead GddMemName envVariable = "GDD_MEM_NAME" // GddMemHost specify AdvertiseAddr attribute of memberlist config struct. // if GddMemHost starts with dot such as .seed-svc-headless.default.svc.cluster.local, // it will be prefixed by hostname such as seed-2.seed-svc-headless.default.svc.cluster.local // for supporting k8s stateful service // if empty or not set, private ip will be used instead. GddMemHost envVariable = "GDD_MEM_HOST" // GddMemPort if empty or not set, an available port will be chosen randomly. recommend specifying a port GddMemPort envVariable = "GDD_MEM_PORT" // GddMemDeadTimeout dead node will be removed from node map if not received refute messages from it in GddMemDeadTimeout second // expose GossipToTheDeadTime property of memberlist.Config GddMemDeadTimeout envVariable = "GDD_MEM_DEAD_TIMEOUT" // GddMemSyncInterval local node will synchronize states from other random node every GddMemSyncInterval second // expose PushPullInterval property of memberlist.Config GddMemSyncInterval envVariable = "GDD_MEM_SYNC_INTERVAL" // GddMemReclaimTimeout dead node will be replaced with new node with the same name but different full address in GddMemReclaimTimeout second // expose DeadNodeReclaimTime property of memberlist.Config GddMemReclaimTimeout envVariable = "GDD_MEM_RECLAIM_TIMEOUT" // GddMemProbeInterval probe interval // expose ProbeInterval property of memberlist.Config GddMemProbeInterval envVariable = "GDD_MEM_PROBE_INTERVAL" // GddMemProbeTimeout probe timeout // expose ProbeTimeout property of memberlist.Config GddMemProbeTimeout envVariable = "GDD_MEM_PROBE_TIMEOUT" // GddMemSuspicionMult is the multiplier for determining the time an inaccessible node is considered suspect before declaring it dead. // expose SuspicionMult property of memberlist.Config GddMemSuspicionMult envVariable = "GDD_MEM_SUSPICION_MULT" GddMemRetransmitMult envVariable = "GDD_MEM_RETRANSMIT_MULT" // GddMemGossipNodes how many remote nodes you want to gossip messages // expose GossipNodes property of memberlist.Config GddMemGossipNodes envVariable = "GDD_MEM_GOSSIP_NODES" // GddMemGossipInterval gossip interval // expose GossipInterval property of memberlist.Config GddMemGossipInterval envVariable = "GDD_MEM_GOSSIP_INTERVAL" // GddMemTCPTimeout tcp timeout // expose TCPTimeout property of memberlist.Config GddMemTCPTimeout envVariable = "GDD_MEM_TCP_TIMEOUT" // GddMemWeight node weight GddMemWeight envVariable = "GDD_MEM_WEIGHT" // GddMemWeightInterval node weight will be calculated every GddMemWeightInterval GddMemWeightInterval envVariable = "GDD_MEM_WEIGHT_INTERVAL" GddMemIndirectChecks envVariable = "GDD_MEM_INDIRECT_CHECKS" GddMemLogDisable envVariable = "GDD_MEM_LOG_DISABLE" // GddMemCIDRsAllowed If not set, allow any connection (default), otherwise specify all networks // allowed connecting (you must specify IPv6/IPv4 separately) GddMemCIDRsAllowed envVariable = "GDD_MEM_CIDRS_ALLOWED" GddDBDisableAutoConfigure envVariable = "GDD_DB_DISABLEAUTOCONFIGURE" GddDBDriver envVariable = "GDD_DB_DRIVER" GddDBDsn envVariable = "GDD_DB_DSN" GddDBTablePrefix envVariable = "GDD_DB_TABLE_PREFIX" GddDBSkipDefaultTransaction envVariable = "GDD_DB_SKIPDEFAULTTRANSACTION" GddDBMaxIdleConns envVariable = "GDD_DB_POOL_MAXIDLECONNS" GddDBMaxOpenConns envVariable = "GDD_DB_POOL_MAXOPENCONNS" GddDBConnMaxLifetime envVariable = "GDD_DB_POOL_CONNMAXLIFETIME" GddDBConnMaxIdleTime envVariable = "GDD_DB_POOL_CONNMAXIDLETIME" GddDBPrepareStmt envVariable = "GDD_DB_PREPARESTMT" GddDBLogSlowThreshold envVariable = "GDD_DB_LOG_SLOWTHRESHOLD" GddDBLogIgnoreRecordNotFoundError envVariable = "GDD_DB_LOG_IGNORERECORDNOTFOUNDERROR" GddDBLogParameterizedQueries envVariable = "GDD_DB_LOG_PARAMETERIZEDQUERIES" GddDBLogLevel envVariable = "GDD_DB_LOG_LEVEL" GddDBMysqlSkipInitializeWithVersion envVariable = "GDD_DB_MYSQL_SKIPINITIALIZEWITHVERSION" GddDBMysqlDefaultStringSize envVariable = "GDD_DB_MYSQL_DEFAULTSTRINGSIZE" //GddDBMysqlDefaultDatetimePrecision envVariable = "GDD_DB_MYSQL_DEFAULTDATETIMEPRECISION" GddDBMysqlDisableWithReturning envVariable = "GDD_DB_MYSQL_DISABLEWITHRETURNING" GddDBMysqlDisableDatetimePrecision envVariable = "GDD_DB_MYSQL_DISABLEDATETIMEPRECISION" GddDBMysqlDontSupportRenameIndex envVariable = "GDD_DB_MYSQL_DONTSUPPORTRENAMEINDEX" GddDBMysqlDontSupportRenameColumn envVariable = "GDD_DB_MYSQL_DONTSUPPORTRENAMECOLUMN" GddDBMysqlDontSupportNullAsDefaultValue envVariable = "GDD_DB_MYSQL_DONTSUPPORTNULLASDEFAULTVALUE" GddDBMysqlDontSupportRenameColumnUnique envVariable = "GDD_DB_MYSQL_DONTSUPPORTRENAMECOLUMNUNIQUE" GddDBPostgresPreferSimpleProtocol envVariable = "GDD_DB_POSTGRES_PREFERSIMPLEPROTOCOL" GddDBPostgresWithoutReturning envVariable = "GDD_DB_POSTGRES_WITHOUTRETURNING" GddDbPrometheusEnable envVariable = "GDD_DB_PROMETHEUS_ENABLE" GddDbPrometheusRefreshInterval envVariable = "GDD_DB_PROMETHEUS_REFRESHINTERVAL" GddDbPrometheusDBName envVariable = "GDD_DB_PROMETHEUS_DBNAME" GddDbCacheEnable envVariable = "GDD_DB_CACHE_ENABLE" GddCacheTTL envVariable = "GDD_CACHE_TTL" GddCacheStores envVariable = "GDD_CACHE_STORES" GddCacheRedisAddr envVariable = "GDD_CACHE_REDIS_ADDR" GddCacheRedisUser envVariable = "GDD_CACHE_REDIS_USER" GddCacheRedisPass envVariable = "GDD_CACHE_REDIS_PASS" GddCacheRedisRouteByLatency envVariable = "GDD_CACHE_REDIS_ROUTEBYLATENCY" GddCacheRedisRouteRandomly envVariable = "GDD_CACHE_REDIS_ROUTERANDOMLY" GddCacheRistrettoNumCounters envVariable = "GDD_CACHE_RISTRETTO_NUMCOUNTERS" GddCacheRistrettoMaxCost envVariable = "GDD_CACHE_RISTRETTO_MAXCOST" GddCacheRistrettoBufferItems envVariable = "GDD_CACHE_RISTRETTO_BUFFERITEMS" GddCacheGocacheExpiration envVariable = "GDD_CACHE_GOCACHE_EXPIRATION" GddCacheGocacheCleanupInterval envVariable = "GDD_CACHE_GOCACHE_CLEANUP_INTERVAL" GddZkServers envVariable = "GDD_ZK_SERVERS" GddZkSequence envVariable = "GDD_ZK_SEQUENCE" GddZkDirectoryPattern envVariable = "GDD_ZK_DIRECTORY_PATTERN" )
View Source
const ( // Default configs for framework component DefaultGddBanner = true DefaultGddBannerText = FrameworkName DefaultGddLogLevel = "info" DefaultGddLogFormat = "text" DefaultGddLogReqEnable = false DefaultGddLogCaller = true DefaultGddLogDiscard = false DefaultGddLogPath = "" DefaultGddLogStyle = "json" DefaultGddGraceTimeout = "15s" DefaultGddWriteTimeout = "15s" DefaultGddReadTimeout = "15s" DefaultGddIdleTimeout = "60s" DefaultGddServiceName = "" DefaultGddServiceGroup = "" DefaultGddServiceVersion = "" DefaultGddRouteRootPath = "" DefaultGddHost = "" DefaultGddPort = 6060 DefaultGddGrpcPort = 50051 DefaultGddRetryCount = 0 DefaultGddManage = true DefaultGddManageUser = "admin" DefaultGddManagePass = "admin" DefaultGddTracingMetricsRoot = "tracing" DefaultGddWeight = 1 DefaultGddServiceDiscoveryMode = "" DefaultGddNacosNamespaceId = "public" DefaultGddNacosTimeoutMs = 10000 DefaultGddNacosNotLoadCacheAtStart = false DefaultGddNacosLogDir = "/tmp/nacos/log" DefaultGddNacosCacheDir = "/tmp/nacos/cache" DefaultGddNacosLogLevel = "info" DefaultGddNacosLogDiscard = false DefaultGddNacosServerAddr = "" DefaultGddNacosRegisterHost = "" DefaultGddNacosClusterName = "DEFAULT" DefaultGddNacosGroupName = "DEFAULT_GROUP" DefaultGddNacosConfigFormat = configmgr.DotenvConfigFormat DefaultGddNacosConfigGroup = "DEFAULT_GROUP" DefaultGddNacosConfigDataid = "" DefaultGddEnableResponseGzip = true DefaultGddAppType = "rest" DefaultGddFallbackContentType = "application/json; charset=UTF-8" DefaultGddRouterSaveMatchedRoutePath = true DefaultGddConfigRemoteType = "" DefaultGddApolloCluster = "default" DefaultGddApolloAddr = "" DefaultGddApolloNamespace = "application.properties" DefaultGddApolloBackupEnable = true DefaultGddApolloBackupPath = "" DefaultGddApolloSecret = "" DefaultGddApolloMuststart = false DefaultGddApolloLogEnable = false // DefaultGddSqlLogEnable only for doc purpose DefaultGddSqlLogEnable = false DefaultGddStatsFreq = "1s" DefaultGddRegisterHost = "" DefaultGddEtcdEndpoints = "" DefaultGddEtcdLease int64 = 5 // Default configs for memberlist component DefaultGddMemSeed = "" DefaultGddMemPort = 7946 DefaultGddMemDeadTimeout = "60s" DefaultGddMemSyncInterval = "60s" DefaultGddMemReclaimTimeout = "3s" DefaultGddMemProbeInterval = "5s" DefaultGddMemProbeTimeout = "3s" DefaultGddMemSuspicionMult = 6 DefaultGddMemRetransmitMult = 4 DefaultGddMemGossipNodes = 4 DefaultGddMemGossipInterval = "500ms" DefaultGddMemTCPTimeout = "30s" DefaultGddMemIndirectChecks = 3 DefaultGddMemWeight = 1 DefaultGddMemWeightInterval = 0 DefaultGddMemName = "" DefaultGddMemHost = "" DefaultGddMemCIDRsAllowed = "" DefaultGddMemLogDisable = false DefaultGddDBDisableAutoConfigure = false DefaultGddDBDriver = "" DefaultGddDBDsn = "" DefaultGddDBTablePrefix = "" DefaultGddDBMaxIdleConns = 2 DefaultGddDBMaxOpenConns = -1 DefaultGddDBConnMaxLifetime = -1 DefaultGddDBConnMaxIdleTime = -1 DefaultGddDBLogSlowThreshold = "200ms" DefaultGddDBLogIgnoreRecordNotFoundError = false DefaultGddDBLogParameterizedQueries = false DefaultGddDBLogLevel = logger.Warn DefaultGddDBMysqlSkipInitializeWithVersion = false DefaultGddDBMysqlDefaultStringSize = 0 //DefaultGddDBMysqlDefaultDatetimePrecision envVariable = "GDD_DB_MYSQL_DEFAULTDATETIMEPRECISION" DefaultGddDBMysqlDisableWithReturning = false DefaultGddDBMysqlDisableDatetimePrecision = false DefaultGddDBMysqlDontSupportRenameIndex = false DefaultGddDBMysqlDontSupportRenameColumn = false DefaultGddDBMysqlDontSupportNullAsDefaultValue = false DefaultGddDBMysqlDontSupportRenameColumnUnique = false DefaultGddDBPostgresPreferSimpleProtocol = false DefaultGddDBPostgresWithoutReturning = false DefaultGddZkServers = "" DefaultGddZkSequence = false DefaultGddZkDirectoryPattern = "/registry/%s/providers" DefaultGddDbPrometheusEnable = false DefaultGddDbPrometheusRefreshInterval = 15 DefaultGddDbPrometheusDBName = "" DefaultGddDbCacheEnable = false DefaultGddCacheRedisAddr = "" DefaultGddCacheRedisUser = "" DefaultGddCacheRedisPass = "" DefaultGddCacheRedisRouteByLatency = true DefaultGddCacheRedisRouteRandomly = false DefaultGddCacheTTL = 0 DefaultGddCacheStores = "" DefaultGddCacheRistrettoNumCounters = 1000 DefaultGddCacheRistrettoMaxCost = 100 DefaultGddCacheRistrettoBufferItems = 64 DefaultGddCacheGocacheExpiration = "5m" DefaultGddCacheGocacheCleanupInterval = "10m" DefaultGddDBSkipDefaultTransaction = false DefaultGddDBPrepareStmt = false )
View Source
const FrameworkName = "go-doudou"
Variables ¶
View Source
var G_LogFile *os.File
View Source
var GddConfig = &gddConfig{}
Functions ¶
func GetGrpcPort ¶
func GetGrpcPort() uint64
func GetNacosClientParam ¶
func GetNacosClientParam() vo.NacosClientParam
func GetServiceName ¶
func GetServiceName() string
func LoadConfigFromLocal ¶
func LoadConfigFromLocal()
func LoadConfigFromRemote ¶
func LoadConfigFromRemote()
func ServiceDiscoveryMap ¶
func ServiceDiscoveryMap() map[string]struct{}
Types ¶
type Config ¶
type Config struct { Db struct { Name string Driver string Dsn string Table struct { // for postgresql schema only Prefix string } PrepareStmt bool SkipDefaultTransaction bool DisableNestedTransaction bool Log struct { Level string SlowThreshold string `default:"200ms"` IgnoreRecordNotFoundError bool ParameterizedQueries bool } Mysql struct { SkipInitializeWithVersion bool DefaultStringSize int DisableWithReturning bool DisableDatetimePrecision bool DontSupportRenameIndex bool DontSupportRenameColumn bool DontSupportForShareClause bool DontSupportNullAsDefaultValue bool DontSupportRenameColumnUnique bool } Postgres struct { PreferSimpleProtocol bool WithoutReturning bool } Pool struct { MaxIdleConns int `default:"2"` MaxOpenConns int `default:"-1"` ConnMaxLifetime string ConnMaxIdleTime string } Cache struct { Enable bool ManualConfigure bool } Prometheus struct { Enable bool RefreshInterval int `default:"15"` DBName string } } Cache struct { TTL int Stores string Redis struct { Addr string Username string Password string RouteByLatency bool `default:"true"` RouteRandomly bool DB int Sentinel struct { Master string Nodes string Password string } } Ristretto struct { NumCounters int64 `default:"1000"` MaxCost int64 `default:"100"` BufferItems int64 `default:"64"` } GoCache struct { Expiration time.Duration `default:"5m"` CleanupInterval time.Duration `default:"10m"` } } Service struct { Name string } }
Click to show internal directories.
Click to hide internal directories.