Documentation
¶
Overview ¶
Package profile provides environment profile and configuration utilities for application setup and runtime behavior control.
Index ¶
- Constants
- func Color() string
- func GRPCEndpoint() string
- func Init(profile, color string, zone uint32, version string, nodeName string, ...)
- func IsDev() bool
- func IsDevStr(profile string) bool
- func IsLocal() bool
- func IsProdStr(profile string) bool
- func IsTestStr(profile string) bool
- func NodeName() string
- func PageStartLimit(page, size int64) (start, limit int64)
- func Profile() string
- func Version() string
- func Zone() uint32
Constants ¶
const ( // MaxPageSize defines the maximum number of items per page for pagination. MaxPageSize = 200 // DefaultPageSize defines the default number of items per page if not specified. DefaultPageSize = 20 // FirstPage defines the first page number for pagination. FirstPage = 1 )
const ( // ClientTimeout defines the default timeout for HTTP client requests. ClientTimeout = 10 * time.Second // ClientMaxIdleConns defines the maximum number of idle connections. ClientMaxIdleConns = 100 // ClientMaxIdleConnsPerHost defines the maximum idle connections per host. ClientMaxIdleConnsPerHost = 100 // ClientIdleConnTimeout defines how long an idle connection is kept in the pool. ClientIdleConnTimeout = 90 * time.Second // ClientTLSHandshakeTimeout defines the timeout for TLS handshake. ClientTLSHandshakeTimeout = 5 * time.Second )
const ( // VersionKey is the key for version information in metadata. VersionKey = "ver" // ProfileKey is the key for profile type in metadata. ProfileKey = "profile" // ServiceKey is the key for service name in metadata. ServiceKey = "svc" // ColorKey is the key for deployment color in metadata. ColorKey = "color" // NodeKey is the key for node name in metadata. NodeKey = "node" // ZoneKey is the key for zone information in metadata. ZoneKey = "zone" // UID is the key for user ID in metadata. UID = "uid" // SID is the key for session ID in metadata. SID = "sid" // StatusKey is the key for status information in metadata. StatusKey = "status" )
const ( ProfileDev = "dev" ProfileTest = "test" ProfileProd = "prod" )
Profile is the running model of the service
const ( StatusClient = "client" StatusAdmin = "admin" StatusDev = "dev" )
Status is the status of this connection
const (
ColorLocal = "local"
)
Color is the color of the service, the message will be routed to the corresponding color node
const (
// OrgPrefix defines the organization prefix for environment variables and configuration keys.
OrgPrefix = "PANTHEON_"
)
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(profile, color string, zone uint32, version string, nodeName string, gRPCEndpoint *url.URL)
Init initializes the profile settings with the given parameters. It sets up the environment profile, color, zone, version, node name, and gRPC endpoint.
func IsDev ¶
func IsDev() bool
IsDev checks if the current profile is development. Returns true if the service is running in development mode.
func IsDevStr ¶
IsDevStr checks if the given profile string is the development profile. Returns true if the profile string matches the development profile.
func IsLocal ¶
func IsLocal() bool
IsLocal checks if the current service color is local. Returns true if the service is running in local mode.
func IsProdStr ¶
IsProdStr checks if the given profile string is the production profile. Returns true if the profile string matches the production profile.
func IsTestStr ¶
IsTestStr checks if the given profile string is the test profile. Returns true if the profile string matches the test profile.
func PageStartLimit ¶ added in v0.0.6
PageStartLimit calculates the start index and limit for pagination. It returns the start offset and the number of items to fetch based on the page number and size.
Types ¶
This section is empty.