Documentation ¶
Index ¶
- type Config
- type Engine
- type H
- type Id
- func (f Id) Base2() string
- func (f Id) Base32() string
- func (f Id) Base36() string
- func (f Id) Base58() string
- func (f Id) Base64() string
- func (f Id) Bytes() []byte
- func (f Id) Int64() int64
- func (f Id) IntBytes() [8]byte
- func (f Id) MarshalJSON() ([]byte, error)
- func (f Id) Node() int64
- func (f Id) Step() int64
- func (f Id) String() string
- func (f Id) Time() int64
- func (f *Id) UnmarshalJSON(b []byte) error
- type Propagation
- type Session
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v1.0.2
type Config struct { Pkg string // 生成的xml文件的包名 DriverName string // 驱动名称。例如: mysql,postgreSQL... DSN string // 数据库连接信息。例如: "root:root@(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local" MaxOpenConn int // 最大的并发打开连接数。例如: 这个值是5则表示==>连接池中最多有5个并发打开的连接,如果5个连接都已经打开被使用,并且应用程序需要另一个连接的话,那么应用程序将被迫等待,直到5个打开的连接其中的一个被释放并变为空闲。 MaxIdleConn int // 最大的空闲连接数。注意: MaxIdleConn 应该始终小于或等于 MaxOpenConn,设置比 MaxOpenConn 更多的空闲连接数是没有意义的,因为你最多也就能拿到所有打开的连接,剩余的空闲连接依然保持的空闲。 ConnMaxLifetime time.Duration // 连接的最大生命周期(默认值:0)。设置为0的话意味着没有最大生命周期,连接总是可重用。注意: ConnMaxLifetime 越短,从零开始创建连接的频率就越高! ConnMaxIdleTime time.Duration PrintSql bool // 设置是否打印SQL语句 PrintXml bool // 是否打印 xml文件信息 PrintWarn bool // 是否打印警告 TxEnable bool // 是否启用嵌套事务(如果使用嵌套事务,则必须设置 TxEnable == true) }
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
type Id ¶ added in v1.2.3
type Id int64
func (Id) Base32 ¶ added in v1.2.3
Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func (Id) IntBytes ¶ added in v1.2.3
IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.
func (Id) MarshalJSON ¶ added in v1.2.3
MarshalJSON returns a json byte array string of the snowflake ID.
func (Id) Node ¶ added in v1.2.3
Node returns an int64 of the snowflake ID node number DEPRECATED: the below function will be removed in a future release.
func (Id) Step ¶ added in v1.2.3
Step returns an int64 of the snowflake step (or sequence) number DEPRECATED: the below function will be removed in a future release.
func (Id) Time ¶ added in v1.2.3
Time returns an int64 unix timestamp in milliseconds of the snowflake ID time DEPRECATED: the below function will be removed in a future release.
func (*Id) UnmarshalJSON ¶ added in v1.2.3
UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.
type Propagation ¶ added in v1.2.3
type Propagation int
const ( Required Propagation = iota //(默认)如果当前有事务,就用当前事务。如果当前没有事务,就新建一个事务 。have tx ? join : new tx() Support //支持当前事务,如果当前没有事务,就以非事务方式执行。 have tx ? join(): session.exec() Mandatory //支持当前事务,如果当前没有事务,则返回事务嵌套错误。 have tx ? join() : return error News //新建一个全新Session开启一个全新事务,如果当前存在事务,则把当前事务挂起。 have tx ? stop old。 -> new session().new tx() NotSupport //以非事务方式执行操作,如果当前存在事务,则新建一个Session以非事务方式执行操作,并把当前事务挂起。 have tx ? stop old。 -> new session().exec() Never //以非事务方式执行操作,如果当前存在事务,则返回事务嵌套错误。 have tx ? return error: session.exec() Nested //如果当前事务存在,则在嵌套事务内执行,如嵌套事务回滚,则只会在嵌套事务内回滚,不会影响当前事务。如果当前没有事务,则进行与Required类似的操作。 )
type Session ¶
type Session interface { Begin(p *Propagation) error Commit() error Rollback() error Id() string Close() LastPropagation() *Propagation // contains filtered or unexported methods }