Documentation
¶
Index ¶
- Constants
- Variables
- func BuildSqlSelect(params ...interface{}) string
- func SetManual(man map[string]string) map[string]string
- type ConsumerCallback
- type ConsumerCallbackIsDone
- type Database
- type Embedded
- type EmbeddedOptions
- type Encoder
- type Encoding
- type GoogleServicesKey
- type Kafka
- type KafkaOptions
- type KafkaProviderConfig
- type Kms
- type Messages
- type Mongo
- type MongoClientEncrypted
- type MongoEncrypted
- type MongoKeyProviderConfig
- type MongoProviderConfig
- type MongoSecureField
- type MongoSecureFieldData
- type ProducerIsReady
- type Provider
- type RabbitMQ
- type RabbitMQOptions
- type RabbitMQProviderConfig
- type Redis
- type RedisProviderConfig
- type SQL
- type SQLConfig
- type SqlEncryptType
- type SqlEncrypted
- func (c *SqlEncrypted) Encrypt(data interface{}) SqlEncryptedField
- func (c *SqlEncrypted) EncryptedIndexWhere(col string, cond string, params interface{}) clause.Expr
- func (c *SqlEncrypted) EncryptedSelect(params ...string) []string
- func (c *SqlEncrypted) EncryptedWhere(col string, cond string, params string) clause.Expr
- func (c *SqlEncrypted) SelfEncrypt(data interface{}) SqlEncryptedField
- type SqlEncryptedField
- type SqlEncryptedList
- type VaultConfig
Constants ¶
View Source
const MongoDefaultAlg = "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
View Source
const MongoDefaultDataKey = "default-data-key"
View Source
const MongoDefaultSecureField = "__encrypted__"
View Source
const MongoKeyVaultColl = "__keyVault"
View Source
const MongoRandomAlg = "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
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: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: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`,
}
View Source
var RecordNotFound = errors.New("record not found in database")
RecordNotFound - global error record not found type
Functions ¶
func BuildSqlSelect ¶ added in v0.0.9
func BuildSqlSelect(params ...interface{}) string
BuildSqlSelect - column:alias, ex : "users.email::email"
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 GoogleServicesKey ¶ added in v0.0.9
type GoogleServicesKey struct { Type string `json:"type"` ProjectId string `json:"project_id"` PrivateKeyId string `json:"private_key_id"` PrivateKey string `json:"private_key"` ClientEmail string `json:"client_email"` ClientId string `json:"client_id"` AuthUri string `json:"auth_uri"` TokenUri string `json:"token_uri"` AuthProviderX509CertUrl string `json:"auth_provider_x509_cert_url"` ClientX509CertUrl string `json:"client_x509_cert_url"` }
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 Mongo ¶ added in v0.0.9
type Mongo interface { Get(encOption *options.AutoEncryptionOptions) (client *mongo.Client, err error) CreateEncryptedKeys(keys []string, bypassAutoEncryption, bypassQueryAnalysis bool) (enc *MongoEncrypted, err error) GetEncrypted(schemaMap map[string]interface{}, enc *MongoEncrypted, bypassAutoEncryption, bypassQueryAnalysis bool) (en *MongoEncrypted, err error) GetQueryableEncrypted(encryptedFieldsMap map[string]interface{}, enc *MongoEncrypted, bypassAutoEncryption, bypassQueryAnalysis bool) (res *MongoEncrypted, err error) DropQueryableEncryptedCollection(dbName, collName string, enc *MongoEncrypted) error DefaultClient() (err error) Client() *mongo.Client AddKms(name string, kms Kms) GetKms(name string) (kms Kms) GetConfig() MongoProviderConfig }
type MongoClientEncrypted ¶ added in v1.0.0
type MongoClientEncrypted struct {
// contains filtered or unexported fields
}
func NewMongoClientEncrypted ¶ added in v1.0.0
func NewMongoClientEncrypted(keyName string, db Mongo, encoding string) *MongoClientEncrypted
func (*MongoClientEncrypted) Decrypt ¶ added in v1.0.0
func (c *MongoClientEncrypted) Decrypt(raw bson.Raw, desc interface{}) error
func (*MongoClientEncrypted) Encrypt ¶ added in v1.0.0
func (c *MongoClientEncrypted) Encrypt(data interface{}) interface{}
type MongoEncrypted ¶ added in v0.0.9
type MongoKeyProviderConfig ¶ added in v0.0.9
type MongoKeyProviderConfig struct { SecretKey string `yaml:"secretkey" default:"" desc:"config:mongo:secretkey"` KMIpAddress string `yaml:"kMIpAddress" default:"" desc:"config:mongo:kMIpAddress"` AccessKeyId string `yaml:"accessKeyId" default:"" desc:"config:mongo:accessKeyId"` SecretAccessKey string `yaml:"secretAccessKey" default:"" desc:"config:mongo:secretAccessKey"` Key string `yaml:"key" default:"" desc:"config:mongo:key"` Region string `yaml:"region" default:"" desc:"config:mongo:region"` GoogleServicesKey GoogleServicesKey `yaml:"googleServicesKey" default:"" desc:"config:mongo:googleServicesKey"` Location string `yaml:"location" default:"" desc:"config:mongo:location"` KeyRing string `yaml:"keyRing" default:"" desc:"config:mongo:keyRing"` KeyName string `yaml:"keyName" default:"" desc:"config:mongo:keyName"` TlsCertificateKeyFile string `yaml:"tlsCertificateKeyFile" default:"" desc:"config:mongo:tlsCertificateKeyFile"` TlsCAFile string `yaml:"tlsCAFile" default:"" desc:"config:mongo:tlsCAFile"` Vault VaultConfig `yaml:"vault" default:"" desc:"config:mongo:vault"` }
type MongoProviderConfig ¶ added in v0.0.9
type MongoProviderConfig struct { 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"` MongodCryptdPort int `yaml:"mongodCryptdPort" default:"27020" desc:"config:mongo:mongodCryptdPort"` KeyProvider string `yaml:"keyProvider" default:"local" desc:"config:mongo:keyProvider"` KeyProviderConfig MongoKeyProviderConfig `yaml:"keyProviderConfig" desc:"config:mongo:keyProviderConfig"` }
MongoProviderConfig - Mongodb configuration
If Uri not empty, Host, Port, UserName, Password and Options will be ignored
type MongoSecureField ¶ added in v1.0.0
type MongoSecureField struct { Version int `json:"version"` KeyId string `json:"keyId"` Encoding string `json:"encoding"` Data map[string]MongoSecureFieldData `json:"data"` // contains filtered or unexported fields }
func NewMongoSecureField ¶ added in v1.0.0
func NewMongoSecureField(kms Kms, encoding string) *MongoSecureField
func (*MongoSecureField) AddData ¶ added in v1.0.0
func (c *MongoSecureField) AddData(name string, data interface{})
type MongoSecureFieldData ¶ added in v1.0.0
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 RedisProviderConfig ¶ added in v0.0.2
type RedisProviderConfig struct { 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 { 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"` }
type SqlEncryptType ¶ added in v0.0.9
type SqlEncryptType int
const ( EncryptTypeCustom SqlEncryptType = 0 EncryptTypeNative = 1 )
type SqlEncrypted ¶ added in v0.0.9
type SqlEncrypted struct { Kms Kms // contains filtered or unexported fields }
func NewSqlEncrypted ¶ added in v0.0.9
func NewSqlEncrypted(kms Kms, tp SqlEncryptType) *SqlEncrypted
func (*SqlEncrypted) Encrypt ¶ added in v0.0.9
func (c *SqlEncrypted) Encrypt(data interface{}) SqlEncryptedField
func (*SqlEncrypted) EncryptedIndexWhere ¶ added in v1.0.0
func (c *SqlEncrypted) EncryptedIndexWhere(col string, cond string, params interface{}) clause.Expr
func (*SqlEncrypted) EncryptedSelect ¶ added in v0.0.9
func (c *SqlEncrypted) EncryptedSelect(params ...string) []string
func (*SqlEncrypted) EncryptedWhere ¶ added in v0.0.9
func (*SqlEncrypted) SelfEncrypt ¶ added in v0.0.9
func (c *SqlEncrypted) SelfEncrypt(data interface{}) SqlEncryptedField
type SqlEncryptedField ¶ added in v0.0.9
type SqlEncryptedField struct { Raw interface{} `json:"Raw"` // contains filtered or unexported fields }
func (SqlEncryptedField) GormDBDataType ¶ added in v0.0.9
func (SqlEncryptedField) GormDataType ¶ added in v0.0.9
func (c SqlEncryptedField) GormDataType() string
func (*SqlEncryptedField) Scan ¶ added in v0.0.9
func (c *SqlEncryptedField) Scan(value interface{}) error
type SqlEncryptedList ¶ added in v1.0.0
func NewSqlEncryptedList ¶ added in v1.0.0
func NewSqlEncryptedList() *SqlEncryptedList
func (*SqlEncryptedList) Get ¶ added in v1.0.0
func (c *SqlEncryptedList) Get(key string) *SqlEncrypted
func (*SqlEncryptedList) Store ¶ added in v1.0.0
func (c *SqlEncryptedList) Store(key string, d *SqlEncrypted)
Click to show internal directories.
Click to hide internal directories.