Documentation
¶
Index ¶
- type IAerospike
- type ICache
- type IClient
- type IClientBase
- type IClientGrpc
- type IClientResponse
- type IConfig
- type IController
- type ICookie
- type ICtx
- type IDatabase
- type IEngine
- type IHeader
- type ILogger
- type IMetrics
- type IMiddleware
- type IModules
- type IMongoDB
- type INoSql
- type IQuery
- type IRepository
- type IRequest
- type IResponse
- type IServer
- type IServerBase
- type IServerGRPC
- type IService
- type IStorage
- type ITask
- type ITaskRunConfiguration
- type ITrace
- type LogLevel
- type NoSQLRow
- type NoSQLRows
- type RouteFunc
- type SQLRow
- type SQLRows
- type TaskRunAfter
- type TaskRunTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IAerospike ¶ added in v0.4.0
type IAerospike interface {
// CRUD operations
Exists(ctx context.Context, key *aerospike.Key, policy *aerospike.BasePolicy) bool
Count(ctx context.Context, key *aerospike.Key, policy *aerospike.BasePolicy) int64
FindOne(ctx context.Context, key *aerospike.Key, policy *aerospike.BasePolicy, bins []string) (NoSQLRow, error)
Find(ctx context.Context, query *aerospike.Statement, policy *aerospike.QueryPolicy) (NoSQLRows, error)
Exec(ctx context.Context, key *aerospike.Key, policy *aerospike.WritePolicy, packageName string, functionName string) (NoSQLRows, error)
Insert(ctx context.Context, key *aerospike.Key, query interface{}, policy *aerospike.WritePolicy) (interface{}, error)
Delete(ctx context.Context, key *aerospike.Key, policy *aerospike.WritePolicy) int64
DeleteMany(ctx context.Context, keys []*aerospike.Key, policy *aerospike.BatchPolicy, policyDelete *aerospike.BatchDeletePolicy) int64
// Advanced operations
Operate(ctx context.Context, query []aerospike.BatchRecordIfc) (int64, error)
// Access underlying database client
GetDb() *aerospike.Client
}
type ICache ¶
type ICache interface {
Init(app IEngine) error
Stop() error
String() string
/*
Has checks if the given key exists.
It returns true if the key exists, false otherwise.
Parameters:
- key (string): The key to check.
Returns:
- bool: true if the key exists, false otherwise.
*/
Has(ctx context.Context, key string) bool
/*
Set sets a key with the provided data and expiration time.
Parameters:
- key: the key to set
- args: the data to be stored, can be of type []byte, string, or any other type that can be converted to string
- timeout: the duration after which the key will expire
Returns:
- error: an error if the key could not be set
*/
Set(ctx context.Context, key string, args any, timeout time.Duration) error
/*
SetIn updates the value of a specific key within a map stored. If the key does not exist, a new map is created.
It takes the key, the subkey, the value to set, and the timeout duration as parameters.
Parameters:
- key: the key of the map
- key2: the subkey within the map to update
- args: the value to set
- timeout: the duration for which the data should be stored
Returns:
- error: an error if the operation fails, nil otherwise
*/
SetIn(ctx context.Context, key string, key2 string, args any, timeout time.Duration) error
/*
SetMap sets a key-value pair by marshaling the input args into JSON format before calling the Set method.
Parameters:
- key: the key to set
- args: the value to set, will be marshaled into JSON format
- timeout: the duration after which the key-value pair will expire
Returns:
- error: an error if the operation encounters any issues, nil otherwise
*/
SetMap(ctx context.Context, key string, args any, timeout time.Duration) error
/*
Get retrieves the value associated with the given key.
Parameters:
- key (string): The key to look up.
Returns:
- any: The value associated with the key.
- error: An error, if any occurred during the retrieval process. Returns ErrKeyNotFound if the key is not found in the cache.
*/
Get(ctx context.Context, key string) (any, error)
/*
GetIn retrieves the value associated with the specified key and subkey.
Parameters:
- key: The key to look up.
- key2: The subkey to look up within the key's associated value.
Returns:
- any: The value associated with the key and subkey.
- error: An error if the key, subkey, or associated value is not found.
Notes:
- If the key or subkey is not found, an error with ErrKeyNotFound will be returned.
*/
GetIn(ctx context.Context, key string, key2 string) (any, error)
/*
GetMap retrieves a value using the specified key and returns it as a map[string]interface{}.
Parameters:
- key (string): The key used to retrieve the value.
Returns:
- map[string]interface{}: The value retrieved stored as a map.
- error: An error if any occurred during the retrieval or unmarshalling process.
*/
GetMap(ctx context.Context, key string) (any, error)
/*
Increment increments the value of the given key by the specified amount.
If the key does not exist, it sets the key with the provided value and expiration time.
Parameters:
- key: The key to increment.
- val: The amount by which to increment the value of the key.
- timeout: The duration after which the key will expire.
Returns:
- int64: New value
- error: An error if any occurred during the increment operation, or setting the key, or touching the key with the new expiration time.
*/
Increment(ctx context.Context, key string, val int64, timeout time.Duration) (int64, error)
/*
IncrementIn increments the value associated with key2 in the map stored at key by the specified value val.
If the key does not exist, a new map is created. If an error occurs during the retrieval of the map, it is returned.
If the value at key2 is not an integer, an error is returned.
Parameters:
- key: The key of the map to be incremented.
- key2: The key within the map whose value will be incremented.
- val: The value by which to increment the existing value at key2.
- timeout: The duration after which the operation times out.
Returns:
- int64: New value
- error: An error if any occurred during the operation.
*/
IncrementIn(ctx context.Context, key string, key2 string, val int64, timeout time.Duration) (int64, error)
/*
Decrement decrements the value associated with the given key by the specified amount.
If the key is not found in the cache, it returns ErrKeyNotFound.
If any other error occurs during the decrement operation, that error is returned.
After decrementing the value, it updates the expiration time of the key with the provided timeout.
Parameters:
- key: The key for which the value needs to be decremented.
- val: The amount by which the value should be decremented.
- timeout: The duration after which the key should expire if not accessed.
Returns:
- int64: New value
- error: An error if the decrement operation or updating the expiration time fails.
*/
Decrement(ctx context.Context, key string, val int64, timeout time.Duration) (int64, error)
/*
DecrementIn decrements the value associated with key2 in the map stored at key by the specified val.
If the key does not exist, a new map will be created.
If key2 does not exist in the map, key2 will be added with the negative value of val.
The updated map will then be stored with the specified timeout.
Parameters:
- key: The key under which the map is stored.
- key2: The key within the map whose value needs to be decremented.
- val: The value by which key2 should be decremented.
- timeout: The duration after which the updated map will expire.
Returns:
- int64: New value
- error: An error if the operation encounters any issues, nil otherwise.
*/
DecrementIn(ctx context.Context, key string, key2 string, val int64, timeout time.Duration) (int64, error)
/*
Delete deletes the value for a key.
If the key is not found in the cache, it returns ErrKeyNotFound.
If an error occurs during the deletion operation, that error is returned.
Parameters:
- key (string): The key for which the value needs to be deleted.
Returns:
- error: An error if the deletion operation encounters any issues.
*/
Delete(ctx context.Context, key string) error
Expire(ctx context.Context, key string, timeout time.Duration) error
}
type IClientBase ¶ added in v0.3.0
type IClientGrpc ¶ added in v0.3.0
type IClientGrpc interface {
IClient
GetClient() *grpc.ClientConn
}
type IClientResponse ¶ added in v0.0.9
type IConfig ¶
type IConfig interface {
Init(app IEngine) error
Stop() error
Has(key string) bool
GetString(key string, def string) string
GetBool(key string, def bool) bool
GetInt(key string, def int) int
GetFloat(key string, def float64) float64
GetMapString(key string, def map[string]string) map[string]string
GetMapBool(key string, def map[string]bool) map[string]bool
GetMapInt(key string, def map[string]int) map[string]int
GetMapFloat(key string, def map[string]float64) map[string]float64
GetSliceString(key string, def []string) []string
GetSliceBool(key string, def []bool) []bool
GetSliceInt(key string, def []int) []int
GetSliceFloat(key string, def []float64) []float64
}
type IController ¶
type IDatabase ¶
type IDatabase interface {
Init(app IEngine) error
Stop() error
String() string
Query(ctx context.Context, query string, args ...interface{}) (SQLRows, error)
QueryRow(ctx context.Context, query string, args ...interface{}) (SQLRow, error)
Exec(ctx context.Context, query string, args ...interface{}) error
GetDb() interface{}
}
type IEngine ¶ added in v0.2.0
type IEngine interface {
Init() error
Stop() error
GetLogger() ILogger
GetConfig() IConfig
SetMetrics(c IMetrics)
SetTrace(c ITrace)
PushCache(c ICache) IEngine
GetCache(key string) ICache
PushDatabase(c IDatabase) IEngine
GetDatabase(key string) IDatabase
PushNoSql(c INoSql) IEngine
GetNoSql(key string) INoSql
PushController(c IController) IEngine
GetController(key string) IController
PushModule(c IModules) IEngine
GetModule(key string) IModules
PushRepository(c IRepository) IEngine
GetRepository(key string) IRepository
PushService(c IService) IEngine
GetService(key string) IService
PushTask(c ITask) IEngine
GetTask(key string) ITask
RemoveTask(key string)
RunTask(key string, args map[string]interface{}) error
PushServer(c IServer) IEngine
GetServer(key string) IServer
PushClient(c IClient) IEngine
GetClient(key string) IClient
PushStorage(c IStorage) IEngine
GetStorage(key string) IStorage
PushMiddleware(c IMiddleware) IEngine
GetMiddleware(key string) IMiddleware
}
type ILogger ¶
type ILogger interface {
Init(cfg IConfig) error
Stop() error
SetLevel(level LogLevel)
Debug(ctx context.Context, args ...interface{})
Info(ctx context.Context, args ...interface{})
Warn(ctx context.Context, args ...interface{})
Message(ctx context.Context, args ...interface{})
Error(ctx context.Context, err error)
Fatal(ctx context.Context, err error)
Panic(ctx context.Context, err error)
}
type IMiddleware ¶ added in v0.0.9
type IMongoDB ¶ added in v0.4.0
type IMongoDB interface {
// CRUD operations
Exists(ctx context.Context, collection string, query interface{}) bool
Count(ctx context.Context, collection string, query interface{}, opt *options.CountOptions) int64
FindOne(ctx context.Context, collection string, query interface{}, opt *options.FindOneOptions) (NoSQLRow, error)
FindOneAndUpdate(ctx context.Context, collection string, query interface{}, update interface{}, opt *options.FindOneAndUpdateOptions) (NoSQLRow, error)
Find(ctx context.Context, collection string, query interface{}, opt *options.FindOptions) (NoSQLRows, error)
Exec(ctx context.Context, collection string, query interface{}, opt *options.AggregateOptions) (NoSQLRows, error)
Insert(ctx context.Context, collection string, query interface{}, opt *options.InsertOneOptions) (interface{}, error)
Update(ctx context.Context, collection string, query interface{}, update interface{}, opt *options.UpdateOptions) error
Delete(ctx context.Context, collection string, query interface{}, opt *options.DeleteOptions) int64
// Advanced operations
Batch(ctx context.Context, collection string, query []mongo.WriteModel, opt *options.BulkWriteOptions) (int64, error)
// Access underlying database
GetDb() *mongo.Database
}
type IRepository ¶
type IServerBase ¶ added in v0.3.0
type IServerGRPC ¶ added in v0.3.0
type IServerGRPC interface {
IServer
RegisterService(desc *grpc.ServiceDesc, impl any)
}
type IStorage ¶
type IStorage interface {
Init(app IEngine) error
Stop() error
String() string
Has(name string) bool
Put(name string, data io.Reader) error
StoreFolder(name string) error
Read(name string) (io.ReadCloser, error)
Delete(name string) error
List(path string) ([]string, error)
IsFolder(name string) (bool, error)
GetSize(name string) (int64, error)
GetModified(name string) (int64, error)
}
type ITaskRunConfiguration ¶ added in v0.2.0
type ITaskRunConfiguration interface {
}
type TaskRunAfter ¶ added in v0.2.0
type TaskRunAfter struct {
ITaskRunConfiguration
Restart <-chan time.Duration
After time.Duration
}
type TaskRunTime ¶ added in v0.2.0
type TaskRunTime struct {
ITaskRunConfiguration
Restart <-chan time.Time
To time.Time
}
Click to show internal directories.
Click to hide internal directories.