Skip to content

Import path: gitlab.soludian.com/soludian/fountain/constants

constants

go
import "gitlab.soludian.com/soludian/fountain/constants"

Index

Constants

go
const (
    // KConfigPriorityEnv ưu tiên cho các cấu hình môi trường (Environment Configurations)
    KConfigPriorityEnv = iota + 1

    // KConfigPriorityLog ưu tiên cho cấu hình logging (ghi nhật ký) và xử lý log
    KConfigPriorityLog

    // KConfigPriorityCrypto ưu tiên cho các cấu hình mã hóa, bảo mật dữ liệu
    KConfigPriorityCrypto

    // KConfigPriorityServiceDiscovery ưu tiên cho cấu hình khám phá dịch vụ (Service Discovery) như Consul, Eureka
    KConfigPriorityServiceDiscovery

    // KConfigPriorityServer ưu tiên cho cấu hình máy chủ chính hoặc backend chính
    KConfigPriorityServer
    KConfigPriorityServerUDP
    KConfigPriorityServerTCP
    KConfigPriorityServerHTTP
    KConfigPriorityServerGRPC

    // KConfigPriorityTracing ưu tiên cho cấu hình Distributed Tracing để theo dõi luồng xử lý giữa các microservices
    KConfigPriorityTracing
    KConfigPriorityTracingSentry

    // KConfigPriorityLib ưu tiên cho các thư viện và phụ thuộc ngoài
    KConfigPriorityLib

    // KConfigPriorityClient ưu tiên cho cấu hình các client kết nối đến backend
    KConfigPriorityClient
    KConfigPriorityClientUDP
    KConfigPriorityClientTCP
    KConfigPriorityClientHTTP
    KConfigPriorityClientGRPC

    // KConfigPriorityJobScheduler ưu tiên cho cấu hình các job định kỳ, cron jobs hoặc task scheduling
    KConfigPriorityJobScheduler

    // KConfigPriorityBrokers ưu tiên cho cấu hình hàng đợi tin nhắn (message brokers)
    KConfigPriorityBrokers

    // KConfigPriorityCache ưu tiên cho cấu hình hệ thống cache (Redis, Memcached)
    KConfigPriorityCache

    // KConfigPriorityDB ưu tiên cho cấu hình cơ sở dữ liệu
    KConfigPriorityDB

    // KConfigPriorityStorage ưu tiên cho cấu hình lưu trữ dữ liệu như S3, Blob Storage
    KConfigPriorityStorage
)

go
const (
    // Context key
    KContextKeyTokenID       = "TokenID"
    KContextKeyDeviceKind    = "DeviceKind"
    KContextKeyDeviceIP      = "DeviceIP" // IP khi mà thiết bị được cấp token, có thể khác với IP thực tế của request nếu user dùng proxy hoặc VPN
    KContextKeyUserID        = "UserID"
    KContextKeyUserName      = "UserName" // Can be using on basic auth
    KContextKeyBearToken     = "BearToken"
    KContextKeyBasicPassword = "Password" // Basic auth
    KContextKeyIs2FAPending  = "Is2FAPending"
    KContextKeyRoles         = "Roles"
)

go
const (
    // KFountainMaxProcessesEnvKey configures the maximum number of processes
    KFountainMaxProcessesEnvKey = "FOUNTAIN_MAX_PROCESSES"
    // KFountainConfigPathEnvKey is the environment variable for application configuration path
    KFountainConfigPathEnvKey = "FOUNTAIN_CONFIG_PATH"
    // KFountainWatchConfig is the environment variable to watch configuration changes
    KFountainWatchConfigEnvKey = "FOUNTAIN_WATCH_CONFIG"
    // KFountainEnvironmentEnvKey is the environment variable for application mode
    KFountainEnvironmentEnvKey = "FOUNTAIN_ENVIRONMENT"
    // KFountainNamespaceEnvKey is the environment variable for application namespace
    KFountainNamespaceEnvKey = "FOUNTAIN_NAMESPACE"
    // KFountainRegionEnvKey...
    KFountainRegionEnvKey = "FOUNTAIN_REGION"
    // KFountainZoneEnvKey...
    KFountainZoneEnvKey = "FOUNTAIN_ZONE"
    // KFountainDebugModeEnvKey is the debug environment variable; set FOUNTAIN_DEBUG_MODE=true to enabxle debug mode
    KFountainDebugModeEnvKey = "FOUNTAIN_DEBUG_MODE"
    // KFountainDisableAuxiliaryConfigEnvKey indicates whether auxiliary configuration is disabled
    KFountainDisableAuxiliaryConfigEnvKey = "FOUNTAIN_DISABLE_AUXILIARY_CONFIG"
    // KFountainDisableMetricsConfigEnvKey indicates whether metrics configuration is disabled
    KFountainDisableMetricsConfigEnvKey = "FOUNTAIN_DISABLE_METRICS_CONFIG"
    // KFountainEnableGovernanceConfigEnvKey indicates whether governance configuration is enabled
    KFountainEnableGovernanceConfigEnvKey = "FOUNTAIN_ENABLE_GOVERNANCE_CONFIG"

    // KFountainConfigRawEnvKey is where raw configuration creates a new config file
    KFountainConfigRawEnvKey = "FOUNTAIN_CONFIG_RAW"

    // KFountainComponentNameEnvKey indicates the component name; app.kubernetes.io/component
    KFountainComponentNameEnvKey = "FOUNTAIN_COMPONENT_NAME"
    // KFountainPartOfEnvKey indicates the component name; app.kubernetes.io/part-of
    KFountainPartOfEnvKey = "FOUNTAIN_PART_OF"
    // KFountainServerIDEnvKey indicates the app ID of the application; pod name/ID in Kubernetes
    KFountainServerIDEnvKey = "FOUNTAIN_POD_NAME"
    // KFountainImageNameEnvKey indicates the image name of the application
    KFountainImageNameEnvKey = "FOUNTAIN_IMAGE_NAME"
    // KFountainAppVersionEnvKey indicates the version of the application
    KFountainAppVersionEnvKey = "FOUNTAIN_APP_VERSION"
    // KFountainAddrEnvKey indicates the address of the application
    KFountainAddrEnvKey = "FOUNTAIN_ADDR"
    // KFountainDomainEnvKey indicates the domain of the application
    KFountainDomainEnvKey = "FOUNTAIN_DOMAIN"
    // KFountainDCNameEnvKey indicates the DC name of the application
    KFountainDCNameEnvKey = "FOUNTAIN_DC_NAME"
    // KFountainNodeNameEnvKey indicates the node name of the application
    KFountainNodeNameEnvKey = "FOUNTAIN_NODE_NAME"
    // KFountainNodeIPEnvKey indicates the node name of the application
    KFountainNodeIPEnvKey = "FOUNTAIN_NODE_IP"
    // KFountainServiceNameEnvKey indicates the service name of the application
    KFountainServiceNameEnvKey = "FOUNTAIN_SERVICE_NAME"
    // KFountainEndpointPrefixEnvKey indicates the endpoint prefix of the application
    KFountainEndpointPrefixEnvKey = "FOUNTAIN_ENDPOINT_PREFIX"

    // KFountainK8SServerHostEnvKey is automatically set by Kubernetes
    KFountainK8SServerHostEnvKey = "KUBERNETES_SERVICE_HOST"
    // KFountainK8SServerPortEnvKey is automatically set by Kubernetes
    KFountainK8SServerPortEnvKey = "KUBERNETES_SERVICE_PORT"

    // KFountainLogFileLevelEnvKey indicates the log file level of the application
    KFountainLogFileLevelEnvKey = "FOUNTAIN_LOG_FILE_LEVEL"
    // KFountainLogPrintLevelEnvKey indicates the log print level of the application
    KFountainLogPrintLevelEnvKey = "FOUNTAIN_LOG_PRINT_LEVEL"
    // KFountainLogPathEnvKey is the environment variable for application log path
    KFountainLogPathEnvKey = "FOUNTAIN_LOG_PATH"
    // KFountainLogPrefixEnvKey indicates the log prefix of the application
    KFountainLogPrefixEnvKey = "FOUNTAIN_LOG_PREFIX"
    // KFountainTraceIDNameEnvKey indicates the trace ID name of the application; default is x-trace-id
    KFountainTraceIDNameEnvKey = "FOUNTAIN_TRACE_ID_NAME"
    // KFountainLogExtraEnvKeysEnvKey extends the tracking field, usually used to print custom headers/metadata
    // Configuration format {key1},{key2},{key3}..., multiple keys are separated by ","
    // For example, export FOUNTAIN_LOG_EXTRA_KEYS=X-KFountain-Uid,X-KFountain-Order-Id
    // These extended tracking fields will find the corresponding values from Headers(HTTP) or Metadata(gRPC) according to the configured key names such as key1, key2, key3, and print them to the request log
    KFountainLogExtraEnvKeysEnvKey = "FOUNTAIN_LOG_EXTRA_KEYS"
    // KFountainLogWriterEnvKey
    KFountainLogWriterEnvKey = "DEFAULT_LOG_WRITER"
    // KFountainLogTimeTypeEnvKey records the time type; default is second, millisecond, %Y-%m-%d %H:%M:%S
    KFountainLogTimeTypeEnvKey    = "FOUNTAIN_LOG_LOG_TIME_TYPE"
    KFountainLogSentryDNSEnvKey   = "FOUNTAIN_LOG_SENTRY_DNS"
    KFountainLogFullAppInfoEnvKey = "FOUNTAIN_LOG_FULL_APP_INFO"

    // KFountainJobNameEnvKey is the job name if the app runs as a job; split by "," or ";"
    KFountainJobNameEnvKey   = "FOUNTAIN_JOB_NAME"
    KFountainJobHeaderEnvKey = "FOUNTAIN_JOB_HEADER"
    KFountainJobDataEnvKey   = "FOUNTAIN_JOB_DATA"
)

App

go
const (
    K_DEFAULT_FOUNTAIN_COMPONENT_NAME = "fountain"
    K_DEFAULT_FOUNTAIN_PART_OF        = "system"
)

HTTP HEADER

go
const (
    KDefaultHeaderTraceID    string = "X-Fountain-Trace-ID"
    KDefaultHeaderEncryption string = "X-Fountain-Encryption"
)

Context

go
const (
    KContextMetadataServerID       string = "x-fountain-server-id"
    KContextMetadataSessionID      string = "x-fountain-session-id"
    KContextMetadataClientRemoteIP string = "x-fountain-client-remote-ip"
    KContextMetadataTraceID        string = "x-fountain-trace-id"
    KContextMetadataSpanID         string = "x-fountain-span-id"
    KContextMetadataReceiveTime    string = "x-fountain-receive-time"
    KContextMetadataBotID          string = "x-fountain-bot-id"
    KContextMetadataClientMsgID    string = "x-fountain-client-msg-id"

    // Data of bot
    KContextKeyValue string = `x-fountain-user-full-key`
)

AWS

go
const (
    KDefaultAwsRegion     string = "ap-southeast-1"
    KDefaultS3DirData     string = "fountain"
    KDefaultAwsPermission string = "public-read"
)

Device

go
const (
    KDeviceKindWeb     string = "web"
    KDeviceKindMobile  string = "mobile"
    KDeviceKindDesktop string = "desktop"
    KDeviceKindTablet  string = "tablet"
    KDeviceKindOther   string = "other"
)

constant for token storage

go
const (
    KCacheUserAuthorizationFormat            string = "user-session:%s" // userUUID
    KCacheUserAuthorizationTokenField        string = "token"
    KCacheUserAuthorizationAndroidTokenField string = "android-token"
    KCacheUserAuthorizationIOSTokenField     string = "ios-token"
    KCacheUserAuthorizationWebTokenField     string = "web-token"
)

constant for expire time

go
const (
    KCacheExpiresInForever        = 0
    KCacheExpiresInOneMinute      = time.Minute
    KCacheExpiresInTenMinutes     = time.Minute * 10
    KCacheExpiresInFifteenMinutes = time.Minute * 15
    KCacheExpiresInOneHour        = time.Hour
    KCacheExpiresInTwoHour        = KCacheExpiresInOneHour * 2
    KCacheExpiresInOneDay         = KCacheExpiresInOneHour * 24
    KCacheExpiresInThreeDay       = KCacheExpiresInOneDay * 3
    KCacheExpiresInSevenDay       = KCacheExpiresInOneDay * 7
    KCacheExpiresInOneMonth       = KCacheExpiresInOneDay * 30
    KCacheExpiresInThreeMonths    = KCacheExpiresInOneMonth * 3
    KCacheExpiresInSixMonths      = KCacheExpiresInOneMonth * 6
    KCacheExpiresInOneYear        = KCacheExpiresInOneMonth * 12
)

go
const (
    // KKeyRouteConfig ...
    KKeyRouteConfig = "__route_config__"

    // KKeyProviderConfig ...
    KKeyProviderConfig = "__provider_config__"

    // KKeyConsumerConfig ...
    KKeyConsumerConfig = "__consumer_config__"

    // KKeyServiceInfo ...
    KKeyServiceInfo = "__service_info__"
)

go
const (
    KLabelKeyComponentName  = "component" // component >> part_of >> service >> server name (server id)
    KLabelPartOf            = "part_of"
    KLabelKeyService        = "service"
    KLabelKeyServerID       = "server" // Name of server, 1 service have 1 (or multi) server (s)
    KLabelKeyTransport      = "transport"
    KLabelKeyRouter         = "route"
    KLabelKeyTarget         = "target" // client call to server with target address
    KLabelKeyJobName        = "job"
    KLabelKeyClientApp      = "client_app"
    KLabelKeyInstanceName   = "instance_name" // For any instance of libs
    KLabelKeyPeer           = "peer"
    KLabelKeyQueue          = "queue"
    KLabelKeyCache          = "cache"
    KLabelKeyDatabase       = "database"
    KLabelKeyStorage        = "storage"
    KLabelKeyResponseCode   = "reps_code"
    KLabelKeyResponseStatus = "reps_status"
    KLabelKeyCommandName    = "command"
    KLabelKeyQueryName      = "query"

    KLabelValueTransportHTTP             = "http"
    KLabelValueTransportGRPC             = "grpc"
    KLabelValueTransportTCP              = "tcp"
    KLabelValueTransportUDP              = "udp"
    KLabelValueTransportGRPCUnary        = "grpc_unary"
    KLabelValueTransportGRPCStream       = "grpc_stream"
    KLabelValueTransportWebsocket        = "ws"
    KLabelValueQueueKafka                = "kafka"
    KLabelValueQueueMQTT                 = "mqtt"
    KLabelValueQueueAMQP                 = "amqp"
    KLabelValueCacheRedis                = "redis"
    KLabelValueCacheMemCache             = "memcache"
    KLabelValueDatabaseBBoltDB           = "bbolt"
    KLabelValueDatabaseMongoDB           = "mongodb"
    KLabelValueDatabaseMySQL             = "mysql"
    KLabelValueDatabasePostgreSQL        = "postgresql"
    KLabelValueDatabaseEventStoreDB      = "event_store"
    KLabelValueDatabaseCassandra         = "cassandra"
    KLabelValueStorageElastic            = "elastic"
    KLabelValueStorageS3                 = "s3"
    KLabelValueSKeyResponseStatusSuccess = "success"
    KLabelValueSKeyResponseStatusError   = "error"

    KDefaultFountainNamespace = "fountain"
)

go
const (
    KDefaultLogPath   = "/var/log/fountain"
    KDefaultLogPrefix = "fountain"
)

go
const (
    K_OTEL_EXPORTER_JAEGER_AGENT_HOST_KEY = "OTEL_EXPORTER_JAEGER_AGENT_HOST"
    K_OTEL_EXPORTER_JAEGER_AGENT_PORT_KEY = "OTEL_EXPORTER_JAEGER_AGENT_PORT"
    K_OTEL_EXPORTER_JAEGER_ENDPOINT_KEY   = "OTEL_EXPORTER_JAEGER_ENDPOINT"
    K_OTEL_EXPORTER_JAEGER_USER_KEY       = "OTEL_EXPORTER_JAEGER_USER"
    K_OTEL_EXPORTER_JAEGER_PASSWORD_KEY   = "OTEL_EXPORTER_JAEGER_PASSWORD" // #nosec G101
    K_OTEL_EXPORTER_OTLP_ENDPOINT_KEY     = "OTEL_EXPORTER_OTLP_ENDPOINT"
)

go
const (
    // DefaultConfig
    KDefaultConfig = "config.yaml"
)

go
const (
    K_CONFIG_KEY_AUXILIARY_SERVER = "auxiliary"
)

type ServerProtocol

go
type ServerProtocol string

go
const (
    KServerProtocolUnknown ServerProtocol = "unknown"
    // KServerTypeProvider service http
    KServerProtocolHTTP ServerProtocol = "http"
    // KServerTypeProvider service udp
    KServerProtocolUDP ServerProtocol = "udp"
    // KServerTypeProvider service tcp
    KServerProtocolTCP ServerProtocol = "tcp"
    // KServerTypeProvider service grpc
    KServerProtocolGRPC ServerProtocol = "grpc"
)

type ServiceKind

go
type ServiceKind string

go
const (
    KServerKindUnknown     ServiceKind = "unknown"
    KServerKindProvider    ServiceKind = "providers"
    KServerProtocolMetrics ServiceKind = "metrics"
    KServerKindGovernor    ServiceKind = "governor"
    KServerKindConsumer    ServiceKind = "consumers"
    KServerKindSubscriber  ServiceKind = "subscribers"
)

Generated by gomarkdoc