base

package
v0.0.0-...-1b9946f Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLog *zap.Logger
View Source
var ErrNoPlaylistID = errors.New("url query is missing playlist id")
View Source
var ErrNoVideoID = errors.New("url query is missing video id")
View Source
var Unreachable string = "unreachable branch detected"

Functions

func AWSConfigFromEnv

func AWSConfigFromEnv() *aws.Config

func AWSSession

func AWSSession() *session.Session

func AddCognitoFlags

func AddCognitoFlags(cmd *cobra.Command, o *CognitoOptions)

func AddDatabaseFlags

func AddDatabaseFlags(cmd *cobra.Command, o *DatabaseOptions)

func AddIAMFlags

func AddIAMFlags(cmd *cobra.Command, o *IAMOptions)

func AddKeyCloakFlags

func AddKeyCloakFlags(cmd *cobra.Command, o *KeyCloakOptions)

func AddMongoFlags

func AddMongoFlags(cmd *cobra.Command, o *MongoOptions)

func AddPostgresFlags

func AddPostgresFlags(cmd *cobra.Command, out *PostgresOptions)

func AddRedisFlags

func AddRedisFlags(cmd *cobra.Command, o *RedisOptions)

func AddServerFlags

func AddServerFlags(cmd *cobra.Command, out *ServerOptions)

func AddServiceFlags

func AddServiceFlags(
	cmd *cobra.Command,
	name string,
	out *ServiceOptions,
	defaultTimeout time.Duration,
)

func CheckEnv

func CheckEnv(name string, target *string) string

func CheckEnvBool

func CheckEnvBool(name string, target *bool) bool

func CheckEnvInt

func CheckEnvInt(name string, target *int) int

func CheckEnvInt64

func CheckEnvInt64(name string, target *int64) int64

func ConnectMongo

func ConnectMongo(o *MongoOptions) *mongo.Database

func ConnectPostgres

func ConnectPostgres(o *PostgresOptions) *sql.DB

func ConnectRedis

func ConnectRedis(o *RedisOptions) *redis.Client

func Contains

func Contains(arr []string, v string) bool

func Elapsed

func Elapsed(since time.Time) zap.Field

func ExtractChannelID

func ExtractChannelID(input string) (string, error)

func ExtractPlaylistID

func ExtractPlaylistID(input string) (string, error)

func ExtractVideoID

func ExtractVideoID(input string) (string, error)

func HealthHandler

func HealthHandler(w http.ResponseWriter, r *http.Request)

func IAMEnv

func IAMEnv(o *IAMOptions, required bool)

func InvalidMethod

func InvalidMethod(method string) error

func Lerp

func Lerp(a float64, b float64, f float64) float64

func MapContainsAll

func MapContainsAll(p map[string]interface{}, keys ...string) bool

func MapContainsAny

func MapContainsAny(p map[string]interface{}, keys ...string) bool

func Progress

func Progress(ctx context.Context, onProgress chan<- struct{})

func ProgressDownload

func ProgressDownload(
	ctx context.Context,
	onProgress chan<- *DownloadProgress,
)

func RandomizeSeed

func RandomizeSeed()

func ReadyHandler

func ReadyHandler(w http.ResponseWriter, r *http.Request)

func RunMetrics

func RunMetrics(port int, log *zap.Logger)

func SetLogLevel

func SetLogLevel()

func SignalReady

func SignalReady(log *zap.Logger)

func WaitForService

func WaitForService(opts *ServiceOptions)

func WaitForServices

func WaitForServices(opts []*ServiceOptions)

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

type CognitoOptions

type CognitoOptions struct {
	UserPoolID               string
	ClientID                 string
	ClientSecret             string
	AllowTokenUseBeforeIssue bool
}

func CognitoEnv

func CognitoEnv(o *CognitoOptions, required bool) *CognitoOptions

func (*CognitoOptions) Ensure

func (o *CognitoOptions) Ensure()

func (*CognitoOptions) IsSet

func (o *CognitoOptions) IsSet() bool

type DatabaseDriver

type DatabaseDriver string
var (
	MongoDriver    DatabaseDriver = "mongo"
	PostgresDriver DatabaseDriver = "postgres"
)

func (DatabaseDriver) IsValid

func (d DatabaseDriver) IsValid() bool

type DatabaseOptions

type DatabaseOptions struct {
	Driver   DatabaseDriver
	Mongo    MongoOptions
	Postgres PostgresOptions
}

func DatabaseEnv

func DatabaseEnv(o *DatabaseOptions, required bool) *DatabaseOptions

func (*DatabaseOptions) IsSet

func (o *DatabaseOptions) IsSet() bool

type DownloadProgress

type DownloadProgress struct {
	Total   int64         // bytes
	Rate    float64       // bytes per second
	Elapsed time.Duration //
}

type IAMDriver

type IAMDriver string
var (
	CognitoDriver  IAMDriver = "cognito"
	KeyCloakDriver IAMDriver = "keycloak"
)

type IAMOptions

type IAMOptions struct {
	Driver   IAMDriver
	KeyCloak KeyCloakOptions
	Cognito  CognitoOptions
}

type KeyCloak

type KeyCloak struct {
	*gocloak.GoCloak
	KeyCloakOptions
	Token *gocloak.JWT
	// contains filtered or unexported fields
}

func ConnectKeyCloak

func ConnectKeyCloak(o *KeyCloakOptions) *KeyCloak

func (*KeyCloak) GetAccessToken

func (k *KeyCloak) GetAccessToken(ctx context.Context) (string, error)

type KeyCloakAdminOptions

type KeyCloakAdminOptions struct {
	BasicAuth
	Realm string
}

type KeyCloakOptions

type KeyCloakOptions struct {
	Endpoint     string
	Admin        KeyCloakAdminOptions
	ClientID     string
	ClientSecret string
	Realm        string
}

func KeyCloakEnv

func KeyCloakEnv(o *KeyCloakOptions, required bool) *KeyCloakOptions

func (*KeyCloakOptions) Ensure

func (o *KeyCloakOptions) Ensure()

func (*KeyCloakOptions) IsSet

func (o *KeyCloakOptions) IsSet() bool

type MongoOptions

type MongoOptions struct {
	DBName     string `json:"dbName"`
	Host       string `json:"host"`
	AuthSource string `json:"authSource"`
	Username   string `json:"username"`
	Password   string `json:"password"`
}

func MongoEnv

func MongoEnv(o *MongoOptions, required bool) *MongoOptions

func (*MongoOptions) Ensure

func (o *MongoOptions) Ensure()

func (*MongoOptions) IsSet

func (o *MongoOptions) IsSet() bool

type PostgresOptions

type PostgresOptions struct {
	Host       string
	Port       int
	Username   string
	Password   string
	Database   string
	SSLMode    string
	SSLKeyPath string
}

func PostgresEnv

func PostgresEnv(o *PostgresOptions, required bool) *PostgresOptions

func (*PostgresOptions) Ensure

func (o *PostgresOptions) Ensure()

func (*PostgresOptions) IsSet

func (p *PostgresOptions) IsSet() bool

type RedisOptions

type RedisOptions struct {
	Username string
	Password string
	Host     string
	Port     int
	URL      string
}

func RedisEnv

func RedisEnv(o *RedisOptions, required bool) *RedisOptions

func (*RedisOptions) ConnectionString

func (o *RedisOptions) ConnectionString() string

func (*RedisOptions) IsSet

func (o *RedisOptions) IsSet() bool

type ServerOptions

type ServerOptions struct {
	Port        int
	MetricsPort int
}

func ServerEnv

func ServerEnv(o *ServerOptions) *ServerOptions

type ServiceOptions

type ServiceOptions struct {
	Endpoint  string
	Timeout   time.Duration
	BasicAuth BasicAuth
}

func ServiceEnv

func ServiceEnv(name string, o *ServiceOptions) *ServiceOptions

func (*ServiceOptions) HasBasicAuth

func (o *ServiceOptions) HasBasicAuth() bool

func (*ServiceOptions) HasTimeout

func (o *ServiceOptions) HasTimeout() bool

func (*ServiceOptions) WithBasicAuth

func (o *ServiceOptions) WithBasicAuth(username, password string) *ServiceOptions

func (*ServiceOptions) WithTimeout

func (o *ServiceOptions) WithTimeout(timeout time.Duration) *ServiceOptions

Jump to

Keyboard shortcuts

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