Documentation
¶
Index ¶
- Variables
- func CopyStruct(src, dst any) error
- func GenerateID(prefix string) string
- func GenerateRandomID(length int) string
- func GenerateSessionID() string
- func GenerateWorkerID() string
- func GetConfigParser(format ConfigFormat) (koanf.Parser, error)
- func InsecureCredentials() credentials.TransportCredentials
- func NeedsTLS(addr string) bool
- func TLSCredentials() credentials.TransportCredentials
- func ToSlice(v interface{}) []interface{}
- func ToStruct(m map[string]string, out interface{}) error
- func TransportCredentials(addr string) credentials.TransportCredentials
- func WithClientName(name string) func(*redis.UniversalOptions)
- type ConfigFormat
- type ConfigLoaderFunc
- type ConfigManager
- type ContainerOverlay
- type OverlayLayer
- type ParserFunc
- type RedisClient
- func (r *RedisClient) Keys(ctx context.Context, pattern string) ([]string, error)
- func (r *RedisClient) Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd
- func (r *RedisClient) Scan(ctx context.Context, pattern string) ([]string, error)
- func (r *RedisClient) Subscribe(ctx context.Context, channels ...string) (<-chan *redis.Message, <-chan error)
- func (r *RedisClient) ToSlice(v interface{}) []interface{}
- func (r *RedisClient) ToStruct(m map[string]string, out interface{}) error
- type RedisLock
- type RedisLockOption
- type RedisLockOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilMessage = errors.New("redis: nil message") ErrChannelClosed = errors.New("redis: channel closed") ErrConnectionIssue = errors.New("redis: connection issue") ErrUnknownRedisMode = errors.New("redis: unknown mode") )
var Keys = &redisKeys{}
Functions ¶
func CopyStruct ¶
func GenerateID ¶
GenerateID generates a unique ID with the given prefix. Format: prefix-timestamp-random
func GenerateRandomID ¶
GenerateRandomID generates a random ID of the specified length.
func GenerateSessionID ¶
func GenerateSessionID() string
GenerateSessionID generates a unique session ID.
func GenerateWorkerID ¶
func GenerateWorkerID() string
GenerateWorkerID generates a unique worker ID.
func GetConfigParser ¶
func GetConfigParser(format ConfigFormat) (koanf.Parser, error)
func InsecureCredentials ¶ added in v0.1.10
func InsecureCredentials() credentials.TransportCredentials
InsecureCredentials returns plaintext credentials (no TLS). Use this when the --insecure flag is explicitly set.
func NeedsTLS ¶ added in v0.1.10
NeedsTLS determines if TLS should be used for the given address.
The logic follows grpcurl's convention:
- Default to TLS for external/production addresses
- Use plaintext only for explicitly local addresses
TLS is disabled (plaintext) for:
- localhost, 127.0.0.1, ::1, *.local, *.localhost
- Kubernetes internal addresses (*.svc, *.svc.cluster.local)
TLS is enabled for everything else (production default).
func TLSCredentials ¶ added in v0.1.10
func TLSCredentials() credentials.TransportCredentials
TLSCredentials returns TLS credentials with system CAs.
func ToSlice ¶
func ToSlice(v interface{}) []interface{}
ToSlice flattens a struct using its field tags so it can be used by HSet. Struct fields must have the redis tag on them otherwise they will be ignored.
func ToStruct ¶
ToStruct copies the result of HGetAll to a provided struct. If a field cannot be parsed, we use Go's default value. Struct fields must have the redis tag on them otherwise they will be ignored.
func TransportCredentials ¶ added in v0.1.10
func TransportCredentials(addr string) credentials.TransportCredentials
TransportCredentials returns appropriate gRPC credentials for the address. Uses TLS by default, plaintext only for local/internal addresses.
func WithClientName ¶
func WithClientName(name string) func(*redis.UniversalOptions)
Types ¶
type ConfigFormat ¶
type ConfigFormat string
var ( JSONConfigFormat ConfigFormat = ".json" YAMLConfigFormat ConfigFormat = ".yaml" YMLConfigFormat ConfigFormat = ".yml" )
type ConfigLoaderFunc ¶
ConfigLoaderFunc is a function type used to load configuration into a Koanf instance. It takes a Koanf pointer 'k' as a parameter and returns an error if the loading process encounters any issues.
type ConfigManager ¶
type ConfigManager[T any] struct { // contains filtered or unexported fields }
ConfigManager is a generic configuration manager that allows handling and manipulation of configuration data for various types. It includes a Koanf instance ('kf') for managing configuration settings.
func NewConfigManager ¶
func NewConfigManager[T any]() (*ConfigManager[T], error)
NewConfigManager creates a new instance of the ConfigManager[T]. It initializes a Koanf instance and loads the default configuration. It then loads the configuration from the /etc/airstore.d/ directory and the user-specified configuration file from CONFIG_PATH. If the CONFIG_JSON environment variable is set, it loads the configuration from the JSON string. If debug mode is enabled, it prints the current configuration.
func (*ConfigManager[T]) GetConfig ¶
func (cm *ConfigManager[T]) GetConfig() T
GetConfig retrieves the current configuration of type 'T' from the ConfigManager. It unmarshals the configuration data and returns it. If any errors occur during unmarshaling, it logs a fatal error and exits the application.
func (*ConfigManager[T]) LoadConfig ¶
func (cm *ConfigManager[T]) LoadConfig(format ConfigFormat, provider koanf.Provider) error
LoadConfig loads configuration data from a given provider in the specified format into the ConfigManager. It obtains a parser for the format, and then loads the configuration data. If any errors occur during the loading process, they are returned as an error.
func (*ConfigManager[T]) Print ¶
func (cm *ConfigManager[T]) Print() string
Print returns a string representation of the current configuration state.
type ContainerOverlay ¶
type ContainerOverlay struct {
// contains filtered or unexported fields
}
ContainerOverlay manages overlay filesystem layers for containers This creates a writable layer on top of a read-only base (e.g., CLIP FUSE mount)
func NewContainerOverlay ¶
func NewContainerOverlay(sandboxID, rootPath, overlayPath string) *ContainerOverlay
NewContainerOverlay creates a new ContainerOverlay rootPath: the base rootfs (e.g., CLIP FUSE mount) overlayPath: where to store overlay layer data
func (*ContainerOverlay) AddEmptyLayer ¶
func (co *ContainerOverlay) AddEmptyLayer() error
AddEmptyLayer adds an empty writable layer on top of the current stack
func (*ContainerOverlay) AddLayer ¶
func (co *ContainerOverlay) AddLayer(upperDir string) error
AddLayer adds a pre-populated upper layer on top of the current stack
func (*ContainerOverlay) Cleanup ¶
func (co *ContainerOverlay) Cleanup() error
Cleanup unmounts all layers and removes overlay directories
func (*ContainerOverlay) Setup ¶
func (co *ContainerOverlay) Setup() error
Setup creates the initial overlay layer on top of the base rootfs
func (*ContainerOverlay) TopLayerPath ¶
func (co *ContainerOverlay) TopLayerPath() string
TopLayerPath returns the merged path of the top overlay layer This is the path that should be used as the container rootfs
func (*ContainerOverlay) UpperLayerPath ¶
func (co *ContainerOverlay) UpperLayerPath() string
UpperLayerPath returns the upper (writable) path of the top layer
type OverlayLayer ¶
type OverlayLayer struct {
// contains filtered or unexported fields
}
OverlayLayer represents a single overlay layer
type ParserFunc ¶
type RedisClient ¶
type RedisClient struct {
redis.UniversalClient
}
func NewRedisClient ¶
func NewRedisClient(config types.RedisConfig, options ...func(*redis.UniversalOptions)) (*RedisClient, error)
func (*RedisClient) Keys ¶
Keys gets all keys using a pattern. Actually runs a scan since keys locks up the database.
func (*RedisClient) ToSlice ¶
func (r *RedisClient) ToSlice(v interface{}) []interface{}
type RedisLock ¶
type RedisLock struct {
// contains filtered or unexported fields
}
func NewRedisLock ¶
func NewRedisLock(client *RedisClient, opts ...RedisLockOption) *RedisLock
type RedisLockOption ¶
type RedisLockOption func(*RedisLock)