profile

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 3 Imported by: 8

Documentation

Overview

Package profile provides environment profile and configuration utilities for application setup and runtime behavior control.

Index

Constants

View Source
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
)
View Source
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
)
View Source
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"
)
View Source
const (
	ProfileDev  = "dev"
	ProfileTest = "test"
	ProfileProd = "prod"
)

Profile is the running model of the service

View Source
const (
	StatusClient = "client"
	StatusAdmin  = "admin"
	StatusDev    = "dev"
)

Status is the status of this connection

View Source
const (
	ColorLocal = "local"
)

Color is the color of the service, the message will be routed to the corresponding color node

View Source
const (
	// OrgPrefix defines the organization prefix for environment variables and configuration keys.
	OrgPrefix = "PANTHEON_"
)

Variables

This section is empty.

Functions

func Color

func Color() string

Color returns the current deployment color.

func GRPCEndpoint

func GRPCEndpoint() string

GRPCEndpoint returns the gRPC endpoint string.

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

func IsDevStr(profile string) bool

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

func IsProdStr(profile string) bool

IsProdStr checks if the given profile string is the production profile. Returns true if the profile string matches the production profile.

func IsTestStr

func IsTestStr(profile string) bool

IsTestStr checks if the given profile string is the test profile. Returns true if the profile string matches the test profile.

func NodeName

func NodeName() string

NodeName returns the name of the current node.

func PageStartLimit added in v0.0.6

func PageStartLimit(page, size int64) (start, limit int64)

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.

func Profile

func Profile() string

Profile returns the current environment profile.

func Version

func Version() string

Version returns the current version string.

func Zone

func Zone() uint32

Zone returns the current zone identifier.

Types

This section is empty.

Jump to

Keyboard shortcuts

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