interfaces

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IContext

type IContext interface {
}

IContext for setup context with value interface

type IDBTx

type IDBTx interface {
	Rollback()
	Commit()
}

type IDatabase

type IDatabase interface {
	ConnectDB(dbAccRead *resources.DBAccount, dbAccWrite *resources.DBAccount)
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Get(dest interface{}, query string, args ...interface{}) error
	DriverName() string
	Close()
	Begin() (IDBTx, error)
	In(query string, params ...interface{}) (string, []interface{}, error)
	Rebind(query string) string
	Select(dest interface{}, query string, args ...interface{}) error
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

	// DB transaction.
	IDatabaseTx
	Commit() error
	Rollback() error

	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
	QueryRowSqlx(query string, args ...interface{}) *sqlx.Row
}

IDatabase is interface for database

type IDatabaseTx

type IDatabaseTx interface {
	BeginTx() (*sqlx.Tx, error)
	TransactionBlock(tx *sqlx.Tx, fc func(tx *sqlx.Tx) error) error
}

IDatabaseTx is interface for only transaction database

type IElasticsearch

type IElasticsearch interface {
	IndexDocument(indexName string, documentID int64, document string) error
	Get(indexName string, documentID int64) (string, error)
}

type IHTTP

type IHTTP interface {
	CallService(method, url string, requestBody []byte) (string, *resources.ApplicationError)
	CallServiceByte(method, url string, requestBody []byte) ([]byte, *resources.ApplicationError)
}

IHTTP is the general interface for HTTP Call

type ILogger

type ILogger interface {
	LogInfo(payload string)
	Close()
}

type IPanicHandler

type IPanicHandler interface {
	SetPanicResp(c *gin.Context, serviceName, message string) *resources.PanicHandlerResponse
	SetPayloadSlack(resp *resources.PanicHandlerResponse) slack.Payload
	GetPanicAndSendToSlack(c *gin.Context, serviceName, message string) error
}

IPanicHandler is a interface for panic handler

type IRedis

type IRedis interface {
	ConnectRedis(ra *resources.RedisAccount)
	Get(key string) (string, error)
	Keys(pattern string) ([]string, error)
	HGetAll(key string) (map[string]string, error)
	Set(key string, data interface{}) error
	SetEx(key string, parameter resources.SetExParameter) error
	HMSet(key string, data interface{}) error
	HMSetEx(key string, parameter resources.SetExParameter) error
	GetSet(key string, data interface{}) error
	HMGet(key string, fields ...string) ([]interface{}, error)
	Close()
	Scan(key string) ([]string, error)
	Del(keys ...string) error
	HDel(key string, fields ...string) error
	XDel(stream string, ids ...string) error
	LLen(key string) (int64, error)
	LRange(key string, start int64, stop int64) ([]string, error)
	LPush(key string, value ...interface{}) error
	SPop(key string) (string, error)
	SAdd(key string, data ...interface{}) error
	SIsMember(key string, data interface{}) (bool, error)
	Pipeline()
	JSONSet(key string, data interface{}) (interface{}, error)
	JSONGet(key string) (interface{}, error)
	JSONMGet(path string, keys ...string) (interface{}, error)
	JSONDel(key, path string) (interface{}, error)
	CreateRedisync() *redsync.Redsync
	CreateRedisMutex(key string, options ...redsync.Option) *redsync.Mutex
	LockRedisMutex(mutex *redsync.Mutex, tries int) error
}

IRedis is the general interface for redis commands usage

type IRouter

type IRouter interface {
	Routing(config *resources.AppConfig, dbObj map[string]IDatabase, redisdb map[string]IRedis) *gin.Engine
}

IRouter is interface for routing

type IRows

type IRows interface {
	MapScan(dest map[string]interface{}) error
	SliceScan() ([]interface{}, error)
	StructScan(dest interface{}) error
	Next() bool
}

type ISlack

type ISlack interface {
	New(token string, option ...slack.Option) *slack.Client
	UploadFile(params slack.FileUploadParameters) (file *slack.File, err error)
	// SendSlack ...
	SendSlack(channelID string, options ...slack.MsgOption) (string, string, error)
}

ISlack used for slack api interaction

type ISlackWebhook

type ISlackWebhook interface {
	SendWebhook(ctx context.Context, payload slackAPI.WebhookMessage) (err error)
	Send(webhookURL, proxy string, payload slack.Payload) []error
}

ISlackWebhook for sending slack webhook interface

type InterfaceKvotheRepository

type InterfaceKvotheRepository interface {
	GetSongQuoteByIDPostgres(id int64) (*models.SongQuote, error)

	GetAllSongQuotesPostgres() ([]models.SongQuote, error)
	UpsertSongQuoteRedis(sq models.SongQuote) error
}

type InterfaceKvotheService

type InterfaceKvotheService interface {
	GetSongQuoteByID(id int64) (*models.SongQuote, int, error)
	GetAllSongData() ([]models.SongQuote, int, error)
	BackfillRedis() error

	//mock data
	GetQuoteByIDMockData(rawID string) (string, error)
	AddNewQuoteMockData(q string) (string, error)

	GetPersonByIDMockData(rawID string) (string, error)
	AddNewPersonMockData(p string) (string, error)
}

Jump to

Keyboard shortcuts

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