kothak

package
v0.0.0-...-e31961d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

README

Kothak

Kothak is a resource holder. This library holds resource connection and object.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBConfig            DBConfig              `json:"database" yaml:"database" toml:"database"`
	RedisConfig         RedisConfig           `json:"redis" yaml:"redis" toml:"redis"`
	ObjectStorageConfig []ObjectStorageConfig `json:"object_storage" yaml:"object_storage" toml:"object_storage"`
}

Config of kothak

type DBConfig

type DBConfig struct {
	MaxRetry              int           `json:"max_retry" yaml:"max_retry" toml:"max_retry" default:"1"`
	MaxOpenConnections    int           `json:"max_open_conns" yaml:"max_open_conns" toml:"max_open_conns" default:"10"`
	MaxIdleConnections    int           `json:"max_idle_conns" yaml:"max_idle_conns" toml:"max_idle_conns" default:"2"`
	ConnectionMaxLifetime string        `json:"conn_max_lifetime" yaml:"conn_max_lifetime" toml:"conn_max_lifetime" default:"30s"`
	SQLDBs                []SQLDBConfig `json:"connect" yaml:"connect" toml:"connect"`
	// contains filtered or unexported fields
}

DBConfig define sql databases configuration

func (*DBConfig) SetDefault

func (dbconf *DBConfig) SetDefault() error

SetDefault configuration

type GCSConfig

type GCSConfig struct {
	ClientID     string `json:"client_id" yaml:"client_id" toml:"client_id"`
	ClientSecret string `json:"client_secret" yaml:"client_secret" toml:"client_secret"`
	JSONKey      string `json:"json_key" yaml:"json_key" toml:"json_key"`
}

GCSConfig for google cloud storage

type Kothak

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

Kothak struct

func New

func New(ctx context.Context, kothakConfig Config, logger logger.Logger) (*Kothak, error)

New kothak instance

func (*Kothak) CloseAll

func (k *Kothak) CloseAll() error

CloseAll to close all connected resources TODO: check error when closing connections and close connection concurrently

func (*Kothak) GetObjectStorage

func (k *Kothak) GetObjectStorage(objStorageName string) (*objectstorage.Storage, error)

GetObjectStorage from kothak object

func (*Kothak) GetRedis

func (k *Kothak) GetRedis(redisname string) (redis.Redis, error)

GetRedis from kothak object

func (*Kothak) GetSQLDB

func (k *Kothak) GetSQLDB(dbname string) (*sqldb.DB, error)

GetSQLDB from kothak object

func (*Kothak) MustGetObjectStorage

func (k *Kothak) MustGetObjectStorage(objStorageName string) *objectstorage.Storage

MustGetObjectStorage from kothak object

func (*Kothak) MustGetRedis

func (k *Kothak) MustGetRedis(redisname string) redis.Redis

MustGetRedis from kothak object

func (*Kothak) MustGetSQLDB

func (k *Kothak) MustGetSQLDB(dbname string) *sqldb.DB

MustGetSQLDB from kothak object

type ObjectStorageConfig

type ObjectStorageConfig struct {
	Name        string    `json:"name" yaml:"name" toml:"name"`
	Provider    string    `json:"provider" yaml:"provider" toml:"provider"`
	Region      string    `json:"region" yaml:"region" toml:"region"`
	Endpoint    string    `json:"endpoint" yaml:"endpoint" toml:"endpoint"`
	Bucket      string    `json:"bucket" yaml:"bucket" toml:"bucket"`
	BucketProto string    `json:"bucket_proto" yaml:"bucket_proto" toml:"bucket_proto"`
	BucketURL   string    `json:"bucket_url" yaml:"bucket_url" toml:"bucket_url"`
	S3          S3Config  `json:"s3" yaml:"s3" toml:"s3"`
	GCS         GCSConfig `json:"gcs" yaml:"gcs" toml:"gcs"`
}

ObjectStorageConfig struct

type Redis

type Redis interface {
}

Redis interface for infra

type RedisConfig

type RedisConfig struct {
	MaxIdle   int               `json:"max_idle_conn" yaml:"max_idle_conn" toml:"max_idle_conn"`
	MaxActive int               `json:"max_active_conn" yaml:"max_active_conn" toml:"max_active_conn"`
	Timeout   int               `json:"timeout" yaml:"timeout" toml:"timeout"`
	Rds       []RedisConnConfig `json:"connect" yaml:"connect" toml:"connect"`
}

RedisConfig of kothak

type RedisConnConfig

type RedisConnConfig struct {
	Name      string `json:"name" yaml:"name" toml:"name"`
	Address   string `json:"address" yaml:"address" toml:"address"`
	MaxIdle   int    `json:"max_idle_conn" yaml:"max_idle_conn" toml:"max_idle_conn"`
	MaxActive int    `json:"max_active_conn" yaml:"max_active_conn" toml:"max_active_conn"`
	Timeout   int    `json:"timeout" yaml:"timeout" toml:"timeout"`
}

RedisConnConfig struct

type S3Config

type S3Config struct {
	ClientID       string `json:"client_id" yaml:"client_id" toml:"client_id"`
	ClientSecret   string `json:"client_secret" yaml:"client_secret" toml:"client_secret"`
	DisableSSL     bool   `json:"disable_ssl" yaml:"disable_ssl" toml:"disable_ssl"`
	ForcePathStyle bool   `json:"force_path_style" yaml:"force_path_style" toml:"force_path_style"`
}

S3Config for s3 storage

type SQLDBConfig

type SQLDBConfig struct {
	Name              string                `yaml:"name" toml:"name"`
	Driver            string                `yaml:"driver" toml:"driver"`
	LeaderConnConfig  SQLDBConnectionConfig `yaml:"leader" toml:"leader"`
	ReplicaConnConfig SQLDBConnectionConfig `yaml:"replica" toml:"replica"`
}

SQLDBConfig of kothak

type SQLDBConnectionConfig

type SQLDBConnectionConfig struct {
	DSN                   string `json:"dsn" yaml:"dsn" toml:"dsn" protected:"1"`
	MaxOpenConnections    int    `json:"max_open_conns" yaml:"max_open_conns" toml:"max_open_conns"`
	MaxIdleConnections    int    `json:"max_idle_conns" yaml:"max_idle_conns" toml:"max_idle_conns"`
	ConnectionMaxLifetime string `json:"conn_max_lifetime" yaml:"conn_max_lifetime" toml:"conn_max_lifetime"`
	MaxRetry              int    `json:"max_retry" yaml:"max_retry" toml:"max_retry"`
	// contains filtered or unexported fields
}

SQLDBConnectionConfig struct

func (*SQLDBConnectionConfig) SetDefault

func (connConfig *SQLDBConnectionConfig) SetDefault(dbconfig DBConfig) error

SetDefault configuration

Jump to

Keyboard shortcuts

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