infrastructures

package
v0.0.0-...-e10a309 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPCall

type HTTPCall struct {
	Conf *resources.SectionHTTP
	// contains filtered or unexported fields
}

func NewHTTPCall

func NewHTTPCall(conf *resources.SectionHTTP) *HTTPCall

NewHTTPCall init HTTPCall

func (*HTTPCall) CallService

func (h *HTTPCall) CallService(method, url string, requestBody []byte) (string, *resources.ApplicationError)

CallService is a function to call another service

func (*HTTPCall) CallServiceByte

func (h *HTTPCall) CallServiceByte(method, url string, requestBody []byte) ([]byte, *resources.ApplicationError)

CallServiceByte is a function to call another service return byte data

type PanicHandlerController

type PanicHandlerController struct {
	Slack       interfaces.ISlackWebhook
	SlackConfig *SlackWebhook
	Logger      interfaces.ILogger
}

func (*PanicHandlerController) GetPanicAndSendToSlack

func (pc *PanicHandlerController) GetPanicAndSendToSlack(c *gin.Context, serviceName, message string) error

func (*PanicHandlerController) SetPanicResp

func (pc *PanicHandlerController) SetPanicResp(c *gin.Context, serviceName, message string) *resources.PanicHandlerResponse

func (*PanicHandlerController) SetPayloadSlack

func (pc *PanicHandlerController) SetPayloadSlack(resp *resources.PanicHandlerResponse) slack.Payload

type PostgreSQLHandler

type PostgreSQLHandler struct {
	DBRead  *sqlx.DB
	DBWrite *sqlx.DB
	Tx      *sqlx.Tx
}

Database struct

func (*PostgreSQLHandler) Begin

func (d *PostgreSQLHandler) Begin() (interfaces.IDBTx, error)

func (*PostgreSQLHandler) BeginTx

func (d *PostgreSQLHandler) BeginTx() (*sqlx.Tx, error)

func (*PostgreSQLHandler) Close

func (d *PostgreSQLHandler) Close()

func (*PostgreSQLHandler) Commit

func (d *PostgreSQLHandler) Commit() error

func (*PostgreSQLHandler) ConnectDB

func (d *PostgreSQLHandler) ConnectDB(
	dbAccRead *resources.DBAccount,
	dbAccWrite *resources.DBAccount,
)

func (*PostgreSQLHandler) DriverName

func (d *PostgreSQLHandler) DriverName() string

func (*PostgreSQLHandler) Exec

func (d *PostgreSQLHandler) Exec(query string, args ...interface{}) (sql.Result, error)

func (*PostgreSQLHandler) ExecContext

func (d *PostgreSQLHandler) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*PostgreSQLHandler) Get

func (d *PostgreSQLHandler) Get(dest interface{}, query string, args ...interface{}) error

func (*PostgreSQLHandler) GetContext

func (d *PostgreSQLHandler) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*PostgreSQLHandler) In

func (d *PostgreSQLHandler) In(query string, params ...interface{}) (string, []interface{}, error)

func (*PostgreSQLHandler) Query

func (d *PostgreSQLHandler) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*PostgreSQLHandler) QueryContext

func (d *PostgreSQLHandler) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (*PostgreSQLHandler) QueryRow

func (d *PostgreSQLHandler) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow executes a query that is expected to return at most one row. QueryRow always returns a non-nil value. Errors are deferred until Row's Scan method is called. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest.

func (*PostgreSQLHandler) QueryRowSqlx

func (d *PostgreSQLHandler) QueryRowSqlx(query string, args ...interface{}) *sqlx.Row

func (*PostgreSQLHandler) Queryx

func (d *PostgreSQLHandler) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)

func (*PostgreSQLHandler) Rebind

func (d *PostgreSQLHandler) Rebind(query string) string

func (*PostgreSQLHandler) Rollback

func (d *PostgreSQLHandler) Rollback() error

func (*PostgreSQLHandler) Select

func (d *PostgreSQLHandler) Select(dest interface{}, query string, args ...interface{}) error

func (*PostgreSQLHandler) TransactionBlock

func (d *PostgreSQLHandler) TransactionBlock(tx *sqlx.Tx, fc func(tx *sqlx.Tx) error) error

type RedisHandler

type RedisHandler struct {
	Client      *redis.Client
	Pipe        redis.Pipeliner
	PipeCounter int
	RH          *rejson.Handler
	RS          map[string]*redisearch.Client
	Pool        *redigo.Pool
	Redisync    *redsync.Redsync
}

RedisHandler is a struct for save redis Client and a receiver

func (*RedisHandler) Close

func (r *RedisHandler) Close()

Close redis connection

func (*RedisHandler) ConnectRedis

func (r *RedisHandler) ConnectRedis(ra *resources.RedisAccount)

ConnectRedis make redis connection

func (*RedisHandler) CreateRedisMutex

func (r *RedisHandler) CreateRedisMutex(key string, options ...redsync.Option) *redsync.Mutex

func (*RedisHandler) CreateRedisync

func (r *RedisHandler) CreateRedisync() *redsync.Redsync

func (*RedisHandler) Del

func (r *RedisHandler) Del(keys ...string) error

Del data in redis from keys (one, or more than one key)

func (*RedisHandler) Get

func (r *RedisHandler) Get(key string) (string, error)

Get data

func (*RedisHandler) GetSet

func (r *RedisHandler) GetSet(key string, data interface{}) error

GetSet get and insert data to redis

func (*RedisHandler) HDel

func (r *RedisHandler) HDel(key string, fields ...string) error

func (*RedisHandler) HGetAll

func (r *RedisHandler) HGetAll(key string) (map[string]string, error)

HGetAll get hash redis data all fields

func (*RedisHandler) HMGet

func (r *RedisHandler) HMGet(key string, fields ...string) ([]interface{}, error)

HMGet get hash data from redis

func (*RedisHandler) HMSet

func (r *RedisHandler) HMSet(key string, data interface{}) error

HMSet insert hash data to redis type hash

func (*RedisHandler) HMSetEx

func (r *RedisHandler) HMSetEx(key string, parameter resources.SetExParameter) error

HMSet insert hash data to redis type hash with Expiration (TTL)

func (*RedisHandler) JSONDel

func (r *RedisHandler) JSONDel(key, path string) (interface{}, error)

func (*RedisHandler) JSONGet

func (r *RedisHandler) JSONGet(key string) (interface{}, error)

func (*RedisHandler) JSONMGet

func (r *RedisHandler) JSONMGet(path string, keys ...string) (interface{}, error)

func (*RedisHandler) JSONSet

func (r *RedisHandler) JSONSet(key string, data interface{}) (interface{}, error)

func (*RedisHandler) Keys

func (r *RedisHandler) Keys(pattern string) ([]string, error)

Get data with pattern note : avoid pattern '*' for keys lookup. Consider adding prefix and/or suffix on the pattern.

func (*RedisHandler) LLen

func (r *RedisHandler) LLen(key string) (int64, error)

LLen func to get total list

func (*RedisHandler) LPush

func (r *RedisHandler) LPush(key string, value ...interface{}) error

LPush func to push into list

func (*RedisHandler) LRange

func (r *RedisHandler) LRange(key string, start int64, stop int64) ([]string, error)

LRange func to get value from list by range

func (*RedisHandler) LockRedisMutex

func (r *RedisHandler) LockRedisMutex(mutex *redsync.Mutex, tries int) error

func (*RedisHandler) Pipeline

func (r *RedisHandler) Pipeline()

func (*RedisHandler) SAdd

func (r *RedisHandler) SAdd(key string, data ...interface{}) error

SAdd add members to a set stored in redis to a key. if key not exists, will create new and add member

func (*RedisHandler) SIsMember

func (r *RedisHandler) SIsMember(key string, data interface{}) (bool, error)

SIsMember will return true if data is member of set stored at a key or false if data is not member of set stored at a key

func (*RedisHandler) SPop

func (r *RedisHandler) SPop(key string) (string, error)

func (*RedisHandler) Scan

func (r *RedisHandler) Scan(key string) ([]string, error)

Scan accept wildcard for searching ex : users*

func (*RedisHandler) Set

func (r *RedisHandler) Set(key string, data interface{}) error

Set insert data to redis in string type

func (*RedisHandler) SetEx

func (r *RedisHandler) SetEx(key string, parameter resources.SetExParameter) error

SetEx insert data to old redis in string type with Expiration (TTL)

func (*RedisHandler) XDel

func (r *RedisHandler) XDel(stream string, ids ...string) error

type Slack

type Slack struct {
	SlackClient *slack.Client
}

func NewSlackClient

func NewSlackClient(token string) *Slack

func (*Slack) New

func (s *Slack) New(token string, option ...slack.Option) *slack.Client

func (*Slack) SendSlack

func (s *Slack) SendSlack(channelID string, options ...slack.MsgOption) (string, string, error)

func (*Slack) UploadFile

func (s *Slack) UploadFile(params slack.FileUploadParameters) (file *slack.File, err error)

type SlackWebhook

type SlackWebhook struct {
	SlackWebhookEnv     string
	SlackWebhookURL     string
	SlackWebhookChannel string

	SlackToken          string
	SlackUploadFilePath string
}

func NewSlackWebhook

func NewSlackWebhook(opts ...SlackWebhookFuncOption) *SlackWebhook

func (*SlackWebhook) Assign

func (sw *SlackWebhook) Assign(opts ...SlackWebhookFuncOption) *SlackWebhook

func (*SlackWebhook) Send

func (s *SlackWebhook) Send(webhookURL, proxy string, payload slack.Payload) []error

sending report image and text Send ...

func (*SlackWebhook) SendWebhook

func (sw *SlackWebhook) SendWebhook(ctx context.Context, payload slackAPI.WebhookMessage) (err error)

type SlackWebhookFuncOption

type SlackWebhookFuncOption func(*SlackWebhook)

func WithWebhook

func WithWebhook(url string, channel string) SlackWebhookFuncOption

type SqlxTx

type SqlxTx struct {
	Tx *sqlx.Tx
}

SqlxTx is a wrapper struct for sqlx Tx

func (*SqlxTx) Commit

func (d *SqlxTx) Commit()

func (*SqlxTx) Rollback

func (d *SqlxTx) Rollback()

Jump to

Keyboard shortcuts

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