Documentation ¶
Index ¶
- type Capability
- type ConfigProvider
- type DbBuilderClient
- type DbBuilderProvider
- type DbClient
- type DbProvider
- type LoggerProvider
- type MessageQueueProvider
- type MessageQueuePublisher
- type MessageQueueSubscriber
- type Provider
- type ProviderCategory
- type ProviderName
- type RedisClient
- type RedisCommand
- type RedisProvider
- type Sqlizer
- type SqlxDbClient
- type SqlxDbProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capability ¶
type Capability struct { Category ProviderCategory Name ProviderName Module fx.Option }
Capability 能力提供者
type ConfigProvider ¶
type DbBuilderClient ¶
type DbBuilderProvider ¶
type DbBuilderProvider interface { Provider My() DbBuilderClient Master() DbBuilderClient Slave(i int) DbBuilderClient By(name string) DbBuilderClient Set(sqlizer Sqlizer) }
type DbClient ¶
type DbClient interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row Get(dest interface{}, query string, args ...interface{}) error Select(dest interface{}, query string, args ...interface{}) error Rebind(query string) string Close() error }
type DbProvider ¶
type LoggerProvider ¶
type LoggerProvider interface { Provider GetStdLogger() *log.Logger Log(keyvals ...interface{}) error Trace(msg string, keyvals ...interface{}) Debug(msg string, keyvals ...interface{}) Info(msg string, keyvals ...interface{}) Warn(msg string, keyvals ...interface{}) Error(msg string, keyvals ...interface{}) Fatal(msg string, keyvals ...interface{}) Panic(msg string, keyvals ...interface{}) }
type MessageQueueProvider ¶
type MessageQueueProvider interface { Provider NewPublisher(name string, args ...*mq.PublisherOption) (MessageQueuePublisher, error) NewSubscriber(name string, args ...*mq.SubscriberOption) (MessageQueueSubscriber, error) }
MessageQueueProvider 相同name的多个订阅者如果订阅同一个topic,则只有一个订阅者会收到消息 不同name的多个订阅者果订阅同一个topic,则所有订阅者都会收到消息
type MessageQueuePublisher ¶
type MessageQueuePublisher interface { // Publish publishes provided messages to given topic. // // Publish can be synchronous or asynchronous - it depends on the implementation. // // Most publishers implementations don't support atomic publishing of messages. // This means that if publishing one of the messages fails, the next messages will not be published. // // Publish must be thread safe. Publish(topic string, messages [][]byte, delaySeconds ...int64) error // Close should flush unsent messages, if publisher is async. Close() error }
type MessageQueueSubscriber ¶
type MessageQueueSubscriber interface { // Subscribe returns output channel with messages from provided topic. // Channel is closed, when Close() was called on the subscriber. // // To receive the next message, `Ack()` must be called on the received message. // If message processing failed and message should be redelivered `Nack()` should be called. // // When provided ctx is cancelled, subscriber will close subscribe and close output channel. // Provided ctx is set to all produced messages. // When Nack or Ack is called on the message, context of the message is canceled. Subscribe(ctx context.Context, topic string) (<-chan *mq.Message, error) // Close closes all subscriptions with their output channels and flush offsets etc. when needed. Close() error }
type ProviderCategory ¶
type ProviderCategory int
const ( ProviderCategoryUnknown ProviderCategory = iota ProviderCategoryConfig ProviderCategoryLogger ProviderCategoryDb ProviderCategoryRedis ProviderCategoryMq ProviderCategoryDbSqlx ProviderCategoryDbBuilder )
type ProviderName ¶
type ProviderName string
const ( ProviderNameConfigViper ProviderName = "config-viper" ProviderNameLoggerZerolog ProviderName = "logger-zerolog" ProviderNameRedisRedigo ProviderName = "redis-redigo" ProviderNameDbSqlBoilerMysql ProviderName = "db-sqlboiler-mysql" ProviderNameDbSqlBoilerSqlite ProviderName = "db-sqlboiler-sqlite3" ProviderNameDbSqlxMysql ProviderName = "db-sqlx-mysql" ProviderNameDbSquirrelMysql ProviderName = "db-squirrel-mysql" ProviderNameMqRabbitMq ProviderName = "mq-rabbitmq" )
type RedisClient ¶
type RedisClient interface { // general purpose Del(key string) error Dels(keys []string) error Exists(key string) (bool, error) Expire(key string, expire int) error Incr(key string) error IncrBy(key string, number int) error DecrBy(key string, number int) error Ttl(key string) (int64, error) Pipeline(commands []*RedisCommand) (reply interface{}, err error) Ping() error // Set operations Set(key string, value interface{}) error SetEx(key string, value interface{}, expire int) error // Get operations Get(key string) ([]byte, error) GetInt(key string) (int, error) GetInt64(key string) (int64, error) GetFloat64(key string) (float64, error) GetString(key string) (string, error) // HashMap operations HGetAll(key string) (map[string]string, error) HGet(key string, field string) ([]byte, error) HGetInt(key string, field string) (int, error) HGetInt64(key string, field string) (int64, error) HGetFloat64(key string, field string) (float64, error) HGetString(key string, field string) (string, error) HMGet(key string, fields []string) ([][]byte, error) HSet(key string, field interface{}, value interface{}) (int, error) HMSet(key string, args map[string]interface{}) error HDel(key string, field interface{}) (int, error) HDels(key string, fields []interface{}) (int, error) HLen(key string) (int, error) // set SIsMember(key string, member interface{}) (bool, error) SAdd(key string, members interface{}) error SRem(key string, members interface{}) error SInter(keys []string) ([]string, error) SUnion(keys []string) ([]string, error) SDiff(keys []string) ([]string, error) SMembers(key string) ([]string, error) // zset ZAdd(key string, score int64, member interface{}) error ZCard(key string) (int, error) ZRange(key string, min, max int64) ([]string, error) ZRemRangeByScore(key string, min, max interface{}) error ZRangeByScore(key string, min, max interface{}, withScores bool, list *protobuf.ListParam) ([]string, error) ZScore(key string, member interface{}) (int64, error) ZInterstore(newKey string, keys ...interface{}) (int64, error) ZIncrBy(key string, increment int64, member interface{}) error ZRem(destKey string, members ...interface{}) (int64, error) // list LPush(key string, values ...any) error RPush(key string, values ...any) error RPop(key string) ([]byte, error) LRangeInt64(key string, start, end int64) ([]int64, error) LRangeString(key string, start, end int64) ([]string, error) LLen(key string) (int64, error) Eval(scriptContent string, keys []interface{}, args []interface{}) (interface{}, error) // redis bloom BfExists(key string, item string) (exists bool, err error) BfAdd(key string, item string) (exists bool, err error) BfReserve(key string, errorRate float64, capacity uint64) (err error) BfAddMulti(key string, items []interface{}) ([]int64, error) BfExistsMulti(key string, items []interface{}) ([]int64, error) }
type RedisCommand ¶
type RedisCommand struct { Name string Args []interface{} }
type RedisProvider ¶
type RedisProvider interface { Provider My() RedisClient By(string) RedisClient }
type SqlxDbClient ¶
type SqlxDbProvider ¶
type SqlxDbProvider interface { Provider My() SqlxDbClient Master() SqlxDbClient Slave(i int) SqlxDbClient By(name string) SqlxDbClient }
Click to show internal directories.
Click to hide internal directories.