Documentation ¶
Index ¶
- Constants
- Variables
- func AuthInterceptor(token string) grpc.UnaryClientInterceptor
- func BuildDeploymentURL(externalUrl, urlType string, stub *types.StubWithRelated, ...) string
- func BuildServeURL(externalUrl, urlType string, stub *types.StubWithRelated) string
- func CopyStruct(src, dst any) error
- func Decrypt(secretKey []byte, ciphertext64 string) (string, error)
- func DecryptAllSecrets(signingKey []byte, secrets []string) ([]string, error)
- func Encrypt(secretKey []byte, plaintext string) (string, error)
- func ExtractObjectFile(ctx context.Context, objectId string, workspaceName string) error
- func GenerateObjectId() (string, error)
- func GetAWSConfig(accessKey string, secretKey string, region string, endpoint string) (aws.Config, error)
- func GetConfigParser(format ConfigFormat) (koanf.Parser, error)
- func GetTimeoutContext(baseCtx context.Context, timeoutSeconds int) (context.Context, context.CancelFunc)
- func MergeContexts(ctxs ...context.Context) (context.Context, context.CancelFunc)
- func NewChannelSlogger() *slog.Logger
- func ParseSigningKey(signingKey string) ([]byte, error)
- func SetupTelemetry(ctx context.Context, serviceName string, appConfig types.AppConfig) (shutdown func(context.Context) error, err error)
- func ToSlice(v interface{}) []interface{}
- func ToStruct(m map[string]string, out interface{}) error
- func WithClientName(name string) func(*redis.UniversalOptions)
- type ChannelHandler
- type ConfigFormat
- type ConfigLoaderFunc
- type ConfigManager
- type ContainerOverlay
- type ContainerOverlayLayer
- type Event
- type EventBus
- type EventBusSubscriber
- type EventType
- type ImageRegistry
- func (r *ImageRegistry) Exists(ctx context.Context, imageId string) bool
- func (r *ImageRegistry) Pull(ctx context.Context, localPath string, imageId string) error
- func (r *ImageRegistry) Push(ctx context.Context, localPath string, imageId string) error
- func (r *ImageRegistry) Size(ctx context.Context, imageId string) (int64, error)
- type KeyEvent
- type KeyEventManager
- type LocalObjectStore
- func (s *LocalObjectStore) Exists(ctx context.Context, key string) bool
- func (s *LocalObjectStore) Get(ctx context.Context, key string, localPath string) error
- func (s *LocalObjectStore) Put(ctx context.Context, localPath string, key string) error
- func (s *LocalObjectStore) Size(ctx context.Context, key string) (int64, error)
- type LogBuffer
- type LogRecord
- type ObjectStore
- type OutputMsg
- type OutputWriter
- type ParserFunc
- type RedisClient
- func (r *RedisClient) Keys(ctx context.Context, pattern string) ([]string, error)
- func (r *RedisClient) LRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (r *RedisClient) PSubscribe(ctx context.Context, channels ...string) (<-chan *redis.Message, <-chan error, func())
- 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
- type RunCClient
- func (c *RunCClient) Archive(ctx context.Context, containerId, imageId string, outputChan chan OutputMsg) error
- func (c *RunCClient) Close() error
- func (c *RunCClient) Exec(containerId, cmd string) (*pb.RunCExecResponse, error)
- func (c *RunCClient) Kill(containerId string) (*pb.RunCKillResponse, error)
- func (c *RunCClient) Status(containerId string) (*pb.RunCStatusResponse, error)
- func (c *RunCClient) StreamLogs(ctx context.Context, containerId string, outputChan chan OutputMsg) error
- type S3Store
- type SafeMap
- type Tracer
- type ZerologIOWriter
Constants ¶
const ( KeyOperationHSet string = "hset" KeyOperationSet string = "set" KeyOperationDel string = "del" KeyOperationExpire string = "expire" KeyOperationExpired string = "expired" )
const ( S3ImageRegistryStore = "s3" LocalImageRegistryStore = "local" )
const ( InvokeUrlTypePath string = "path" InvokeUrlTypeHost string = "host" )
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 RedisKeys = &redisKeys{}
Functions ¶
func AuthInterceptor ¶
func AuthInterceptor(token string) grpc.UnaryClientInterceptor
func BuildDeploymentURL ¶
func BuildDeploymentURL(externalUrl, urlType string, stub *types.StubWithRelated, deployment *types.Deployment) string
func BuildServeURL ¶
func BuildServeURL(externalUrl, urlType string, stub *types.StubWithRelated) string
func CopyStruct ¶
func DecryptAllSecrets ¶
DecryptAllSecrets decrypts all the given secrets in the order they are given.
func ExtractObjectFile ¶
func GenerateObjectId ¶
This simulates Mongo's object ID function which utilizes a 4-byte encoded timestamp value in the beginning of the id Used to even further reduce any chance of collision across distributed containers
func GetAWSConfig ¶
func GetConfigParser ¶
func GetConfigParser(format ConfigFormat) (koanf.Parser, error)
func GetTimeoutContext ¶
func MergeContexts ¶
func NewChannelSlogger ¶
func ParseSigningKey ¶
func SetupTelemetry ¶
func SetupTelemetry(ctx context.Context, serviceName string, appConfig types.AppConfig) (shutdown func(context.Context) error, err error)
SetupTelemetry bootstraps the OpenTelemetry pipeline
func ToSlice ¶
func ToSlice(v interface{}) []interface{}
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 ¶
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 WithClientName ¶
func WithClientName(name string) func(*redis.UniversalOptions)
Types ¶
type ChannelHandler ¶
type ChannelHandler struct {
// contains filtered or unexported fields
}
ChannelHandler implements slog.Handler to send logs to a channel
func NewChannelHandler ¶
func NewChannelHandler(logChan chan LogRecord) *ChannelHandler
NewChannelHandler creates a new handler that sends logs to the provided channel
type ConfigFormat ¶
type ConfigFormat string
var ( JSONConfigFormat ConfigFormat = ".json" YAMLConfigFormat ConfigFormat = ".yaml" YMLConfigFormat ConfigFormat = ".yml" )
type ConfigLoaderFunc ¶
type ConfigLoaderFunc func(k *koanf.Koanf) error
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/beta9.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
}
func NewContainerOverlay ¶
func NewContainerOverlay(containerId string, rootPath string, overlayPath string) *ContainerOverlay
func (*ContainerOverlay) AddEmptyLayer ¶
func (co *ContainerOverlay) AddEmptyLayer() error
func (*ContainerOverlay) AddLayer ¶
func (co *ContainerOverlay) AddLayer(upperDir string) error
func (*ContainerOverlay) Cleanup ¶
func (co *ContainerOverlay) Cleanup() error
func (*ContainerOverlay) Setup ¶
func (co *ContainerOverlay) Setup() error
func (*ContainerOverlay) TopLayerPath ¶
func (co *ContainerOverlay) TopLayerPath() string
type ContainerOverlayLayer ¶
type ContainerOverlayLayer struct {
// contains filtered or unexported fields
}
type EventBus ¶
type EventBus struct { EventCallbacks map[string]func(*Event) bool Subscribers []EventBusSubscriber // contains filtered or unexported fields }
func NewEventBus ¶
func NewEventBus(rdb *RedisClient, subscribers ...EventBusSubscriber) *EventBus
Create a new event bus
func (*EventBus) ReceiveEvents ¶
Receive all subscribed events (blocking)
type EventBusSubscriber ¶
type ImageRegistry ¶
type ImageRegistry struct { ImageFileExtension string // contains filtered or unexported fields }
func NewImageRegistry ¶
func NewImageRegistry(config types.ImageServiceConfig) (*ImageRegistry, error)
func (*ImageRegistry) Exists ¶
func (r *ImageRegistry) Exists(ctx context.Context, imageId string) bool
type KeyEventManager ¶
type KeyEventManager struct {
// contains filtered or unexported fields
}
func NewKeyEventManager ¶
func NewKeyEventManager(rdb *RedisClient) (*KeyEventManager, error)
func (*KeyEventManager) ListenForPattern ¶
type LocalObjectStore ¶
type LocalObjectStore struct {
Path string
}
func NewLocalObjectStore ¶
func NewLocalObjectStore() (*LocalObjectStore, error)
func (*LocalObjectStore) Exists ¶
func (s *LocalObjectStore) Exists(ctx context.Context, key string) bool
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
func NewLogBuffer ¶
func NewLogBuffer() *LogBuffer
type ObjectStore ¶
type OutputWriter ¶
type OutputWriter struct {
// contains filtered or unexported fields
}
func NewOutputWriter ¶
func NewOutputWriter(outputCallback func(string)) *OutputWriter
type ParserFunc ¶
type ParserFunc func() (koanf.Parser, error)
type RedisClient ¶
type RedisClient struct {
redis.UniversalClient
}
func NewRedisClient ¶
func NewRedisClient(config types.RedisConfig, options ...func(*redis.UniversalOptions)) (*RedisClient, error)
func (*RedisClient) Keys ¶
Gets all keys using a pattern Actually runs a scan since keys locks up the database.
func (*RedisClient) PSubscribe ¶
func (r *RedisClient) PSubscribe(ctx context.Context, channels ...string) (<-chan *redis.Message, <-chan error, func())
func (*RedisClient) Publish ¶
func (r *RedisClient) Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd
func (*RedisClient) Subscribe ¶
func (r *RedisClient) Subscribe(ctx context.Context, channels ...string) (<-chan *redis.Message, <-chan error)
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)
type RedisLockOptions ¶
type RunCClient ¶
type RunCClient struct { ServiceUrl string ServiceToken string // contains filtered or unexported fields }
func NewRunCClient ¶
func NewRunCClient(serviceUrl, serviceToken string, existingConn net.Conn) (*RunCClient, error)
func (*RunCClient) Close ¶
func (c *RunCClient) Close() error
func (*RunCClient) Exec ¶
func (c *RunCClient) Exec(containerId, cmd string) (*pb.RunCExecResponse, error)
func (*RunCClient) Kill ¶
func (c *RunCClient) Kill(containerId string) (*pb.RunCKillResponse, error)
func (*RunCClient) Status ¶
func (c *RunCClient) Status(containerId string) (*pb.RunCStatusResponse, error)
func (*RunCClient) StreamLogs ¶
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
func NewS3Store ¶
func NewS3Store(config types.S3ImageRegistryConfig) (*S3Store, error)
type SafeMap ¶
type SafeMap[V any] struct { // contains filtered or unexported fields }
func NewSafeMap ¶
NewSafeMap initializes a new SafeMap with the specified value type.
type Tracer ¶
type Tracer struct { Ctx context.Context Span _trace.Span // contains filtered or unexported fields }