Help us shape the future of Go! Take the 2026 Go Developer Survey

intf

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppServer added in v0.0.8

type AppServer interface {
	Start() error                               // 开始
	Stop(forced ...bool) error                  // 默认为优雅关闭, 如果forced为true, 则强制关闭
	HookPreStart(fns ...HookFunction) AppServer // 添加启动前的钩子函数
	HookPreStop(fns ...HookFunction) AppServer  // 添加停止前的钩子函数
}

type ConfigProvider

type ConfigProvider interface {
	Provider
	Unmarshal(configVar any, key ...string) error // 读取配置到变量configVar
	Get(key string) any                           // 获取配置项的值
}

type DataAccessObject added in v0.0.21

type DataAccessObject[businessObject any, modelObject any, Condition any] interface {
	Create(businessObject) (int64, error)                                            // 创建对象
	Edit(businessObject) error                                                       // 编辑对象
	Delete(id int64) error                                                           // 删除对象
	Get(id int64) (modelObject, error)                                               // 获取对象
	BulkGet(ids []int64) (map[int64]modelObject, error)                              // 批量获取对象
	Count(filters map[string]string) (int64, error)                                  // 统计对象
	List(filters map[string]string, list *protobuf.ListParam) ([]modelObject, error) // 列出对象
	GetQueryConditions(filters map[string]string) []Condition                        // 获取查询条件
}

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 DbProvider interface {
	Provider
	My() DbClient
	Master() DbClient
	Slave(i int) DbClient
	By(name string) DbClient
}

type HookFunction added in v0.0.8

type HookFunction func() error

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 ...*types.PublisherOption) (MessageQueuePublisher, error)
	NewSubscriber(name string, args ...*types.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 *types.Message, error)
	// Close closes all subscriptions with their output channels and flush offsets etc. when needed.
	Close() error
}

type OssProvider added in v0.0.3

type OssProvider interface {
	Provider
	WithContentTypes(contentTypes []string) OssProvider                                   // 设置允许的文件类型
	WithMaxFileSize(fileSize int64) OssProvider                                           // 设置允许最大的文件大小
	WithSignExpiresIn(duration time.Duration) OssProvider                                 // 设置签名过期时间
	Upload(dir, filename string, data []byte) (string, error)                             // 上传文件
	GetPresignedURL(dir, filename, contentType string) (string, map[string]string, error) // 生成预签名URL, 返回URL,headers
	GetPostSignature(dir, filename string) (map[string]string, error)                     // 生成POST签名
}

type Provider added in v0.0.4

type Provider interface {
	GetCapability() types.Capability // 获取能力
}

Provider 底层库能力提供者接口

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 any) ([]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
}

Jump to

Keyboard shortcuts

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