Documentation
¶
Index ¶
- Variables
- func SetManual(man map[string]string) map[string]string
- type ConsumerCallback
- type ConsumerCallbackIsDone
- type Database
- type Embedded
- type EmbeddedOptions
- type Encoder
- type Encoding
- type Kafka
- type KafkaOptions
- type KafkaProviderConfig
- type Messages
- type Mongo
- type MongoProviderConfig
- type ProducerIsReady
- type Provider
- type RabbitMQ
- type RabbitMQOptions
- type RabbitMQProviderConfig
- type Redis
- type RedisProviderConfig
- type SQL
- type SQLConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigManual = map[string]string{
"config:autoReconnect": `auto reconnect database in first init`,
"config:startInterval": `first timeout duration after failed`,
"config:maxError": `how many reconnect before trigger error`,
"config:sql:name": `database config name, optional`,
"config:sql:enable": `enable sql database`,
"config:sql:host": `sql server address, must be valid rules hostname_rfc1123
ex: localhost, 127.0.0.1, service.domain, 10.10.10.10, etc.`,
"config:sql:port": `sql server port number`,
"config:sql:username": `sql server username`,
"config:sql:password": `sql server password`,
"config:sql:database": `sql database name`,
"config:sql:options": `this option will be added after connection string`,
"config:sql:connection": `if this value not empty, another mysql parameter will be ignored.
use this, if you have a custom protocol connection.
like username:password@unix(/tmp/mysql.sock)/dbname.`,
"config:sql:dbPath": `sqlite database file location path`,
"config:rabbitmq:enable": `enable rabbitmq database message brokers`,
"config:rabbitmq:host": `rabbitmq server address, must be valid rules hostname_rfc1123
ex: localhost, 127.0.0.1, service.domain, 10.10.10.10, etc.`,
"config:rabbitmq:port": `rabbitmq server port number`,
"config:rabbitmq:username": `rabbitmq server username`,
"config:rabbitmq:password": `rabbitmq server password`,
"config:rabbitmq:reconnectDuration": `rabbitmq reconnect duration (in second).`,
"config:rabbitmq:dedicatedConnection": `dedicated connection for each consumer, more reliable but more cost.`,
"config:redis:name": `database config name, optional`,
"config:redis:host": `redis server address, must be valid rules hostname_rfc1123
ex: localhost, 127.0.0.1, service.domain, 10.10.10.10, etc.`,
"config:redis:port": `redis server port number`,
"config:redis:password": `redis server password`,
"config:redis:pool": `number of redis pool`,
"config:mongo:name": `database config name, optional`,
}
View Source
var RecordNotFound = errors.New("record not found in database")
RecordNotFound - global error record not found type
Functions ¶
Types ¶
type ConsumerCallback ¶
type ConsumerCallback func(Messages, ConsumerCallbackIsDone)
type ConsumerCallbackIsDone ¶ added in v0.0.6
type ConsumerCallbackIsDone struct { Done context.CancelFunc EndRequest func() }
type Database ¶
type Database interface { Init(logger.Logger) SetTracer(tracing.Tracing) LoadRabbitMQ(string, RabbitMQProviderConfig) RabbitMQ LoadSQL(string, SQLConfig) SQL LoadRedis(string, RedisProviderConfig) Redis LoadEmbedded(EmbeddedOptions) Embedded LoadKafka(string, KafkaProviderConfig) Kafka LoadMongo(tag string, config MongoProviderConfig) Mongo }
type Embedded ¶
type Embedded interface { DB() *nutsdb.DB Set(bucket string, key string, value interface{}, encoding Encoding) (err error) Get(bucket string, key string, value interface{}, encoding Encoding) (err error) Delete(bucket string, key string) (err error) GetAllKeys(bucket string) (keys []string, err error) }
type EmbeddedOptions ¶
type EmbeddedOptions struct {
Directory string
}
type Kafka ¶ added in v0.0.6
type Kafka interface { Consumer(KafkaOptions, ConsumerCallback) Producer(ProducerIsReady) Push(ctx context.Context, id string, options KafkaOptions, body interface{}, cb ConsumerCallback) error }
type KafkaOptions ¶ added in v0.0.6
type KafkaProviderConfig ¶ added in v0.0.6
type KafkaProviderConfig struct { Enable bool `yaml:"enable" default:"false" desc:"config:kafka:enable"` Host string `yaml:"host" default:"127.0.0.1:9092" desc:"config:kafka:host"` Registry string `yaml:"registry" default:"" desc:"config:kafka:registry"` Username string `yaml:"username" default:"" desc:"config:kafka:username"` Password string `yaml:"password" default:"" desc:"config:kafka:password"` SecurityProtocol string `yaml:"securityProtocol" default:"SASL_SSL" desc:"config:kafka:securityProtocol"` Mechanisms string `yaml:"mechanisms" default:"PLAIN" desc:"config:kafka:mechanisms"` Debug string `yaml:"debug" default:"consumer" desc:"config:kafka:debug"` }
type Messages ¶
type MongoProviderConfig ¶ added in v0.0.9
type MongoProviderConfig struct { Name string `yaml:"name" default:"" desc:"config:mongo:name"` Enable bool `yaml:"enable" default:"false" desc:"config:mongo:enable"` Uri string `yaml:"uri" default:"" desc:"config:mongo:uri"` Host string `yaml:"host" default:"127.0.0.1" desc:"config:mongo:host"` Port int `yaml:"port" default:"27017" desc:"config:mongo:port"` UserName string `yaml:"username" default:"root" desc:"config:mongo:username"` Password string `yaml:"password" default:"root" desc:"config:mongo:password"` Database string `yaml:"database" default:"sample_database" desc:"config:mongo:database"` Options string `yaml:"options" default:"options" desc:"config:mongo:options"` AutoReconnect bool `yaml:"autoReconnect" default:"false" desc:"config:autoReconnect"` StartInterval int `yaml:"startInterval" default:"2" desc:"config:startInterval"` MaxError int `yaml:"maxError" default:"5" desc:"config:maxError"` }
MongoProviderConfig - Mongodb configuration
If Uri not empty, Host, Port, UserName, Password and Options will be ignored
type ProducerIsReady ¶ added in v0.0.6
type ProducerIsReady func()
type RabbitMQ ¶
type RabbitMQ interface { Consumer(RabbitMQOptions, ConsumerCallback) Producer(RabbitMQOptions) Push(ctx context.Context, id, exchange, key string, body interface{}, cb ConsumerCallback) error }
type RabbitMQOptions ¶
type RabbitMQProviderConfig ¶
type RabbitMQProviderConfig struct { Enable bool `yaml:"enable" default:"false" desc:"config:rabbitmq:enable"` Host string `yaml:"host" default:"127.0.0.1" desc:"config:rabbitmq:host"` Port int `yaml:"port" default:"5672" desc:"config:rabbitmq:port"` Username string `yaml:"username" default:"guest" desc:"config:rabbitmq:username"` Password string `yaml:"password" default:"guest" desc:"config:rabbitmq:password"` ReconnectDuration int `yaml:"reconnectDuration" default:"5" desc:"config:rabbitmq:reconnectDuration"` DedicatedConnection bool `yaml:"dedicatedConnection" default:"false" desc:"config:rabbitmq:dedicatedConnection"` }
type Redis ¶ added in v0.0.2
type Redis interface { Init() error GetClient() (pool radix.Client) GetConfig() RedisProviderConfig }
type RedisProviderConfig ¶ added in v0.0.2
type RedisProviderConfig struct { Name string `yaml:"name" default:"" desc:"config:redis:name"` Enable bool `yaml:"enable" default:"false" desc:"config:redis:enable"` Host string `yaml:"host" default:"127.0.0.1" desc:"config:redis:host"` Port int `yaml:"port" default:"6379" desc:"config:redis:port"` Password string `yaml:"password" default:"" desc:"config:redis:password"` Pool int `yaml:"pool" default:"10" desc:"config:redis:pool"` AutoReconnect bool `yaml:"autoReconnect" default:"false" desc:"config:autoReconnect"` StartInterval int `yaml:"startInterval" default:"2" desc:"config:startInterval"` MaxError int `yaml:"maxError" default:"5" desc:"config:maxError"` }
type SQLConfig ¶
type SQLConfig struct { Name string `yaml:"name" default:"" desc:"config:sql:name"` Driver string `yaml:"driver" default:"mysql" desc:"config:sql:enable"` Enable bool `yaml:"enable" default:"false" desc:"config:sql:enable"` Host string `yaml:"host" default:"127.0.0.1" desc:"config:sql:host"` Port int `yaml:"port" default:"3306" desc:"config:sql:port"` Username string `yaml:"username" default:"root" desc:"config:sql:username"` Password string `yaml:"password" default:"root" desc:"config:sql:password"` Database string `yaml:"database" default:"sample_database" desc:"config:sql:database"` Options string `yaml:"options" default:"" desc:"config:sql:options"` Connection string `yaml:"connection" default:"" desc:"config:sql:connection"` AutoReconnect bool `yaml:"autoReconnect" default:"false" desc:"config:autoReconnect"` StartInterval int `yaml:"startInterval" default:"2" desc:"config:startInterval"` MaxError int `yaml:"maxError" default:"5" desc:"config:maxError"` DBPath string `yaml:"dbPath" default:"./sqlite.db" desc:"config:sql:dbPath"` SsLMode string `yaml:"sslMode" default:"disable" desc:"config:sql:sslMode"` TimeoutConnection int `yaml:"timeoutConnection" default:"5000" desc:"config:sql:timeoutConnection"` TimeoutTransaction int `yaml:"timeoutTransaction" default:"5000" desc:"config:sql:timeoutTransaction"` }
Click to show internal directories.
Click to hide internal directories.