Documentation ¶
Index ¶
- type AppEnv
- type Box
- type Conf
- type Conv
- type ConvTime
- type Crypto
- type Db
- type DbInstance
- type DbPostgresInstance
- type DbTx
- type GM
- type Http
- type HttpBuilder
- type HttpResponse
- type Json
- type Lock
- type LockInstance
- type LockOpt
- type Net
- type Test
- type Use
- type UseGcs
- type Util
- type UtilEnv
- type UtilEnvBase64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conf ¶
type Conf interface { SetZxEnvName(name string) Conf SetTimezone(timezone string) Conf SetClogAddress(address string, svcName string, svcVersion string) Conf SetClogRetryMaxDuration(duration time.Duration) Conf SetInternalBaseUrls(urls []string) Conf // address "-" means no engine, so all the feature will success every time, used when on development SetTxLockEngine(address string, dvalTimeout time.Duration, dvalTryFor *time.Duration) Conf Commit() }
type Crypto ¶
type Crypto interface { AesEcbEncrypt(key, value string) (string, error) AesEcbRawEncrypt(key, value string) ([]byte, error) AesEcbDecrypt(key, value string) (string, error) AesEcbRawDecrypt(key string, value []byte) ([]byte, error) Md5(val string) string Sha256(val string) string Sha512(val string) string }
type Db ¶
type Db interface { Postgres(conf mol.DbConnection) DbPostgresInstance PostgresRW(readConf mol.DbConnection, writeConf mol.DbConnection) DbPostgresInstance }
type DbInstance ¶
type DbInstance interface { Ping() (string, error) PingRead() (string, error) NewTransaction() (DbTx, error) Select(out any, usingRW bool, query string, args ...any) (*mol.DbExecReport, error) SelectR2(out any, query string, args []any, check *func() bool) (*mol.DbExecReport, error) Execute(query string, args ...any) (*mol.DbExecReport, error) ExecuteRID(query string, args ...any) (*int64, *mol.DbExecReport, error) TxSelect(tx DbTx, out any, query string, args ...any) (*mol.DbExecReport, error) TxExecute(tx DbTx, query string, args ...any) (*mol.DbExecReport, error) TxExecuteRID(tx DbTx, query string, args ...any) (*int64, *mol.DbExecReport, error) }
type DbPostgresInstance ¶
type DbPostgresInstance interface { DbInstance }
type GM ¶
type GM interface { SetBox(box Box) GM SetConf(conf Conf) GM SetConv(conv Conv, tm ConvTime) GM SetCrypto(crypto Crypto) GM SetDb(db Db) GM SetHttp(http Http) GM SetJson(json Json) GM SetLock(lock Lock) GM SetNet(net Net) GM SetTest(test Test) GM SetUse(use Use, useGcs UseGcs) GM SetUtil(util Util, env UtilEnv) GM }
type Http ¶
type Http interface { Get(clog clog.Instance, url string) HttpBuilder Post(clog clog.Instance, url string) HttpBuilder Put(clog clog.Instance, url string) HttpBuilder Patch(clog clog.Instance, url string) HttpBuilder Delete(clog clog.Instance, url string) HttpBuilder }
type HttpBuilder ¶
type HttpBuilder interface { SetTimeout(duration time.Duration) HttpBuilder // disable security check (https) InsecureSkipVerify(skip ...bool) HttpBuilder // Example: // SetRetryCondition(func(resp ice.HttpResponse) bool { // return resp.Code() == http.StatusTooManyRequests // }) SetRetryCondition(condition func(resp HttpResponse, count int) bool) HttpBuilder SetMaxRetry(max int) HttpBuilder EnableTrace(enable ...bool) HttpBuilder SetHeader(args map[string]string) HttpBuilder // Example: // SetJsonHeader("1.0", map[string]string{ // "Authorization": "Bearer xyz", // }) // string "1.0" it will convert to "X-Version", // then map[string]string will added to header value SetJsonHeader(opt ...any) HttpBuilder // Examples: // // Get(".../users/{userId}/{subAccountId}/details"). // SetPathParams(map[string]any{ // "userId": "sample@sample.com", // "subAccountId": "100002", // }) SetPathParam(args map[string]string) HttpBuilder SetQueryParam(args map[string]string) HttpBuilder SetFormData(args map[string]string) HttpBuilder // Examples: // // SetBody(User{ // Username: "jeeva@myjeeva.com", // Password: "welcome2resty", // }) // // SetBody(map[string]any{ // "username": "jeeva@myjeeva.com", // "password": "welcome2resty", // "address": &Address{ // City: "My City", // ZipCode: 00000, // }, // }) // // SetBody(`{ // "username": "jeeva@getrightcare.com", // "password": "admin" // }`) // // SetBody([]byte("This is my raw request, sent as-is")) // SetBody(value any) HttpBuilder // Examples: // profileImgBytes, _ := os.ReadFile("/andy/test-img.png") // notesBytes, _ := os.ReadFile("/andy/text-file.txt") // // AddFileReader("profile_img", "my-profile-img.png", bytes.NewReader(profileImgBytes)). // AddFileReader("notes", "user-notes.txt", bytes.NewReader(notesBytes)) AddFileReader(param, fileName string, reader io.Reader) HttpBuilder // Examples: // // SetFiles(map[string]string{ // "file1": "/andy/invoice.pdf", // "file2": "/andy/detail.pdf", // "file3": "/andy/summary.pdf", // }) SetFiles(files map[string]string) HttpBuilder Call() (data []byte, code int, err error) }
type HttpResponse ¶
type Lock ¶ added in v1.0.2
type Lock interface { NewOpt() LockOpt // code // -1: // 0: have an error // 1: locked Tx(id string, opt ...LockOpt) (LockInstance, error) }
type LockInstance ¶ added in v1.0.2
type UseGcs ¶ added in v1.0.26
type UseGcs interface { Init(credential UtilEnvBase64, bucketName string) error Write(filePath string, reader io.Reader) error WriteData(filePath string, data []byte) error WriteReqFile(parts *map[string][]*multipart.FileHeader, key string, dirPath string, overrideFileName string) (fileName string, fileExt string, err error) }
type Util ¶
type Util interface { IsEmailValid(email string, verifyDomain ...bool) bool Timenow(timezone ...string) time.Time ConcurrentProcess(total, max int, fn func(index int)) LiteUID() string UID(addition ...int) string GetAlphabet(isUpper ...bool) string GetNumeric() string GetRandom(length int, value string) string DecodeUID(uid string, addition ...int) (rawId string, randId string, err error) ReplaceAll(value *string, replaceValue string, replaceKey ...string) *string ReadTextFile(filePath string) ([]string, error) LoadEnv(filePath ...string) error GetExecDir() (string, error) GetExecPathFunc(skip ...int) (string, string) SingleExec(fn func()) PanicCatcher(fn func()) (err error) ReflectionGet(obj any, fieldName string) (any, error) ReflectionSet(obj any, bind map[string]any) error StackTrace(skip ...int) string IsAllowedIp(clientIp string, allowedIps ...string) bool }
type UtilEnv ¶
type UtilEnv interface { GetAppEnv(key string) AppEnv GetString(key string, dval ...string) string GetInt(key string, dval ...int) int GetInt32(key string, dval ...int32) int32 GetInt64(key string, dval ...int64) int64 GetFloat32(key string, dval ...float32) float32 GetFloat64(key string, dval ...float64) float64 GetFCT(key string, dval ...fct.FCT) fct.FCT GetBool(key string, dval ...bool) bool GetStringSlice(key string, separator string, dval ...[]string) []string GetDurationMs(key string, dval ...time.Duration) time.Duration GetBase64(key string) UtilEnvBase64 }
type UtilEnvBase64 ¶ added in v1.0.20
Click to show internal directories.
Click to hide internal directories.