config

package
v1.2.127 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	CfgPulseDeployment         = "PULSE_DEPLOYMENT"           // Pulse deployment name
	CfgHostName                = "HOSTNAME"                   // Host name
	CfgLoglevel                = "LOG_LEVEL"                  // Log level
	CfgLogJsonFormat           = "LOG_JSON_FORMAT"            // Enable Json log format
	CfgHttpReadTimeoutMs       = "HTTP_READ_TIMEOUT_MS"       // HTTP read timeout (in milliseconds)
	CfgHttpWriteTimeoutMs      = "HTTP_WRITE_TIMEOUT_MS"      // HTTP write timeout (in milliseconds)
	CfgWsKeepAliveSec          = "WS_KEEP_ALIVE_SEC"          // Web socket keep-alive period (in seconds)
	CfgWsReadBufferSizeBytes   = "WS_READ_BUFFER_SIZE_BYTES"  // Web socket read buffer size (in bytes)
	CfgWsWriteBufferSizeBytes  = "WS_WRITE_BUFFER_SIZE_BYTES" // Web socket write buffer size (in bytes)
	CfgWsWriteCompress         = "WS_WRITE_COMPRESS"          // Web socket enable compression
	CfgWsWriteTimeoutSec       = "WS_WRITE_TIMEOUT"           // Web socket write timeout (in seconds)
	CfgWsPongTimeoutSec        = "WS_PONG_TIMEOUT"            // Web socket pong response timeout (in seconds)
	CfgTopicPartitions         = "TOPIC_PARTITIONS"           // Number of partitions per topic
	CfgEnableGoRuntimeProfiler = "ENABLE_GO_RUNTIME_PROFILER" // Enable / Disable runtime profiling
	CfgGoRuntimeProfilerAddr   = "GO_RUNTIME_PROFILER_ADDR"   // Go runtime profiler address

	CfgDatabaseUri  = "DATABASE_URI"  // Configuration database URI
	CfgDatastoreUri = "DATASTORE_URI" // Big data store URI
	CfgMessagingUri = "MESSAGING_URI" // Real-time Messaging middleware URI
	CfgDataCacheUri = "DATACACHE_URI" // Distributed cache middleware URI
	CfgStreamingUri = "STREAMING_URI" // Streaming middleware URI

	// CfgEnableMessageOrdering is set to true to ensure that messages with the same ordering key are delivered in the order they were published.
	// This is crucial for use cases where the order of messages is important for correct processing.
	// Note: The Pub/Sub topic must be configured to support message ordering for this to take effect.
	// Enabling message ordering may impact the throughput of message publishing, as it requires Pub/Sub to maintain order within each ordering key.
	CfgEnableMessageOrdering = "ENABLE_MESSAGE_ORDERING"

	// CfgPubSubNumOfGoroutines NumGoroutines specifies the number of goroutines that will be used
	// to pull messages from the subscription in parallel. Each goroutine
	// opens a separate StreamingPull stream. A higher number of goroutines
	// might increase throughput but also increases the system's load.
	// Defaults to DefaultReceiveSettings.NumGoroutines when set to 0.
	CfgPubSubNumOfGoroutines = "PUBSUB_NUM_OF_GOROUTINES"

	// CfgPubSubMaxOutstandingMessages defines the maximum number of unprocessed
	// messages (messages that have been received but not yet acknowledged
	// or expired). Setting this to a lower number can prevent the consumer
	// from being overwhelmed by a large volume of incoming messages.
	// If set to 0, the default is DefaultReceiveSettings.MaxOutstandingMessages.
	// A negative value indicates no limit.
	CfgPubSubMaxOutstandingMessages = "PUBSUB_MAX_OUTSTANDING_MESSAGES"

	// CfgPubSubMaxOutstandingBytes is the maximum total size of unprocessed messages.
	// This setting helps to control memory usage by limiting the total size
	// of messages that can be held in memory at a time. If set to 0, the
	// default is DefaultReceiveSettings.MaxOutstandingBytes. A negative
	// value indicates no limit on the byte size of unprocessed messages.
	CfgPubSubMaxOutstandingBytes = "PUSUB_MAX_OUTSTANDING_BYTES"

	// CfgPubSubAckDeadline defines the acknowledgment (ack) deadline for messages in GCP Pub/Sub.
	// This setting specifies the maximum amount of time the subscriber has to acknowledge a received message
	// before it becomes eligible for re-delivery. It is typically configured in seconds. If not explicitly
	// specified in the configuration settings, it will default to 10 seconds. This helps ensure that
	// messages are not re-delivered prematurely if processing takes longer than the default deadline.
	// Example environment variable: PUBSUB_ACK_DEADLINE=30 (for a 30-second deadline).
	CfgPubSubAckDeadline = "PUBSUB_ACK_DEADLINE"

	CfgRdsInstanceName = "RDS_INSTANCE_NAME"

	CfgMaxDbConnections = "MAX_DB_CONNECTIONS"
)
View Source
const (
	DefaultPubSubNumOfGoroutines = 0
	DefaultPubSubMaxOutstandingMessages
	DefaultPubSubMaxOutstandingBytes = 0
	DefaultEnableMessageOrdering     = false
	DefaultEnableGoRuntimeProfiler   = false
	DefaultGoRuntimeProfilerAddr     = ":6060"
	DefaultMaxDbConnections          = 10
	DefaultPubSubAckDeadline         = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConfig

type BaseConfig struct {
	// contains filtered or unexported fields
}

func Get

func Get() *BaseConfig

Get singleton instance

func (*BaseConfig) AddConfigVar added in v1.1.2

func (c *BaseConfig) AddConfigVar(key, value string)

AddConfigVar adds or updates configuration variable

func (*BaseConfig) DataCacheUri added in v1.2.97

func (c *BaseConfig) DataCacheUri() string

DataCacheUri returns the distributed cache middleware URI

func (*BaseConfig) DatabaseUri added in v1.2.97

func (c *BaseConfig) DatabaseUri() string

DatabaseUri returns the database URI

func (*BaseConfig) DatastoreUri added in v1.2.97

func (c *BaseConfig) DatastoreUri() string

DatastoreUri returns the big data store URI

func (*BaseConfig) EnableGoRuntimeProfiler added in v1.2.84

func (c *BaseConfig) EnableGoRuntimeProfiler() bool

func (*BaseConfig) EnableLogJsonFormat added in v1.2.97

func (c *BaseConfig) EnableLogJsonFormat() bool

EnableLogJsonFormat returns json log format flag

func (*BaseConfig) EnableMessageOrdering added in v1.2.83

func (c *BaseConfig) EnableMessageOrdering() bool

func (*BaseConfig) GetAllKeysSorted

func (c *BaseConfig) GetAllKeysSorted() []string

GetAllKeysSorted gets a list of all the configuration keys

func (*BaseConfig) GetAllVars

func (c *BaseConfig) GetAllVars() map[string]string

GetAllVars gets a map of all the configuration variables and values

func (*BaseConfig) GetBoolParamValueOrDefault

func (c *BaseConfig) GetBoolParamValueOrDefault(key string, defaultValue bool) (val bool)

GetBoolParamValueOrDefault gets environment variable as bool

func (*BaseConfig) GetInt64ParamValueOrDefault

func (c *BaseConfig) GetInt64ParamValueOrDefault(key string, defaultValue int64) (val int64)

GetInt64ParamValueOrDefault gets environment variable as int64

func (*BaseConfig) GetIntParamValueOrDefault

func (c *BaseConfig) GetIntParamValueOrDefault(key string, defaultValue int) (val int)

GetIntParamValueOrDefault gets environment variable as int

func (*BaseConfig) GetStringParamValueOrDefault

func (c *BaseConfig) GetStringParamValueOrDefault(key string, defaultValue string) (val string)

GetStringParamValueOrDefault gets environment variable as string

func (*BaseConfig) GoRuntimeProfilerAddr added in v1.2.84

func (c *BaseConfig) GoRuntimeProfilerAddr() string

func (*BaseConfig) HostName added in v1.2.94

func (c *BaseConfig) HostName() string

HostName fetch current host (machine) name

func (*BaseConfig) HttpReadTimeoutMs

func (c *BaseConfig) HttpReadTimeoutMs() int

HttpReadTimeoutMs gets HTTP read time out in milliseconds

func (*BaseConfig) HttpWriteTimeoutMs

func (c *BaseConfig) HttpWriteTimeoutMs() int

HttpWriteTimeoutMs gets HTTP write time out in milliseconds

func (*BaseConfig) LogLevel

func (c *BaseConfig) LogLevel() string

LogLevel gets log level

func (*BaseConfig) MaxDbConnections added in v1.2.93

func (c *BaseConfig) MaxDbConnections() int

func (*BaseConfig) MessagingUri added in v1.2.97

func (c *BaseConfig) MessagingUri() string

MessagingUri returns the real-time messaging middleware URI

func (*BaseConfig) PubSubAckDeadline added in v1.2.121

func (c *BaseConfig) PubSubAckDeadline() int

PubSubAckDeadline returns the configured Pub/Sub acknowledgment deadline in seconds, or the default value of 10 seconds if not explicitly set.

func (*BaseConfig) PubSubMaxOutstandingBytes added in v1.2.81

func (c *BaseConfig) PubSubMaxOutstandingBytes() int

func (*BaseConfig) PubSubMaxOutstandingMessages added in v1.2.81

func (c *BaseConfig) PubSubMaxOutstandingMessages() int

func (*BaseConfig) PubSubNumOfGoroutines added in v1.2.81

func (c *BaseConfig) PubSubNumOfGoroutines() int

func (*BaseConfig) PulseDeployment added in v1.2.97

func (c *BaseConfig) PulseDeployment() string

PulseDeployment fetch pulse deployment name

func (*BaseConfig) RdsInstanceName added in v1.2.92

func (c *BaseConfig) RdsInstanceName() string

RdsInstanceName fetch RDS instance

func (*BaseConfig) ScanEnvVariables

func (c *BaseConfig) ScanEnvVariables()

ScanEnvVariables scans all environment variables and map their values to existing configuration keys

func (*BaseConfig) StartTime added in v1.2.95

func (c *BaseConfig) StartTime() (result entity.Timestamp)

StartTime returns the start time of the service

func (*BaseConfig) StreamingUri added in v1.2.90

func (c *BaseConfig) StreamingUri() string

StreamingUri returns the streaming middleware URI

func (*BaseConfig) TopicPartitions added in v1.2.16

func (c *BaseConfig) TopicPartitions() int

TopicPartitions gets default number of partitions per topic

func (*BaseConfig) WsKeepALiveInterval

func (c *BaseConfig) WsKeepALiveInterval() int64

WsKeepALiveInterval gets web socket keep alive interval (in seconds)

func (*BaseConfig) WsPongTimeoutSec

func (c *BaseConfig) WsPongTimeoutSec() int

WsPongTimeoutSec gets web socket PONG time out in seconds

func (*BaseConfig) WsReadBufferSizeBytes

func (c *BaseConfig) WsReadBufferSizeBytes() int

WsReadBufferSizeBytes gets web socket read buffer size

func (*BaseConfig) WsWriteBufferSizeBytes

func (c *BaseConfig) WsWriteBufferSizeBytes() int

WsWriteBufferSizeBytes gets web socket write buffer size

func (*BaseConfig) WsWriteCompress

func (c *BaseConfig) WsWriteCompress() bool

WsWriteCompress gets web socket compression on write flag

func (*BaseConfig) WsWriteTimeoutSec

func (c *BaseConfig) WsWriteTimeoutSec() int

WsWriteTimeoutSec gets web socket write time out in seconds

Jump to

Keyboard shortcuts

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