types

package
v0.0.0-...-76471f1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENV_PRODUCTION     = "prod"
	ENV_PRE_PRODUCTION = "pre"
	ENV_SIMULATION     = "sim"
	ENV_TEST           = "test"
	ENV_DEV            = "dev"
	ENV_LOCAL          = "local"
)

环境变量的参数

View Source
const (
	MqTypeDirect = "direct"
	MqTypeFanout = "fanout"
	MqTypeTopic  = "topic"
)
View Source
const (
	PROVIDER_TYPE_DEFAULT = "default"
	PROVIDER_TYPE_MASTER  = "master"
	PROVIDER_TYPE_SLAVE   = "slave"
	PROVIDER_TYPE_OTHER   = "other"
)
View Source
const (
	CAP_PROVIDER_KV_ETCD // etcd能力
)

key/value storage ability

View Source
const (
	CAP_PROVIDER_NOSQL_ES // elasticSearch能力
)

nosql db ability

View Source
const SdkCategoryOffset = 10

底层库能力类别

Variables

View Source
var (
	ErrMissingValue  = errors.New("(MISSING)")
	ErrEmptyConfig   = errors.New("empty config")
	ErrInvalidConfig = errors.New("invalid config")
	ErrNoProvider    = errors.New("provider not found")
	ErrNoCapability  = errors.New("capability not defined")
)

所有支持的环境

Functions

This section is empty.

Types

type CacheClient

type CacheClient 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
	Pipeline(commands []*CacheCommand) (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 get
	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)

	// 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) (map[string]string, error)
	ZRemRangeByScore(key string, min, max interface{}) error
	ZRangeByScore(key string, min, max interface{}) ([]string, error)
	ZScore(key string, member interface{}) (int64, error)
	ZInterstore(newKey string, keys ...interface{}) (int64, error)

	// list
	RPop(key string) ([]byte, error)
}

type CacheCommand

type CacheCommand struct {
	Name string
	Args []interface{}
}

type CacheProvider

type CacheProvider interface {
	Provider
	My() CacheClient
	By(string) CacheClient
}

type Configer

type Configer interface {
	GetLogConfig() interface{} // 日志配置
	// 数据库配置
	GetMysqlConfig() interface{} // mysql数据库配置
	// 缓存配置
	GetRedisConfig() interface{} // redis缓存配置
	// GetRabbitmqConfig 获取RabbitMq队列配置
	GetRabbitmqConfig() interface{}
	// GetKafkaConfig 获取kafka消息队列配置
	GetKafkaConfig() interface{}
	GetNosqlConfig() interface{} // NoSQL服务配置
	GetKvConfig() interface{}    // kv型服务配置
}

type DbClient

type DbClient interface {
	// Rebind transforms a query from QUESTION to the DB driver's bindvar type.
	Rebind(query string) string

	Get(dest interface{}, query string, args ...interface{}) error
	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
}

type DbProvider

type DbProvider interface {
	Provider

	My() *sqlx.DB // 默认我们的数据库连接
	Master() *sqlx.DB
	Slave(int) *sqlx.DB
	By(string) *sqlx.DB // 获取某个名字的数据库连接
}

database能力提供

type KvProvider

type KvProvider interface {
}

type LogProvider

type LogProvider interface {
	Provider

	GetStdLogger() *log.Logger

	// Log add go-kit log compatibility
	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 Mq

type Mq interface {
	GetDefaultOptions() map[MqOptionType]MqOptioner
	CreateProducer(name string, args ...map[MqOptionType]MqOptioner) (MqProducer, error)
	CreateConsumer(name string, processFunc MqMsgProcessFunc, args ...map[MqOptionType]MqOptioner) (MqConsumer, error)
}

type MqConsumer

type MqConsumer interface {
	Consume() // 消费消息
	Close()
}

消息订阅者,负责从Topic接收并消费消息。

type MqMsgAction

type MqMsgAction int

消息处理后的动作

const (
	Ack        MqMsgAction // 消息标志处理成功
	Retry                  // 消息重传进行重新处理,当条消息会被重传
	Next                   // 取下一条消息
	BatchAck               // 批量消息标志处理成功
	BatchRetry             // 批量消息进行重传并重新处理,自上次ack到现在的消息都会被重传
)

type MqMsgProcessFunc

type MqMsgProcessFunc func([]byte) MqMsgAction

MQ的消息处理函数 入参为处理的数据 第一个返回值是否要ack 第二个返回值是否要把同一个channel上的上一次ack之前的所有

type MqOptionType

type MqOptionType int

option types

const (
	MqOptionQueue    MqOptionType // 队列选项
	MqOptionExchange              // exchange选项
	MqOptionPublish               // 发送选项
	MqOptionConsume               // 消费选项
	MqOptionQos                   // Qos选项
)

type MqOptioner

type MqOptioner interface {
	GetType() MqOptionType // 获取配置项类型,现在有几个配置项: exchange配置项, queue配置项, publish配置项
}

选项接口

type MqProducer

type MqProducer interface {
	Publish(data []byte, args ...interface{}) error // MQ发送消息
	GetLastConfirmedId() uint64                     // 获取上一次确认发送成功的消息Tag
	Close()
}

消息发布者,负责生产并发送消息至Topic

type MqProvider

type MqProvider interface {
	Provider
	My() Mq
	By(string) Mq // 获取某个Mq能力提供者
}

type NosqlProvider

type NosqlProvider interface {
}

type Provider

type Provider interface {
	Init(rootConfiger Configer, logger LogProvider, args ...interface{}) error // 初始化底层能力
}

底层库能力提供者接口

type SdkConfigItem

type SdkConfigItem struct {
	Log      interface{} `mapstructure:"log"`    // 日志配置
	Mysql    interface{} `mapstructure:"mysql"`  // 数据库配置
	Redis    interface{} `mapstructure:"redis"`  // 缓存配置
	RabbitMq interface{} `mapstructure:"aliyun"` // rabbitmq消息队列配置
	Kafka    interface{} `mapstructure:"kafka"`  // kafka消息队列配置
	Alidts   interface{} `mapstructure:"alidts"` // aliyun dts数据同步服务配置
	Nosql    interface{} `mapstructure:"nosql"`  // NoSQL配置
	Kv       interface{} `mapstructure:"kv"`     // Key/Value数据库配置
}

items under sdk config

type SdkType

type SdkType int
const (
	SdkTypeMqRabbitmq SdkType // rabbitmq消息队列能力
	SdkTypeMqKafka            // kafka
)

message queue provider

const (
	SdkCategoryLog   SdkType // 日志能力
	SdkCategoryDb            // 数据库能力, 例如mysql
	SdkCategoryCache         // 缓存能力,例如redis
	SdkCategoryMq            // 消息队列能力,例如rabbitmq, rocketmq, kafka
	SdkCategoryDts           // 数据同步能力,aliyun dts
	SdkCategoryNosql         // nosql数据库能力,例如es, monodb
	SdkCategoryKv            // kv型数据库能力,例如etcd
)
const (
	LibLogZerolog SdkType
)

log ability

const (
	SdkTypeCacheRedis SdkType // redis缓存能力
)

cache ability

const (
	SdkTypeDbMysql SdkType
)

database capability

Jump to

Keyboard shortcuts

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